greerviau / SnakeAI

Train a Neural Network to play Snake using a Genetic Algorithm
MIT License
2.34k stars 553 forks source link

Saved model file does not load #16

Open josefczyz opened 3 years ago

josefczyz commented 3 years ago

Loading the saved .csv model file failed if we trained model with more generations than are weights in level L0.

Method in SnakeAI.pde: void fileSelectedIn(File selection)

157: while(genscore != 0)

it should be while((genscore != 0) & (g<modelTable.getRowCount()-1))

E.g. For topology 1x4 we have 25x4 L0 weights => rows in saved output .csv file If the simulation is performed for more than 100 generations (101) than 100th row in saved .csv file it will have in Graph column genscore<>0 and 101st row will not exist. An error exception will be thrown and the model will not be loaded.

It's just work around. In case we need a Graph of progress, the results of the score per generation should be saved in a separate file.