This is my AI course final project. I implemented a connect-4 game with a GUI and a simple AI. The AI uses the minimax algorithm with alpha-beta pruning to find the best move and reinforcement learning.
Read the wiki for more information about the project and How implemented the heuristic function and the Q-Learning.
$ docker run -p 5000:5000 ilovebacteria/connect-4:latest
HOST_ADDR
: The host address. (default127.0.0.1
)DEBUG
: The flask debug mode. (defaultFalse
)
-
Clone the repository.
-
Open the terminal in the project folder and run these commands to install dependencies.
pipenv install npm install
-
Run this
npm
command to build the project.npm run build
-
Run this
pipenv
command to run the Flask server.pipenv run server
-
Open the browser and go to
http://localhost:5000/
.
In the Q-Learning, 2 agents play against each other. At the end of each game, the winning agent will be rewarded with
1000
and the loser agent will be punished with -1000
. Both agents will be rewarded 0
if the game ends with a draw.
connect_4
package provides a CLI. You can use it to train the AI. It will create q_table.csv
file if it doesn't exist.
If it exists, it will load the Q-Table from it and continue training.
The Q-Table has 4 columns. The first 3 columns are the state of the board and action, and the last column is the Q-Value.
pipenv run python -m connect_4 train --count-games 10