Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Connect4 game #5

Merged
merged 12 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and Test Documentation

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:

test-docs:
runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt

- name: Build documentation
run: |
sphinx-build -b html docs/ docs/_build/html

- name: Documentation tests
run: |
sphinx-build -W --keep-going -b spelling docs/ docs/_build/spelling
38 changes: 38 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test Python Package Installation

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
install:
runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Extract branch name
id: branch
run: echo "BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Install package from current branch
run: pip install --upgrade git+https://github.com/jparisu/IArena.git@${BRANCH}

- name: Run tests
run: pytest
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# IArena

<img src="resources/images/logo.webp" alt="drawing" width="20%"/>

[![Documentation Status](https://readthedocs.org/projects/iarena/badge/?version=latest)](https://iarena.readthedocs.io/en/latest/)

**Framework** for testing **AI** system in basic or logic games.
Expand Down Expand Up @@ -29,6 +31,7 @@ There are some games implemented under `src/IArena/games`:
- `FieldWalk`: Similar to `BlindWalk` but with access to the whole map from the beginning.
- `Coins`: 2 player Roman coins game.
- `Nim`: 2 player well known Nim game.
- ...

### Players

Expand All @@ -38,6 +41,7 @@ There are some players implemented under `src/IArena/players`:
- `RandomPlayer`: Play a random movement from the movements possible.
- `FirstPlayer`: Play the first movement from the movements possible.
- `LastPlayer`: Play the last movement from the movements possible.
- ...

### Arena

Expand All @@ -46,6 +50,7 @@ Implementations of different ways of playing and measuring scores:
- `GenericGame`: Decide the rules and the players and create a basic loop game.
- `BroadcastGame`: Similar to `GenericGame` but print out the player actions.
- `PlayableGame`: Play a game with all players `PlayablePlayer`.
- ...

---

Expand All @@ -63,3 +68,5 @@ There are some resources under `resources` folder with util information and impl
### From source

```bash
pip install --upgrade git+https://github.com/jparisu/IArena.git
```
7 changes: 7 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@

# The master toctree document.
master_doc = 'index'

# The spelling list filename.
spelling_word_list_filename=['spelling/spelling_wordlist.txt']

# Change tab title
release = '1.0.0'
html_title = f"{project} {release} Documentation"
14 changes: 12 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
:maxdepth: 2
:hidden:

/src/getting_started
/src/installation
/src/getting_started/getting_started
/src/getting_started/installation
/src/getting_started/tutorial


.. toctree::
Expand Down Expand Up @@ -35,6 +36,7 @@
/src/games/tutorials/mastermind
/src/games/tutorials/prisoner
/src/games/tutorials/highestcard
/src/games/tutorials/connect4


.. toctree::
Expand All @@ -43,3 +45,11 @@
:hidden:

/src/arena/arena


.. toctree::
:caption: Appendixes
:maxdepth: 2
:hidden:

/src/appendixes/glossary
18 changes: 9 additions & 9 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
doc8==0.10.1
docutils==0.16.0
GitPython==3.1.32
setuptools==65.5.1
sphinx_rtd_theme==0.5.2
sphinx-tabs==3.2.0
sphinx==4.3.1
sphinxcontrib-imagehelper==1.1.1
sphinxcontrib.spelling==7.2.1
doc8
docutils
GitPython
setuptools
sphinx_rtd_theme
sphinx-tabs
sphinx
sphinxcontrib-imagehelper
sphinxcontrib.spelling
Binary file added docs/resources/images/connect4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/images/logo.webp
Binary file not shown.
12 changes: 12 additions & 0 deletions docs/spelling/spelling_wordlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Colab
IArena
IGameRules
IMovement
IPosition
IPlayer
Tic
Tac
Toe
conda
NQueens
Jupyter
26 changes: 26 additions & 0 deletions docs/src/appendixes/glossary.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

.. _glossary:

########
Glossary
########

.. glossary::

Arena
A class that represents the game flow. Uses one GameRule and several players to play a game, returning the final score.

GameRule
A class that defines the rules of a game. It contains methods to help creating the game flow.

Movement
A class that represents a movement in a game. Along with GameRules, generates new Positions given a source one.

Player
A class that represents a player in a game. It contains the method to return a movement given a position.

Position
A class that represents a specific state of a game. Along with the GameRules, it defines the game.

Score
A class that represents the score of a terminated game. Each player has its own score.
21 changes: 15 additions & 6 deletions docs/src/games/games.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ The *IGameRules* holds the logic of the game.
The *IPosition* represents a position or state of the game regarding a specific set of rules.
The *IMovement* represents a movement of the game that goes from one position to another.

.. _rules:
.. _igamerules:

------
IRules
------
----------
IGameRules
----------

Represent the rules of a game implementing the following methods:

Expand Down Expand Up @@ -76,7 +76,7 @@ Represent the rules of a game implementing the following methods:



.. _movement:
.. _imovement:

---------
IMovement
Expand All @@ -86,7 +86,7 @@ Represent a movement of a game.
It does not have general methods, as each movement depends on the rules of the specific game.


.. _position:
.. _iposition:

---------
IPosition
Expand Down Expand Up @@ -236,3 +236,12 @@ This is a list of all the games supported and its characteristics:
- Random
- Hidden information
-

* - **Connect 4**
- ``IArena.games.Connect4``
- :ref:`connect4`
- Connect 4 game.
- 2
- Deterministic
- Perfect information
- **0 sum game**
1 change: 0 additions & 1 deletion docs/src/games/tutorials/coins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ A position is represented by an ``int`` describing the size of the remaining sta
Rules
=====

This games has every methods of :ref:`IRules <infrastructure_rules>`.

It counts with 2 methods to get the minimum and maximum number of coins that can be taken:

Expand Down
Loading