You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/hoverboard/README.md
+59-16Lines changed: 59 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,17 @@
3
3
The scripts in this directory show examples of using NEAT to control a hoverboard on a game.
4
4
It uses Recurrent Networks to control the intensity of both left and right thrusters of the hoverboard, based on it's velocity, angular velocity and normal vector. All those informations could be retreived from real world sensors.
The evolution converges fast on simple behaviours such as overcoming gravity by boosting both thrusters simultaneously, however a more refined fitness method should include the total variation of velocities and normal vector to help it converge faster to a stable controller.
23
34
24
35
```
25
-
> pip install pygame
26
-
> python evolve-reference.py <START_ANGLE>
36
+
> python evolve-time.py <START_ANGLE>
37
+
38
+
> python evolve-time.py --help
27
39
```
28
40
29
-
The examples have a Command Line Interface, so if you wan't to check more options do:
41
+
## evolve-timedist.py
42
+
43
+
A working example using a Recurrent Network with _NSGA2Reproduction_ method, optimizing two fitness values: flight time and mean squared distance from center.
44
+
The input values are: velocity (X/Y), angular velocity, normal vector (X/Y) and distance to center (X/Y).
45
+
46
+
For each genome, instead of a single cycle this method runs 10 game cycles, starting from 5 preset points (including center) with the starting angle A and -A. The fitness results are accumulated and then divided by 10.
This method converges a lot faster to results way beyond the convergence point of the default method. More about this at the _Results_ section of this document.
51
+
30
52
```
31
-
> python evolve-reference.py --help
53
+
> python evolve-timedist.py <START_ANGLE>
54
+
55
+
> python evolve-timedist.py --help
32
56
```
33
57
34
-
#### Visualize
58
+
##visualize.py
35
59
36
-

60
+
This is a small tool for viewing the generation data stored at checkpoints.
61
+
It allows you to watch the best genome of each generation, as well as plotting fitness and species data over generations.
62
+
The plots on the _Results_ section of this document were made with this tool.
37
63
38
-
WIP: Run this file to watch the best genomes controlling the hoverboard and gerenate a pyplot png.
39
64
```
40
-
> pip install pygame
65
+
> python visualize.py <START_ANGLE> <EXPERIMENT>
66
+
67
+
> python visualize.py --help
41
68
```
42
69
43
-
#### NSGA-II
70
+
## gui.py
71
+
72
+
This is an utilitary lib for drawing neat-python networks using pygame.
73
+
74
+
# Results
75
+
76
+
Here's a quick comparison of results found for this particular hoverboard game with and without the use of NSGA-II. These experiments must be improved in order to better outline the benefits and downsides of this approach. Please feel free to develop them further.
77
+
78
+
The fitness value plotted is Flight Time on both cases. As described above, the NSGA-II example takes the average of 10 runs starting from preset points, to avoid developing behaviours biased on starting at the center.
79
+
The observed increase in mean convergence does not seem to rely on these 10 runs evaluation, it is actually harder to evolve in those conditions.
The distribution of species over generations is heavily affected by NSGA-II. More research is due to evaluate it's cost and benefits. Overall, the species tend to stabilize, having more time to evolve it's features.
84
+
A plot of species on the solution space is due to evaluate their distribution, that should be grouped and moving towards the pareto-front.
44
85
45
-
TODO: The NSGA-II method uses multiple fitness values to pick the best performing genomes of each species.
This plot is messy and needs to be improved. It's a scatter plot of every genome on every generation, color coded.
89
+
In order to visualize the overall movement of the population in the solution space, each generation set of points is filled with a Delaunay Triangulation. You can see the generation shapes moving towards the pareto front.
90
+
A black line represents the best solution of each generation, so you can see the optimization path and convergence.
48
91
49
-
This file presents a class for rendering neural networks on pygame.
0 commit comments