game module

Generate random match configurations.

Each Area of a Grid is assigned to a random player seat and gets a random supply of about three dice. The seat order (i.e. the sequence of the player’s turns) is randomly shuffled.

All area and seat data are exposed as tuples. Area and seat references are indices into these tuples.

Game instances are immutable and intended to generate runnable Match instances.

class dicewars.game.Game(grid=None, num_seats=7)

Generate a game (assign seat/dice to areas, shuffle seats and calculate seat states).

Parameters
  • grid (Grid or None) – Grid instance that provides the areas to use (if None: a Grid with default parameters is generated)

  • num_seats (int) – number of player seats

Raises
  • TypeError – if grid is not a Grid instance or num_seats is not int

  • ValueError – if num_seats is out of range

DEFAULT_NUM_SEATS = 7

Default for the num_seats parameter. (int)

AREA_MAX_NUM_DICE = 8

Maximal number of dice per area. (int)

property grid

The Grid instance used for the game.

property num_seats

The number of player seats. (int)

property seat_order

The player indices in the order the players will do their turns. (tuple(int))

property area_seats

The seat indices assigned to each area. (tuple(int))

property area_num_dice

The number of dice supplied to each area. (tuple(int))

property seat_areas

The area indices assigned to each seat. (tuple(tuple(int)))

property seat_num_areas

The total number of areas assigned to each seat. (tuple(int))

property seat_max_size

The maximal number of adjacent areas assigned to each seat. (tuple(int))

property seat_num_dice

The total number of dice supplied to each seat’s areas. (tuple(int))