Skip to main content

RoyalUr-Python Logo

This library provides a Python API for the play and analysis of games of The Royal Game of Ur!

What is The Royal Game of Ur?

The Royal Game of Ur is one of the longest-living games in history, with evidence of it being enjoyed by people who lived over 5,000 years ago! This library aims to bring this ancient board game into the modern age by supporting digital versions of the game, statistical analysis of its rules, and the use of AI to play the game. A board used to play The Royal Game of Ur is shown below, which was excavated by Sir Leonard Woolley in the 1930s. It is currently on display at the British Museum!

British Museum game board excavated by Sir Leonard Woolley

Photo of an excavated board of the Royal Game of Ur that is dated to 2500 BC.
© The Trustees of the British Museum.

Resources

🔧 Installation

The RoyalUr-Python package is available to be installed through pip:

pip install royalur

🚀 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.

from royalur import Game
import random

# Create a new game using the Finkel rules.
game = Game.create_finkel()

while not game.is_finished():
    turn_player_name = game.get_turn().text_name

    if game.is_waiting_for_roll():
        # Roll the dice!
        roll = game.roll_dice()
        print(f"{turn_player_name}: Roll {roll.value}")

    else:
        # Make a random move.
        moves = game.find_available_moves()
        move = moves[random.randint(0, len(moves) - 1)]
        game.make_move(move)
        print(f"{turn_player_name}: {move.describe()}")

# Report the winner!
print(f"{game.get_winner().text_name} 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!

📜 Supported Rulesets

This library supports a wide range of rulesets for the Royal Game of Ur. You may use standard sets of rules that are commonly played, or create your own custom rulesets.

Provided Rulesets:

  • Rules proposed by Irving Finkel (simple version).
  • Rules proposed by James Masters.
  • Rules for Aseb (using a different game board).

⚙️ Custom Rulesets

The rulesets are created by selecting several component pieces that make up the ruleset. This includes selecting the board shape, the path that pieces take around the board, the dice that are used, alongside other features such as whether rosette tiles are safe from capture. The provided values of these components are given below, but new values can also be created and used instead (e.g., for a new path around the board).

Board Shapes:

  • Standard Royal Game of Ur.
  • Aseb.

Supported Board Shapes

Paths:

  • Bell's path.
  • Masters' path.
  • Murray's path.
  • Skiriuk's path.
  • Aseb path proposed by Murray.

Supported Paths

Dice:

  • Four binary die.
  • Three binary die where a roll of zero is treated as a four.
  • N binary die.
  • N binary die where a roll of zero is treated as a roll of N+1.

Features:

  • Number of starting pieces for each player.
  • Whether rosettes are safe tiles.
  • Whether landing on a rosette grants an extra roll.
  • Whether capturing a piece grants an extra roll.

📝 License

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

Metadata

Release files for RoyalUr 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RoyalUr 0.0.6
File Size Uploaded
RoyalUr-0.0.6.tar.gz 23.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for RoyalUr 0.0.6
File Interpreter ABI Platform
RoyalUr-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 54.8 kB

Release files / RoyalUr-0.0.6.tar.gz

Download URL RoyalUr-0.0.6.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b85958da92895b19659409278c24201d9048c719d3ab03aa7850f9b7870d4333
BLAKE2b-256 checksum
How to use checksums
510a69b9cdea3931a59a6616ab440546e65d6144d24bc3103bccf5b5093da0c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / RoyalUr-0.0.6-py3-none-any.whl

Download URL RoyalUr-0.0.6-py3-none-any.whl
Size 31.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b0d7b480b008ab8c25dab426eeb2fb1a20dc5ef2efcbc010f97942ea0b7db51
BLAKE2b-256 checksum
How to use checksums
cd3db8eae03392fa7f3abbde3f9f48dcf4a06f9bc0208ca5afa60ec015f84115
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page