Welcome to Connect-N’s documentation!¶
Connect-N¶
Introduction¶
A simple modified version of Connect Four Game implemented with AI in Python using PyGame.
Project Description¶
This repositry contains a simple game made in python similar to Connect 4.
A bit modified to work with any connect length for any board size.
Currently supports for variable number of players on a two dimentional board.
Only three players supported in GUI mode.
For more players add new colours
COLOR
variable in connect_n/pygame_utility.py file.ID 1 is reserved for AI.
Currently only supports single AI player in a game.
Tests in python 3.7 on Windows OS(by developer).
API: used flask for API development.
Using flask-migrate for database migration.
Using httpie for API calls and testing, similar to postman.
Installation¶
Via pip
¶
pip install --user --upgrade --no-cache connect-n
Via source¶
git clone https://github.com/Kartikei-12/Connect-N
cd Connect-N-master
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
python -m unittest discover --verbose
Simple Example¶
from connect_n import Player, ConnectNGame
if __name__ == "__main__":
game = ConnectNGame(graphic=True, ai=True, record=False)
game.add_player(Player("Human Player"))
game.play()
API¶
API Setup(One time)¶
git clone https://github.com/Kartikei-12/Connect-N
cd Connect-N-master
python -m venv venv
./venv/Scripts/activate
pip install -r requirements.txt
cd connect_n/api/
pip install -r requirements.txt
flask db init
flask db migrate -m "Initial migration"
flask db upgrade
cd ../../
API Usage¶
Run server with flask run
in Connect-N/connect_n/api
directory.
API Call: In new terminal do http GET http://127.0.0.1:5000/test
System Requirements¶
Limitation¶
GUI NOT working inside docker, because no support for pygame inside Docker. Workaround: Code automatically switches to command line interface without raising error connect_n/connect_n.py.
Contributer(s)¶
Help Needed¶
Looking for any algorithm which may be useful for designing AI for turn based games with more than two players.
Looking for a front end developer for making API front end for web and android.
Acknowledgment¶
Thanks to Miguel Grinberg for excelent resource on flask and how to learn it.
Thanks to freecodecamp for the great beginning boost.