(self)
Sets the game state as the init_game_state.
Sets the game state as the init_game_state.
Sets the game state as the init_game_state .
def set_json_info(self):
        """Sets the game state as the init_game_state."""
        board_size = int(self._init_game_state['board_size'])
        self._board_size = board_size
        self._step_count = int(self._init_game_state['step_count'])

        board_array = json.loads(self._init_game_state['board'])
        self._board = np.ones((board_size, board_size)).astype(np.uint8)
        self._board *= constants.Item.Passage.value
        for x in range(self._board_size):
            for y in range(self._board_size):
                self._board[x, y] = board_array[x][y]

        self._items = {}
        item_array = json.loads(self._init_game_state['items'])
        for i in item_array:
            self._items[tuple(i[0])] = i[1]

        agent_array = json.loads(self._init_game_state['agents'])
        for a in agent_array:
            agent = next(x for x in self._agents \
                         if x.agent_id == a['agent_id'])
            agent.set_start_position((a['position'][0], a['position'][1]))
            agent.reset(
                int(a['ammo']), bool(a['is_alive']), int(a['blast_strength']),
                bool(a['can_kick']))

        self._bombs = []
        bomb_array = json.loads(self._init_game_state['bombs'])
        for b in bomb_array:
            bomber = next(x for x in self._agents \
                          if x.agent_id == b['bomber_id'])
            moving_direction = b['moving_direction']
            if moving_direction is not None:
                moving_direction = constants.Action(moving_direction)
            self._bombs.append(
                characters.Bomb(bomber, tuple(b['position']), int(b['life']),
                                int(b['blast_strength']), moving_direction))

        self._flames = []
        flame_array = json.loads(self._init_game_state['flames'])
        for f in flame_array:
            self._flames.append(
                characters.Flame(tuple(f['position']), f['life']))
def set_json_info ( self ) : board_size = int ( self . _init_game_state [ 'board_size' ] ) self . _board_size = board_size self . _step_count = int ( self . _init_game_state [ 'step_count' ] ) board_array = json . loads ( self . _init_game_state [ 'board' ] ) self . _board = np . ones ( ( board_size , board_size ) ) . astype ( np . uint8 ) self . _board *= constants . Item . Passage . value for x in range ( self . _board_size ) : for y in range ( self . _board_size ) : self . _board [ x , y ] = board_array [ x ] [ y ] self . _items = { } item_array = json . loads ( self . _init_game_state [ 'items' ] ) for i in item_array : self . _items [ tuple ( i [ 0 ] ) ] = i [ 1 ] agent_array = json . loads ( self . _init_game_state [ 'agents' ] ) for a in agent_array : agent = next ( x for x in self . _agents if x . agent_id == a [ 'agent_id' ] ) agent . set_start_position ( ( a [ 'position' ] [ 0 ] , a [ 'position' ] [ 1 ] ) ) agent . reset ( int ( a [ 'ammo' ] ) , bool ( a [ 'is_alive' ] ) , int ( a [ 'blast_strength' ] ) , bool ( a [ 'can_kick' ] ) ) self . _bombs = [ ] bomb_array = json . loads ( self . _init_game_state [ 'bombs' ] ) for b in bomb_array : bomber = next ( x for x in self . _agents if x . agent_id == b [ 'bomber_id' ] ) moving_direction = b [ 'moving_direction' ] if moving_direction is not None : moving_direction = constants . Action ( moving_direction ) self . _bombs . append ( characters . Bomb ( bomber , tuple ( b [ 'position' ] ) , int ( b [ 'life' ] ) , int ( b [ 'blast_strength' ] ) , moving_direction ) ) self . _flames = [ ] flame_array = json . loads ( self . _init_game_state [ 'flames' ] ) for f in flame_array : self . _flames . append ( characters . Flame ( tuple ( f [ 'position' ] ) , f [ 'life' ] ) )