Info
This post was imported from a personal note. It may contain inside jokes, streams of consciousness, errors, and other nonsense.
I added a button to fast forward until 80% of the food is consumed or 10,000 steps have elapsed, whichever comes first. I’m really surprised at the boids’ behaviour. It doesn’t even to converge on having the boid turn to face food which seems pretty basic. In fact, on my latest experiment with dozens of iterations they converged to 0±0.1. Weird, right?
Tried another run of several generations and still got the turning away behaviour. They do seem to get better at finding food over time, just based on the time it takes to reach the 80% end condition getting shorter when I hit fast forward.
What if I seed the population with what I think it should do? Will they take over or will it go back to what it usually does?
Okay, after like twenty generations all the boids do what I seeded with.
What could be going on?
- Mutations might be too small to find other strategies so I end up with boids climbing up the same small hill of fitness.
- My strategy works once you get there but it’s hard to get there.
- Food sources are so abundant it’s not important to find a great solution.
Whoa. That would be cool to visualize the parameter space like above and see what is going on.
What can I work on?
- Reporting on the fitness of the entire system at each generation.
- Speed up the simulation. Find the current bottleneck and improve it.
- Add UI to run several generations worth of simulations in a row.
-
Have a visual readout of the neural network weights so it’s easier to see what it’s converging to (0 is white, 1 is green, -1 is red). - Add UI to generate random boids instead of loading from the CSV.
- Setup a code formatter.
- Remove the player avatar and related code? Or will it be useful for testing other world features as I add them?
Wow, the Visual Studio flame graph for CPU usage is great.
Looks like it’s showing how much time is spent in each function. If I want to optimize stuff it’d be great to have data on how long it takes to run several thousand steps before and after.
I’ll need to do some learning if I go this route so maybe not yet. Google Benchmark looks promising. https://www.youtube.com/watch?v=nXaxk27zwlk&ab_channel=CppCon
A lot of love for Tracy for profiling in general but I guess I’m already on Visual Studio.
Improved Reporting #
Even better:
Generation: 17
Steps: 489
Fitness scores, weights:
4; 0.99 -0.55 0.86 -0.21 0.19 1.00
3; 0.76 -0.43 0.93 -0.20 0.28 0.79
3; 0.80 -0.38 0.94 -0.31 0.39 0.73
3; 0.73 -0.35 0.89 -0.19 0.35 0.79
2; 0.77 -0.61 0.91 0.02 0.01 0.92
2; 1.00 -0.52 0.76 -0.22 0.23 1.00
2; 0.81 -0.32 0.94 -0.19 0.30 0.81
2; 0.61 -0.64 0.78 -0.01 0.04 0.93
2; 0.80 -0.42 0.97 -0.28 0.37 0.84
1; 0.71 -0.40 0.88 -0.32 0.31 0.81
I briefly tried outputting unicode to the terminal so I could use the special shading characters to give a visual sense of the neural network weights. Dese bois here:░ ▒ ▓ █
No dice, tho. Windows isn’t too supportive of those kinds of shenanigans even with setting the output mode as in this SO answer.
https://stackoverflow.com/a/12015918
#include <iostream>
#include <io.h>
#include <fcntl.h>
int main() {
_setmode(_fileno(stdout), _O_U16TEXT);
std::wcout << L"Hello, \u0444!\n";
}
Also, through testing the reporting I’ve been seeing that w5 shift toward high positive values so maybe I wasn’t crazy.
…
Also added a button to repopulate with boids with random neural networks. Might be that should be the default.