AI Opponents
DoubleCube.gg provides multiple AI opponents for single-player games.
Available Bots
Random AI
Makes completely random valid moves. Useful as a baseline.
- Difficulty: Beginner
- Estimated ELO: ~800
Greedy AI
Prioritizes:
- Bearing off checkers
- Hitting opponent blots
- Moving to safe positions
- Difficulty: Intermediate
- Estimated ELO: ~1100
Heuristic AI
Uses position evaluation heuristics:
-
Pip count optimization
-
Home board building
-
Anchor strategy
-
Blot minimization
-
Difficulty: Advanced
-
Estimated ELO: ~1300
GNU Backgammon AI
Uses GNU Backgammon's neural network for expert-level play.
- Difficulty: Expert
- Estimated ELO: ~1800+
- Requires: GNU Backgammon installation
Playing Against AI
Create AI Match
const config = {
targetScore: 5,
opponentType: 'ai',
botId: 'greedy' // 'random', 'greedy', 'heuristic', 'gnubg'
};
await connection.invoke('CreateMatch', config);
Get Available Bots
const bots = await connection.invoke('GetAvailableBots');
bots.forEach(bot => {
console.log(`${bot.botId}: ${bot.displayName}`);
console.log(` ELO: ~${bot.estimatedElo}`);
console.log(` ${bot.description}`);
});
AI Architecture
IBackgammonAI Interface
public interface IBackgammonAI
{
string Name { get; }
void ChooseMoves(GameEngine engine);
}
Implementation Example
public class MyCustomAI : IBackgammonAI
{
public string Name => "Custom AI";
public void ChooseMoves(GameEngine engine)
{
while (engine.RemainingMoves.Count > 0)
{
var validMoves = engine.GetValidMoves();
if (validMoves.Count == 0) break;
var bestMove = EvaluateMoves(validMoves, engine);
engine.ExecuteMove(bestMove);
}
}
private Move EvaluateMoves(List<Move> moves, GameEngine engine)
{
// Custom evaluation logic
}
}
Bot Registration
Bots are registered via the plugin system:
// In Startup
builder.Services.AddStandardBots(); // Random, Greedy
builder.Services.AddHeuristicBot(); // Heuristic evaluator
builder.Services.AddAnalysisPlugins(); // GNU Backgammon (if available)
AI Move Service
The server handles AI moves asynchronously:
public interface IAiMoveService
{
Task ExecuteAiTurnAsync(GameSession session);
}
When playing against AI:
- Human makes move, ends turn
- Server triggers
AiMoveService.ExecuteAiTurnAsync() - AI evaluates position, makes moves
GameUpdatebroadcast to human player
Creating Custom Bots
- Implement
IBackgammonAI - Register with the bot resolver
- Add metadata for display
public class BotMetadata
{
public string BotId { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public int EstimatedElo { get; set; }
public bool RequiresExternalResources { get; set; }
}
Simulation Mode
Run AI vs AI simulations:
cd Backgammon.AI
dotnet run
Select matchups and number of games to analyze AI performance.