Mirror of GitHub, please open issues and pull requests on GitHub

Jack Chatelain 97b42384d8 Update README.md 6 ヶ月 前
.github 86f76edcf0 trying to fix a deploy problem 2 年 前
content d1fde4b23f Disallow putting piece in full column (Fixed) 6 ヶ月 前
.gitignore c65e694f43 Add .DS_Store to gitignore 6 ヶ月 前
LICENSE 283f7d920d just organizing everything 2 年 前
README.md 97b42384d8 Update README.md 6 ヶ月 前
mkdocs.yml d67c57e3de adicao de um conjunto de slides 1 年間 前
requirements.txt a496d40a09 No meio da documentacao 2 年 前

README.md

A fork of Connect 4 by fbarth, which is a fork of Connect 4 by Keith Galli

Features I added:

  • Show if game is a tie
  • Do nothing if the user tries to put a piece in a column that's full
  • Vsync for Windows and Linux (untested because I'm on MacOS)

Connect4-Python

(The original readme is below, which has been translated to English with DeepL)

This project consists of two main components:

  • src: which contains the implementation of the game and the agents (robots)
  • content: which contains all the teaching material on the subject.

The entire implementation was done in Python. This project is a fork of Keith Galli's project. Some modifications have been made to the implementation, mainly to allow robot-on-robot play.

All the teaching material is new.

The license for this project is MIT License, as can be seen in the LICENSE file in the repository. In other words, you can use all the material for any purpose you like. However, it is necessary to cite the authors of this project.

Fabrício Barth is a full-time professor at Insper Instituto de Ensino e Pesquisa.

Setup

To set up the project, I recommend creating a virtual environment:

python3.9 -m virtualenv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt

Running the mkdocs server on the local machine

To run the documentation server on a local machine just type:

cd content
mkdocs serve

Deploying documentation using github actions

There is a main.yml file in the .github/workflows directory that defines the deployment of documentation on github's gh-pages using actions.

Examples of running the Liga4 or Connect4 game

The game can be initialized in a few ways via src/connect4.py or src/connect4_with_ai.py:

  • src/connect4.py: two players playing manually.
  • src/connect4_with_ai.py: one manual player and one artificial player.
  • python connect4_with_ai.py random: the artificial player behaves randomly.
  • python connect4_with_ai.py minmax 5: the artificial player implements the min-max algorithm. The number entered is the depth that the min-max algorithm will consider - it must be a value greater than or equal to 1.

  • python connect4_with_ai.py flat: is equivalent to running minmax at depth 1. It is used to show the behavior of an agent that only evaluates the first level of the tree.

  • python connect4_with_ai.py complete: is equivalent to running minmax at depth 20. It is used to show the behavior of an agent that evaluates the entire search tree.

  • python connect4_ai_versus_ai.py random 0 minmax 5: the first argument defines the first player. If it is random then the second argument can be any value. The third argument defines the second player. If the player is minmax then the subsequent argument must always be the depth adopted by minmax.

Compile the slides

To view the files in the slides folder or generate pdf from them, just use any Markdown plugin in VSCode.