DIRECTION_BITS = AttrDict((k, v) for k, v in BITS.items() if v < 4)
CONDITION_BITS = AttrDict((k, v) for k, v in BITS.items() if v >= 4)
+# Player defaults
+PLAYER_DEFAULTS = AttrDict({
+ 'INITIAL_BITS': BITS.NORTH | BITS.SOUTH | BITS.EAST | BITS.WEST,
+ 'INITIAL_POS': (2, 2),
+ 'MAX_HEALTH': 4,
+ 'WINS_REQUIRED': 4,
+})
+
# Game size constants
TILE_SIZE = (96, 96)
BOARD_SIZE = (5 * TILE_SIZE[0], 5 * TILE_SIZE[1])
from random import choice
-from naja.constants import BITS, DIRECTION_BITS, CONDITION_BITS
+from naja.constants import(
+ BITS, DIRECTION_BITS, CONDITION_BITS, PLAYER_DEFAULTS)
from naja.player import Player
from naja import actions
self.board_locations = board_locations
@classmethod
- def new_game(cls, initial_bits, initial_pos, max_health, wins_required,
- locations_definition):
+ def new_game(cls, locations_definition,
+ initial_bits=PLAYER_DEFAULTS.INITIAL_BITS,
+ initial_pos=PLAYER_DEFAULTS.INITIAL_POS,
+ max_health=PLAYER_DEFAULTS.MAX_HEALTH,
+ wins_required=PLAYER_DEFAULTS.WINS_REQUIRED):
state = {
'max_health': max_health,
'health': max_health,
The current game state.
"""
-from naja.constants import BITS
from naja.gameboard import GameBoard
Naja game state.
"""
- INITIAL_BITS = (
- BITS.NORTH | BITS.SOUTH |
- BITS.EAST | BITS.WEST
- )
- MAX_HEALTH = 4
- WINS_REQUIRED = 4
-
def __init__(self):
self.gameboard = GameBoard.new_game(
- initial_bits=self.INITIAL_BITS,
- initial_pos=(2, 2),
- max_health=self.MAX_HEALTH,
- wins_required=self.WINS_REQUIRED,
locations_definition=[]) # TODO: we will need some of these :)
@property