For our project, we created a simple Backgammon using the Python library 'pygame' for the visuals of the game. The rules of backgammon are simple, the goal of the game is for each player to remove all their pieces off the board. Each player has 15 pieces placed in specific positions, the player then roles two six-sided dice and moves their pieces accordingly. Once the player's pieces all reach the end of the board, they can start removing their pieces, the first person to remove all their pieces, wins.
We implemented many algorithms and data structures in our Backgammon game to make it functional, those include:
- Stacks (our main data structure): Used in order to push and pop pieces into and from their position based on the number on the rolled dice
- Searching Algorithms: To find the nearest point to a piece after calculating the distance needed to move it based on the rolled dice
- Depth First Search (Data Structure): Used by the bot algorithm, which always it to look for possible moves and make decisions by visiting multiple positions on the board, then backtracking, to determine which is more favorable to allow it to win the game
- Dictionaries (Data Structure)
The main programming language used was Python, and the following Python elements were used:
- Pygame Library
- Classes
- Conditional statements
- Loops
To install all dependencies, and to make sure pygame is installed, run the following command in your terminal
pip install -r requirements.txt
To run the game, enter the following in the terminal
python main.py
If any errors occur while running the previous command, run the following in terminal:
python3 main.py