Lab · Reinforcement learning
Can a neural network learn to fly?
A little demo showcasing a small neural network trained to travel to a point!
Preface
This is primarily for an assignment in Machine Learning Engineering, so it will not be very pedagocial. Still, I think this is fun to play around with, so maybe you’ll get inspiration to learn a bit about machine learning!
This idea was inspired by this video by Pezzza’s work!
Choose method
Switch checkpoints to see what the same network learned at different points in training.
Controls
The rocket accelerates along its nose. Braking means turning the engine against its motion. This is a spacecraft simulation, with no gravity.
Set a challenge
In neural and hand-written modes, arrow keys place the target when the flight area has focus. Space pauses. Every checkpoint starts from the same flight state when selected.
What does the network know?
Inputs
- Δx / 3
- +1.00
- Δy / 3
- +0.33
- vₓ / 3
- +0.00
- vᵧ / 3
- +0.00
- sin θ
- +0.89
- cos θ
- -0.45
- ω / 6
- +0.00
Position and velocity are relative to the flight frame. The angle is encoded as sine and cosine so a full turn does not create a numerical jump. The actor runs in your browser; it is not learning from your pointer.
What counts as a good move?
Rewards
- Moving closer
- +0.000
- Distance penalty
- +0.000
- Staying close
- +0.000
- Speed near target
- +0.000
- Fuel penalty
- +0.000
- Turning & spin
- +0.000
These terms sum to the live reward per simulation step. The learning algorithm optimizes reward accumulated over time, so a brief negative reward can still be part of a useful braking maneuver.