A command-line implementation of the ancient Nordic board game Tafl (also known as Hnefatafl) written in C++.
TaflSole is a two-player, text-based version of the strategic board game Tafl. Players take alternating turns moving pieces on a board, with one player controlling the defenders (including a king piece) and the other controlling the attackers. The game features a comprehensive move system, board visualization, and game state management.
When you start the program, you will be presented with two options:
newgame- Start a new game of Taflquit- Exit the program
After selecting newgame, the game board will be displayed, and the attacker always makes the first move. The game continues until either the king escapes or is captured.
The following commands are available during gameplay:
move <from_coordinates> <to_coordinates>- Move a piece from one position to another- Example:
move a1 a3
- Example:
back- Undo the previous moveinfo- Display the current game status, including captured pieces for each playerhelp- Show all available commands and their usage
The project is organized into several modules, each handling specific aspects of the game:
TaflSole.cpp- Contains the main entry point
- Calls the
run()function from the game module
-
board.h/cpp- Manages board-specific functionality
- Handles board state and piece placement
-
history.h/cpp- Implements move history tracking
- Provides functionality for undoing moves
-
logic.h/cpp- Contains core game logic
- Manages rules and victory conditions
-
game.h/cpp- Handles user interface and input processing
- Manages game flow and main game loop
-
positionChecks.h/cpp- Contains three commonly reused position checking functions
- Centralizes specific validation methods used across other modules
-
constants.h- Defines game constants
- Contains frequently used values across modules
- Language: C++
- Interface: Command-line
- Input: Text commands
- Output: ASCII board representation
- Data Structures: Uses structs without constructors for object representation
This project was developed as a first-year, first-semester university project, demonstrating fundamental programming concepts including:
- File organization and modular design
- Command parsing and user input handling
- Game state management
- Turn-based gameplay implementation
- Data structure usage with structs
Lubomir Topalski, Sofia University "St. Kliment Ohridski", Faculty of Mathematics and Informatics, Winter semester 2024-2025