Skip to main content

Azul game engine

A game engine for Azul board game.

Original game: https://en.wikipedia.org/wiki/Azul_(board_game).

PyPI version

Functionality

As a client of this game engine the only class you need to use is game.py.

Initializing game.py

lid = Lid()
player1 = Player(Board(wall=Wall(), floor=Floor(lid)), f"Player Name 1")
player2 = Player(Board(wall=Wall(), floor=Floor(lid)), f"Player Name 2")
game = Game([player1, player2])

Using game.py

game.py class has 3 main methods for clients to use:

  • json_object
  • execute_factory_offer_phase_with_factory
  • execute_factory_offer_phase_with_center

json_object()

Returns a dictionary representation of the current game state, suitable for JSON serialization.

Returns:

  • dict: A dictionary containing:
    • isRunning: Boolean indicating if the game is still active
    • Factory displays: List of factory display states
    • Center: Current center tile state
    • Players: List of all player states (including pattern lines, wall, floor)
    • Bag: Current bag tile counts
    • Lid: Current lid tile counts
    • Winners: List of winner names (only present when game has ended)

Example:

state = game.json_object()

execute_factory_offer_phase_with_factory(factory_index, tile_to_take, amount_to_place_on_floor, pattern_line_index)

Executes the current player's turn by taking tiles from a specified factory display.

Parameters:

  • factory_index (int): Index of the factory display to take tiles from. Starting index 0. Ending index: 4 on two player game, 6 on 3 player game, 8 on 4 player game.
  • tile_to_take (Tile): The specific tile color to take from the factory
  • amount_to_place_on_floor (int): Number of tiles to place on the floor
  • pattern_line_index (int): Index of the pattern line to place tiles on (0-4)

Behavior:

  • Takes all tiles of the specified color from the chosen factory display
  • Places remaining tiles from that factory into the center
  • Places tiles on the specified pattern line (and floor on some cases)
  • Advances to the next player's turn
  • Triggers wall tiling phase if all factories and center are empty

Raises:

  • ActionNotAllowedException: If the game has already ended or move is illegal (e.g. user wants to take a Blue tile from a factory but the factory does not have blue tiles).

Example:

# Player takes red tiles from factory 0, places 2 on floor, rest on pattern line 1
game.execute_factory_offer_phase_with_factory(0, Tile.RED, 2, 1)

execute_factory_offer_phase_with_center(tile_to_take, amount_to_place_on_floor, pattern_line_index)

Executes a player's turn by taking tiles from the center area.

Parameters:

  • tile_to_take (Tile): The specific tile color to take from the center
  • amount_to_place_on_floor (int): Number of tiles to place on the floor
  • pattern_line_index (int): Index of the pattern line to place tiles on (0-4)

Behavior:

  • Takes all tiles of the specified color from the center
  • First player to take from center receives the starting player marker (-1 point penalty)
  • Places tiles on the specified pattern line (and floor on some cases)
  • Advances to the next player's turn
  • Triggers wall tiling phase if all factories and center are empty

Raises:

  • ActionNotAllowedException: If the game has already ended or move is illegal (e.g. user wants to take a Blue tile from the center but there is no blue tile in it).

Example:

# Player takes blue tiles from center, places 1 on floor, rest on pattern line 0
game.execute_factory_offer_phase_with_center(Tile.BLUE, 1, 0)

Installing the project

Inside the directory this file is located run pip install .

Running tests

After you have installed the project, run this command pytest -vv in the same directory as this file.

codecov

License

Please read a LICENSE file.

Metadata

Release files for azul-game-engine 1.0.2

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

Source distribution (sdist)

Source distribution for azul-game-engine 1.0.2
File Size Uploaded Provenance
azul_game_engine-1.0.2.tar.gz 21.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for azul-game-engine 1.0.2
File Interpreter ABI Platform
azul_game_engine-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 44.1 kB

Release files / azul_game_engine-1.0.2.tar.gz

Download URL azul_game_engine-1.0.2.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1aacb622fcfed8f8df6f1c328810c9d95986655c992248987ad684450b57c1ad
BLAKE2b-256 checksum
How to use checksums
9b930aaf4d713725aedc47c0437556ae7986cfa8a9c7f7112b9abc8a12e7500a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / azul_game_engine-1.0.2-py3-none-any.whl

Download URL azul_game_engine-1.0.2-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee72234750e61a2fb36bee9b25ccc36d0a0ee706ad936e28393d7983e8085f53
BLAKE2b-256 checksum
How to use checksums
0008d2cbcf4bacc5be18b6ce1c34c64edb692fe42d57e9647c146157e0f7dc2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for azul-game-engine 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

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