Table of Contents
A re-implementation of 3D Tetris, along with a genetic programming algorithm that steadily improves its performance of playing the game.
Includes visualizations through a chart and replays of "fit" individuals in each generation.
Node is required to run the simulation. Python 2 is required to run the genetic algorithm. Python 3 is required to run the web server
Python 2.7 or higher (for genetic algorithm), and also python-pip
Python 3.5 or higher (for web server), and also python3-pip
Node 6.x or higher (for simulation)
Clone the repository and change directory to it.
Set up Python virtual environment. Also make sure that your working directory has no spaces in it.
python3 -m pip install virtualenv flask python3 -m virtualenv env python -m pip install virtualenv enum zerorpc python -m virtualenv env2
- Set up NPM dependencies.
cd simulation npm install
How to run
To go into a virtual environment: (Linux/Mac)
source env/bin/activate (Windows)
Running the genetic algorithm
To run, you need two terminals.
cd simulation && node index.js
(Make sure this one is in the virtual environment
Genetic algorithm will run until 1000 generations by default. This can be configured in
Running the web server
- (Make sure this one is in the virtual environment
The web server hosts data files which consist of a csv file (generations vs score) and a json file (replay data) which configure the
ai endpoint. The
/ endpoint lets you play the game on a browser with WebGL and ES6 support.
Pull requests will always be welcome!
[ ] Use a transpiler for older browser support [ ] Improve genetic algorithm [ ] Alternate views for the 3D Tetris game [ ] Improve documentation [ ] Add testing [ ] And more...