+ @classmethod
+ 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,
+ 'wins_required': wins_required,
+ 'wins': 0,
+ 'locations': locations_definition,
+ }
+ player = Player(initial_bits, initial_pos)
+ board_locations = cls.import_board_locations(
+ cls.generate_board(locations_definition))
+ return cls(state, player, board_locations)
+
+ @classmethod
+ def import_game(cls, definition):
+ state = definition.copy()
+ player = Player.import_player(state.pop('player'))
+ board_locations = cls.import_board_locations(
+ state.pop('board_locations'))
+ return cls(state, player, board_locations)