ExploreMy JigsMission
MakeMake a Jig

© JigSpace Inc. 2026

jig.comContact@JigSpace on X

Reinforcement Learning Maze

publicRemix · Free
DBy DUSK

A robot agent learns a glowing maze by trial and error: states, actions, rewards and Q-learning policy updates, with a live reward chart (bilingual English and Chinese)

Transcript

9 steps · 4 min read
  1. 1

    Step 1: Reinforcement Learning Maze · 强化学习迷宫

    This glowing robot is an agent: a learner that acts. Nobody gives it a map. It learns the way out of the maze by trial and error, guided only by rewards. Drag the scene to look around, or tap any square to see what the agent thinks of it.

    智能体不知道地图,只能靠试错和奖励学会走出迷宫。拖动可旋转视角,点击方格可查看它的价值。

  2. 2

    Step 2: State · 状态

    A state is what the agent knows right now. Here it is simply which square it stands on. This maze has 34 open squares, so the agent can be in 34 different states.

状态 = 智能体此刻所在的方格。这个迷宫共有 34 个可走的方格,也就是 34 种状态。
  • 3

    Step 3: Action · 动作

    In every state the agent can choose one of four actions: move forward, back, left or right. Bumping into a wall leaves it where it was. The four arrows show the actions it can pick from.

    每个状态有四个动作:前、后、左、右。撞墙就原地不动。

  • 4

    Step 4: Reward · 奖励

    After each action the maze answers with a reward: one number. The gold goal gives a plus, and red traps give a minus and end the try. Each step costs a little, so short routes score best. Pick the goal / trap rewards.

    奖励是环境给出的一个数字:金色终点为正,红色陷阱为负,每走一步扣 0.1,所以路线越短越好。

  • 5

    Step 5: Policy update · 策略更新

    For every move in every square, the agent keeps a score called a Q-value: its guess of the reward still to come. After each move it nudges that guess toward what happened, and the learning rate sets the nudge size. Cyan glow spreads back from the goal. The small arrows are its policy, the best move it knows in each square.

    学习率 α 决定每次修正的幅度。价值从终点一格一格往回传,箭头就是策略:每格目前最好的动作。

  • 6

    Step 6: Explore or exploit · 探索与利用

    Should the agent try something new or use what it already knows? With the exploration rate, it picks a random action that share of the time. Purple trails are random tries; cyan moves follow its best guess. Without exploring it may never find a better route.

    ε-贪心:以概率 ε 随机探索(紫色),否则选当前最好的动作(青色)。不探索就可能错过更好的路。

  • 7

    Step 7: Training · 训练

    Learning takes many tries, called episodes. Press Train to play 150 episodes in a few seconds. Watch the reward chart: early tries end in traps or wander, later ones reach the goal by a shorter path. Exploration shrinks a little after every episode.

    每一次从起点出发到结束叫一个回合。训练 150 个回合,看右侧图表里每回合的总奖励逐渐上升。

  • 8

    Step 8: Before and after · 训练前后

    Compare the same robot with an empty Q-table, its list of Q-values, and with its trained one. Both now always pick their best-known move. Before training every move looks equally good, so it wanders. After training it follows the cyan path straight to the goal, in the shortest 14 moves.

    训练前所有动作看起来一样好,只能乱走;训练后它沿青色路径 14 步直达终点。

  • 9

    Step 9: Beyond the maze · 迷宫之外

    In 1950 Claude Shannon built Theseus, a mechanical mouse whose relays remembered a maze after one try. Today the same reward idea trains game players and robots. Big problems have too many states for a table, so a neural network estimates the values instead.

    1950 年香农制作了会“记住”迷宫的机械老鼠忒修斯。现在的深度强化学习用神经网络代替这张价值表。