AP Games
The AP Games is the result of the completion of the project Tic-Tac-Toe with AI at JetBrains Academy. This project was developed just for fun and to learn Python and some concepts of a decision-making algorithm.
Tic-Tac-Toe with AI + bonus Reversi game
Tic-tac-toe, is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is the winner.
Reversi
Reversi is a strategy board game for two players who take turns marking the spaces in an 8x8 board.
Each player must place the piece so that an opponent's piece, or a row of opponent's pieces, is flanked by your pieces. All of the opponent's pieces between your pieces are then turned over to become your color. The object of the game is to own more pieces than your opponent when the game is over. See source.
The example below shows the game interface:
Please choose the game:
0 - Tic-Tac-Toe;
1 - Reversi.
Print 'exit' to exit the program.
Input command: 1
Type 'start user1_type user2_type' to run the selected game,
where user_X_type is one of the supported values:
user, easy, hard and nightmare;
Type 'rules' to get game rules or type 'exit' to return
to the main menu.
Input command: rules
You must place the piece so that an opponent's piece, or a row
of opponent's pieces, is flanked by your pieces.
All of the opponent's pieces between your pieces are then
turned over to become your color. The object of the game is
to own more pieces than your opponent when the game is over.
Input command: start user hard
-------------------
8 | |
7 | |
6 | |
5 | X O |
4 | O X |
3 | |
2 | |
1 | |
-------------------
1 2 3 4 5 6 7 8
Enter the coordinate [X]: 1 1
You cannot go here!
Enter the coordinate [X]: 1
You should enter two numbers!
Enter the coordinate [X]: 4 3
-------------------
8 | |
7 | |
6 | |
5 | X O |
4 | X X |
3 | X |
2 | |
1 | |
-------------------
1 2 3 4 5 6 7 8
Making move level "hard" [O]
-------------------
8 | |
7 | |
6 | |
5 | X O |
4 | O X |
3 | O X |
2 | |
1 | |
-------------------
1 2 3 4 5 6 7 8
Enter the coordinate [X]:
Installation
The project has been tested only with python 3.8 on Ubuntu Linux and Windows 10. If you have python 3.8 and above installed in your machine, just install the AP Games from PyPI:
python --version
pip install ap-games
You can find source code of this package on github. See aplatkouski/ap-games repository.
How to use
Run module:
python -m ap_games [game] [user-1 user-2]
Where:
gameis a value from the following set:0ortic-tac-toefor Tic-Tac-Toe game;1orreversifor Reversi game.
user-1anduser-2are values from the following set:userfor human player;easy,medium,hardandnightmarefor AI player.
Note: Parameters in brackets are optional.
Or open the python console and type:
# Python version 3.8+
from ap_games import cli
cli.main()
Notes
This package can be run as a console game or integrated into another application. This project provides the following basic structures:
SquareGameboardGameBaseTicTacToeReversi
PlayerHumanPlayerAIPlayer- uses mini-max as decision-making algorithm.
Credits
Thanks to Gaurav Sen for his video What is the Minimax Algorithm? - Artificial Intelligence
Development & Contributing
Development of this happens on GitHub, patches including tests, documentation are very welcome, as well as bug reports!
See also our CONTRIBUTING.md.
Copyright
Copyright (c) 2020 Artsiom Platkouski.
AP_games is licensed under the MIT License - see the LICENSE.txt
file for details.
Metadata
Release files for ap-games 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ap_games-0.0.2.tar.gz | 30.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ap_games-0.0.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 58.1 kB
Release files / ap_games-0.0.2.tar.gz
| Download URL | ap_games-0.0.2.tar.gz |
|---|---|
| Size | 30.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44eacf7cede72fda4a976dffef29a84faaf429e4dc9fdca2cc6184b9bb79efd2
|
|
BLAKE2b-256 checksum How to use checksums |
a404402bed4119850cad345280eede5ccde587ca2a7d28e5b826b6f8d4e72e88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
|
Release files / ap_games-0.0.2-py2.py3-none-any.whl
| Download URL | ap_games-0.0.2-py2.py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e14b29a3ecbbde4e54918333e035c79ca6493d6e29e40acd67b61931ff8178f9
|
|
BLAKE2b-256 checksum How to use checksums |
fadbfcefd004e5e4d3155efc7c32cf7179fb85a1842144d0db02099a7cd14d22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
|