A terminal-based implementation of the classic board game Backgammon, written in pure C. This project was created as my first major programming assignment (2023). It demonstrates fundamental concepts of low-level programming, including pointer arithmetic, memory management, and procedural logic implementation without the aid of Object-Oriented paradigms.
- Player vs Computer AI: Play against a basic algorithmic opponent that evaluates moves based on game state.
- Rules Implementation: Full validation of Backgammon moves, including hitting logic, bar re-entry, and bearing off.
- Save/Load System: Ability to serialize the game state to a file and resume gameplay later.
- Visuals: Text-based user interface (TUI) utilizing the
ncurseslibrary for rendering the board in the terminal.
Follow these instructions to get a copy of the project up and running on your local machine.
To run this project, you need a C compiler and the Ncurses library.
- Linux (Debian/Ubuntu):
sudo apt-get install libncurses5-dev libncursesw5-dev
- macOS:
brew install ncurses
- Windows: Recommended to run via WSL (Windows Subsystem for Linux) or using a compatability layer like PDcurses with MinGW.
- Clone the repository:
git clone [https://github.com/your-username/console-backgammon.git](https://github.com/your-username/console-backgammon.git) cd console-backgammon - Compile the code:
gcc main.c -o backgammon -lncurses
- Run the game:
./backgammon
Once the game is running, you can use the following keys to interact with the menu and gameplay:
| Key | Action | Description |
|---|---|---|
| M | Move | Roll the dice and start your turn. |
| N | New Game | Reset the board and start a new match. |
| S | Save | Save current game state to save_file.txt. |
| L | Load | Load game state from save_file.txt. |
| Q | Quit | Exit the application. |
Gameplay Input:
When asked for a move, type the column number (e.g., 06 or 24) to select the pawn, and then the destination column.
Lukasz Swiecicki
- Year 2023
- Project created as part of University coursework.
- Focus: C Programming, Algorithms, Data Structures.