Connect 4 programmed in python using pygame.
Connect-Four is a two-player 6x7 board game where colored discs are dropped vertically down occupying the last available slot within that respective column by taking turns by the players. When we introduce so called "Artificial intelligence" into the game (the agent) we we need to equip the agent with knowledge regarding states, actions and goal (goal test) in order for the agent to achieve it's goal.
Environments have various properties and in the case of connect 4, the game's environmental properties are Accessible, Deterministic, Static and Discrete. There are many approaches that can be employed to solve the Connect-Four game based on the various algorithms, but almost all algorithms have to follow the zero-sum game theory concept where "the total utility score is divided among the players. An increase in one player's score results in decrease in another player's score". This results in an environment which can be represented like this:
The basic flow of the game can be represented like this:
- player vs player
- player vs bot
- bot vs bot
- Random Int Bot (
random
) - One-Step Look Ahead Bot (
onestep
) - MiniMax Bot (
minimax
) - ExpectiMax Bot (
expectimax
) - MonteCarlo Tree Search (
montecarlo
)
- can play in various game mode with UI
- can view performacne of algorithms with or without UI
- ability to choose bots based on
CLI
args (examplepython game.py --p1 minimax --p2 montecarlo --ui false
)--p1
: To select Player 1 Bot.--p2
: To select Player 2 Bot.--ui
: Accepts a boolean value to hide UI incase of bot vs bot--bots
: To list all the Available Bots.
- clone the repo:
git clone https://github.com/mukeshmk/cs7is2-ai-group-proj.git
- create a virtual environment inside the folder:
python -m venv .venv
- activate the virtual environment:
.venv\Scripts\activate
(in case of Windows) - install the required packages for the game to run using:
pip install -r requirements.txt
- run the game:
python game.py
- make sure to
deactivate
once your done.
Basic game code taken from: @KeithGalli from the repo Connect4-Python
This game was developed as part of Trinity College Dublin's CS7IS2 - Artificial intelligence Modules's - Group Project
- The project report can be found here
- The evaluation metrics and reports can be found here
- The win-ratio and comparison between agents can be found here
- The reference papers and articles used in the project report can be found here
Mukesh A | Aishwarya R | Manasi M N | Jagadish R |