Obstruction is a 2D game written in Python, in which players take turns in marking squares on a grid. The first player unable to move loses. The game is played between the user and the computer. The AI is implemented using the minimax algorithm.
- Clone the repo:
$ git clone https://github.com/EmanuelPutura/Obstruction
- Install project dependencies:
$ pip install jproperties $ pip install texttable
- From the project's location:
$ cd ./src $ python main.py
The users can change the game settings before launching the game (e.g., the user can choose between a console-based UI or a graphical UI, the AI strategy, the user's and the computer's board symbols). This can be done by modifying the settings.properties file (located in the src folder of the project). The default game settings are:
ui = gui
strategy = minimax
human_symbol = X
computer_symbol = OFor the UI, the options are gui and console. The strategy can be beginner, random or minimax and the human/computer symbol can be X or O. Also note that for the second player symbol the letter 'O' is used instead of '0', because of displaying considerations.
- Console User Interface
- Graphical User Interface, built with the Tkinter framework
- AI - implemented using the MiniMax Algorithm
- UnitTesting (testing most of the basic functionalities)
- Layered Arhitecture
- Code commentaries for almost all the functions and classes
- Multiple available strategies to be used by the computer player
The AI analyses every possible move from the current board state by using a minimax evaluation function and it tries to maximize the score of the move if it's the computer's turn, or minimize it if it's the user's turn (the AI thinks 2 moves in advance, more than that would seriously affect the time performance). Hence, it decides which move is the most profitable, taking into consideration the current game state.
