Open-source cross-platform reimagination of one of the oldest backgammon games for Windows, built with MonoGame and .NET 10.
- Standard backgammon rules — 24-point board, 15 pieces per player, bar and bearing-off areas
- Single-player vs AI — play against a computer-controlled opponent
- Animated piece movement — smooth sprite-based animation for every move
- Drag-and-drop interaction — click to pick up a piece, then click a valid destination to place it
- Legal-move highlighting — valid target columns are highlighted after selecting a piece
- Dice rolling — roll dice when no moves are available by clicking the centre dice area
- Undo — revert the last move at any time
- Reset — start a fresh game from the opening position
- Context-sensitive cursor — cursor changes to reflect the current interaction state (pointer, pick up, grab, open hand, dice)
You play as white (moving from high-numbered to low-numbered columns). The AI plays as brown (moving in the opposite direction).
Each turn:
- Dice are rolled automatically at the start of your turn.
- Click a white piece to select it. Legal destinations are highlighted.
- Click a highlighted column to move the piece there.
- Repeat until all dice values are used (or no moves remain).
- If you have no legal moves you can click the dice to pass.
Pieces sent to the bar must re-enter from the opponent's home board before any other moves are made. Once all 15 of your pieces have moved past column 0 you can begin bearing off.
The first player to bear off all 15 pieces wins.
The computer opponent uses a minimax search with a transposition table (memoisation) to evaluate full move sequences. The position evaluator accounts for:
- Pip count — distance remaining to bear off
- Point control — bonuses for owning anchors, home-board points, and outer points
- Primes — bonus for consecutive owned points (4-, 5-, and 6-primes)
- Blot threats — penalties for exposed single pieces within direct or combined dice reach of the opponent
- Bar pieces — penalties for pieces on the bar and bonuses for putting the opponent on the bar
All weights and thresholds are adjusted automatically based on the current game phase:
| Phase | Condition |
|---|---|
| Racing | AI leads by more than 15 pips |
| Blocking | Pip difference between −15 and +40 |
| Back game | AI trails by more than 40 pips |
Download the latest packaged build from the GitHub releases page.
- .NET 10 SDK
- MonoGame content build tools (
dotnet-mgcb) — required to rebuild game assets - TrueType core fonts — required for font rendering on Linux (
fonts-freefont-ttfor equivalent)
All NuGet dependencies (MonoGame, NuciXNA) are restored automatically by dotnet restore.
On Ubuntu the CI workflow installs the missing tools with:
dotnet tool install --global dotnet-mgcb
sudo apt-get install -y fonts-freefont-ttfdotnet builddotnet run --project BackgammonByHoratiudotnet testThe repository includes release.sh, which delegates to the upstream deployment script used by the project maintainer.
bash ./release.sh 1.0.0This script downloads and executes an external release helper from https://raw.githubusercontent.com/hmlendea/deployment-scripts/master/release/dotnet/10.0.sh.
Note: Piping into bash is an intensely controversial topic. Please review any external scripts before running them in your environment!
BackgammonByHoratiu/
├── Entities/ # Pure data models (Table, Player, Piece, GameSnapshot, Dice)
├── GameLogic/
│ ├── GameManagers/ # Rules engine (GameManager) and AI coordinator (AiGameManager)
│ └── AI/
│ ├── BackgammonAi.cs # Move planner and execution queue
│ ├── BoardLayout.cs # Board constants (columns, home-board ranges)
│ ├── Evaluation/ # Position scoring (PositionEvaluator, AiWeights, ThreatCalculator)
│ └── Search/ # Minimax search with transposition table (MoveSearcher)
├── Gui/
│ ├── Screens/ # SplashScreen and GameplayScreen
│ └── Controls/ # GuiGameBoard, GuiButton, FramerateCounter
├── Settings/ # Constants and configuration (GameDefines, GraphicsSettings, AudioSettings)
├── Program.cs # Entry point
└── GameWindow.cs # MonoGame window and screen-manager setup
BackgammonByHoratiu.UnitTests/
├── Entities/ # Unit tests for Table, Player, Piece
└── GameLogic/ # Unit tests for game managers, AI evaluator, and search
| Package | Purpose |
|---|---|
MonoGame.Framework.DesktopGL |
Cross-platform 2D rendering, input, and audio |
MonoGame.Content.Builder.Task |
Asset pipeline (fonts, textures, sprites) |
NuciXNA.Graphics |
Sprite and animation abstraction |
NuciXNA.Gui |
Screen and control framework |
NuciXNA.Input |
Keyboard and mouse input abstraction |
NuciXNA.Primitives |
Geometric types (Point2D, Size2D, …) |
NuciXNA.DataAccess |
Content loading utilities |
NuciDAL |
Data-access base library |
Contributions are welcome.
Please:
- keep changes cross-platform
- keep pull requests focused and consistent with existing style
- update documentation when behaviour changes
- add or update tests for new behaviour
Licensed under the GNU General Public License v3.0 or later. See LICENSE for details.

