Neuroevolution game assignment.
Fall 2021 - Computer Intelligence.
This game has been developed as an assignment for students at Amirkabir University of Technology to apply neuroevolution using a simple game.

You can find project's description in Persian in this file.
- Python 3.8 or higher
- Pygame 2.0.1 or higher
- Clone the repository
- Run
python game.py
This game has two modes: Manual and Neuroevolution.
In this mode, you can control the snail using the space bar.
In this mode, the snail is controlled by a neural network.
- Create a simple game use pygame
- Create a simple neural network
- Create a simple genetic algorithm
- Create a simple neuroevolution algorithm
- Create a simple neuroevolution algorithm with genetic algorithm
game.py: Main file to run the game- include all other files
nn.py: Neural network classNeuralNetworkclass__init__: initialize neural networkforward: feed forward functionbatch_normalize: normalize inputactivation: activation functionsigmoid: use sigmoid activation function
evolution.py: Evolution classEvolutionclass__init__: initialize evolutionnext_population_selection: select next population from current population and wrire to average.txt use Q-Tournament if you want to use SUS selection, uncomment line 46 to 62 and comment line 65 to 74generate_new_population: generate new population from current populationmutate: mutate a populationclone_player: clone a player
player.py: Player classPlayerclass__init__: initialize playerflip_player_horizontally: flip player horizontallyupdate: update player use neural network or keyboardanimation_state: animate playerapply_gravity: apply gravity to playerplayer_input: get player input in manual modechange_gravity: change gravitythink: get output from neural network and change gravitymake_inputs: make inputs for neural networkbatch_normalize: normalize inputs
plot.py: Plot class- plot average score and best score from average.txt
average.txt: save average score and min score from each generation- x y z : max score, min score, average score you can use this file to plot average score and best score
plots of two different runs are: