RoyalUr.net Developer Documentation

RoyalUr-Java

This project provides a Java API for the play and analysis of games of the Royal Game of Ur. This API is designed to support many rule sets of the Royal Game of Ur. More documentation will be added here as this API is developed.

🚀 Example

The following is a small example that shows the basics of creating a game, autonomously playing through it by making random moves, and reporting what happens in the game as it progresses.

// Create a new game using the Finkel rules.
Game game = Game.createFinkel();

// Play through a game making random moves.
Random rand = new Random();

while (!game.isFinished()) {
    String turnPlayerName = game.getTurn().getTextName();

    if (game.isWaitingForRoll()) {
        // Roll the dice!
        Roll roll = game.rollDice();
        System.out.println(turnPlayerName + ": Roll " + roll.value());
    } else {
        // Make a random move.
        List<Move> moves = game.findAvailableMoves();
        Move randomMove = moves.get(rand.nextInt(moves.size()));
        game.makeMove(randomMove);
        System.out.println(turnPlayerName + ": " + randomMove.describe());
    }
}

// Report the winner!
System.out.println("\n" + game.getWinner().getTextName() + " won the game!");

Here is a snippet from the end of the output from running the example above:

Dark: Score a piece from C7
Light: Roll 2
Light: Score a piece from A8
Dark: Roll 1
Dark: Move C4 to C3
Light: Roll 1
Light: Score a piece from A7

Light won the game!

🔧 Installation

Currently, the RoyalUr-Java library is only available through building the source code using Maven. We plan to release the library into the central library as well, but we have had issues with that process that we still need to work out. You can manually install from the source code by running maven install in the root directory of the source code.

đź“ś Supported Rule Sets

This library supports a wide range of rule sets for the Royal Game of Ur, although we are looking to add more.

Rule Sets:

Custom Rule Sets

The rule sets are created by selecting several components that make up the rules. This includes selecting the board shape, the path that pieces take around the board, the dice that are used, and other features of the rules. The provided components are given below, but new components can also be created and used instead.

Board Shapes:

Supported Board Shapes

Paths:

Supported Paths

Dice:

Features:

đź“ť License

This library is licensed under the MIT license. Read the license here.