EZ LearnEZ Learn
Courses
EZ Board
Dashboard
All articles
ml-for-cyber-securitymlcsq-learningepsilon-greedy

Q-Learning: Learning the Value of Every Action

Q-learning learns a table of the expected future reward of every state-action pair, nudging each estimate toward the reward just observed plus the best value achievable from here on.

Ashish Revar25 October 20265 min read1 views

Q-learning, one of the oldest and most widely taught reinforcement learning algorithms, learns a table (or, for large state spaces, a function) $Q(s, a)$: the expected total future reward of taking action $a$ in state $s$, and then acting optimally afterward. The agent updates its estimate after every step, nudging $Q(s, a)$ toward the reward just observed plus the best value achievable from the next state.

  1. Observe the current state $s$.
  2. Choose an action $a$: usually the action with the highest known $Q(s, a)$, but occasionally a random action (exploration) so the agent keeps discovering better options rather than settling early on a merely adequate policy.
  3. Take the action, observe the reward $r$ and the new state $s'$.
  4. Update: $Q(s,a) \leftarrow Q(s,a) + \alpha \left[ r + \gamma \max_{a'} Q(s',a') - Q(s,a) \right]$, where $\alpha$ is the learning rate and $\gamma$ discounts future reward relative to immediate reward.
  5. Repeat for many episodes, until $Q$ stops changing meaningfully.

ML concept: Exploration versus Exploitation

An agent that always picks the action it currently believes is best (pure exploitation) can get permanently stuck on a mediocre policy it never tests alternatives against. An agent that always picks randomly (pure exploration) never uses what it has learned. Nearly every practical RL agent, including the honeypot agent in the next topic, uses an $\epsilon$-greedy policy: act greedily with probability $1-\epsilon$, act randomly with probability $\epsilon$, and shrink $\epsilon$ as training progresses.

Try it yourself: Trace One Update by Hand

An agent in state $s=3$ takes action $a=1$ and observes reward $r=0.4$, landing in state $s'=4$, where the best known value is $\max_{a'} Q(4,a') = 2.0$. Using $\alpha=0.1$ and $\gamma=0.9$, and given that $Q(3,1)$ currently equals $1.5$, compute the updated value of $Q(3,1)$ using the update rule above.

Related to this topic

Continue learning

Reference material

eBook

ML for Cyber Security eBook

v1.0

Open resource

Cheatsheet

ML for Cyber Security Cheatsheet

v1.0

Open resource

MCQ Bank

ML for Cyber Security MCQ Bank

v1.0

Open resource

Question Bank

ML for Cyber Security Question Bank

v1.0

Open resource

Discussion

Loading comments…
More articlesTest your knowledge
EZ MentorAI · Free

Q-Learning: Learning the Value of Every Action

Hi! I'm EZ Mentor

Your AI tutor for
Q-Learning: Learning the Value of Every Action

Sign in to ask, it's free.

EZ Mentor is AI-powered · Answers may not be perfect · 10 free questions / day

EZ Learn

Structured learning across Reverse Engineering, Cloud Security and Research Methodology, plus games and practice tools. Free, and open to anyone.

Learn

  • Courses
  • EZ Articles
  • EZ Watch
  • EZ Bytes
  • EZ Talks
  • Community

Library & Exams

  • All Resources
  • eBooks & PDFs
  • Question Banks
  • Cheatsheets
  • All Exams
  • EZ Board

EZ Arena

  • EZ Games
  • Byte Rush
  • Firewall Defence
  • 3D Case Files
  • Live Quiz
  • ML Challenges

EZ Cyber Hygiene

  • Hygiene Journey
  • Cyber Safety Check
  • दिशा - Hygiene
  • सजग - Awareness
  • अभ्यास - Practice
  • Scammed? Call 1930

Platform

  • About
  • Contact
  • Events
  • Verify Certificate
  • Terms of Use
  • Disclaimer

© 2026 EZ Learn by EpochZero. Educational content for learning purposes.

Platform Lead: Ashish Revar