What's New
Debug Tools
Realtime fitness display and fitness calculation performance. Additionally, the snake's color changes from red to green based on its performance in the simulation (green=fitness increasing, red=fitness decreasing).
Logger
now has instances pointing to a text file that it can access to store current console output. When the unit test has concluded, an instance is closed, saving the output and date the instance was created to a .txt
file. I also plan on giving the unit tester an option to store the statistics of the population directly in a .csv
file once the snake populations improve more.
NeuralNetwork Re-write
The NeuralNetwork
struct now can save instances to a series of data buffers in a specified location. Naturally, I have also created functionality for an instance to load the Mojo tensors stored in a data buffer back into its existing PyTorch tensors. I originally wanted to use Mojo's native tensors but they don't have an optimized version of __matmul__
yet and attempts to make my own implementation have failed miserably. I may decide to return to this but for now, I have resorted to using PyTorch.
The NeuralNetwork
struct also now works for more generalized use cases other than snake simulation. It can have an unlimited number of hidden layers for convolution. Additionally, NeuralNetwork
has more write protection for ensuring tensor specs match.
Tuning Pruning Algorithm
Pruning snakes with low fitness scores has been worked on. However, this has much to be improved upon. The snakes still fail to pass on only important traits needed to avoid wall collisions. I will most likely need to adjust the input vectors being fed into the snake's NeuralNetwork
. Snakes with fitness below a certain pivot are replaced by the best snake (the mutated) and snakes above a certain pivot are only mutated, excluding the best snake which is preserved without mutation.