Reinforcement learning: learning by trying
INTERMEDIATE · 7 MIN READ
The robot tries things, gets a score, and slowly learns which actions earn the most.
In reinforcement learning, nobody tells the robot the right answer. It tries an action, the world responds, and a reward score says whether that was good. Over many tries it learns to pick actions that earn more reward.
It is how you teach a dog tricks with treats, except the robot can try millions of times. That is why most of the practice happens in a simulator, where mistakes are free and fast.
The robot starts top-left (🤖) and wants the flag (🏁). Red squares are holes. It is never told the route. It only gets a score: +10 for the flag, -10 for a hole, a tiny penalty per step. Press train and watch the arrows appear.
Tries so far: 0
After about 100 tries the arrows should lead around the holes to the flag. A good route here is 10 steps. Press Reset and train only 1 or 10 times to see how a robot with little practice wanders.
A walking robot is rewarded for moving forward and punished for falling. After millions of simulated tries it discovers a walking style no engineer wrote by hand.
You can get skills that are too hard to program by hand, like balancing, walking or juggling.
You must hand-code every motion. For complex bodies this takes years and still looks stiff.
Play a simple game and write down your own "reward" for each move. You just did what the algorithm does.
Common questions
Why train in simulation?
A real robot can break and is slow. A simulator runs thousands of practice attempts in minutes at no risk.
Does the skill work on a real robot?
Often with extra work. The gap between simulation and reality is a well-known problem called sim-to-real.
Keep learning
Get your personal invite link to share R2BOT with friends.
Teachers and bloggers: paste the embed code into your page to show this demo for free.
Plain English. Free. Unsubscribe in one click.