(self, curr_board, agents, bombs, flames,
                         is_partially_observable, agent_view_size,
                         game_type, game_env)
return observations
Gets the observations as an np.array of the visible squares.

        The agent gets to choose whether it wants to keep the fogged part in
        memory.
Gets the observations as an np.array of the visible squares.
Gets the observations as an np . array of the visible squares .
def get_observations(self, curr_board, agents, bombs, flames,
                         is_partially_observable, agent_view_size,
                         game_type, game_env):
        """Gets the observations as an np.array of the visible squares.

        The agent gets to choose whether it wants to keep the fogged part in
        memory.
        """
        board_size = len(curr_board)

        def make_bomb_maps(position):
            ''' Makes an array of an agents bombs and the bombs attributes '''
            blast_strengths = np.zeros((board_size, board_size))
            life = np.zeros((board_size, board_size))
            moving_direction = np.zeros((board_size, board_size))

            for bomb in bombs:
                x, y = bomb.position
                if not is_partially_observable \
                   or in_view_range(position, x, y):
                    blast_strengths[(x, y)] = bomb.blast_strength
                    life[(x, y)] = bomb.life
                    if bomb.moving_direction is not None:
                        moving_direction[(x, y)] = bomb.moving_direction.value
            return blast_strengths, life, moving_direction

        def make_flame_map(position):
            ''' Makes an array of an agents flame life'''
            life = np.zeros((board_size, board_size))

            for flame in flames:
                x, y = flame.position
                if not is_partially_observable \
                   or in_view_range(position, x, y):
                    # +1 needed because flame removal check is done
                    # before flame is ticked down, i.e. flame life
                    # in environment is 2 -> 1 -> 0 -> dead
                    life[(x, y)] = flame.life + 1
            return life

        def in_view_range(position, v_row, v_col):
            '''Checks to see if a tile is in an agents viewing area'''
            row, col = position
            return all([
                row >= v_row - agent_view_size, row <= v_row + agent_view_size,
                col >= v_col - agent_view_size, col <= v_col + agent_view_size
            ])

        attrs = [
            'position', 'blast_strength', 'can_kick', 'teammate', 'ammo',
            'enemies'
        ]
        alive_agents = [
            utility.agent_value(agent.agent_id)
            for agent in agents
            if agent.is_alive
        ]

        observations = []
        for agent in agents:
            agent_obs = {'alive': alive_agents}
            board = curr_board.copy()
            if is_partially_observable:
                for row in range(board_size):
                    for col in range(board_size):
                        if not in_view_range(agent.position, row, col):
                            board[row, col] = constants.Item.Fog.value
            agent_obs['board'] = board
            bomb_blast_strengths, bomb_life, bomb_moving_direction = make_bomb_maps(agent.position)
            agent_obs['bomb_blast_strength'] = bomb_blast_strengths
            agent_obs['bomb_life'] = bomb_life
            agent_obs['bomb_moving_direction'] = bomb_moving_direction
            flame_life = make_flame_map(agent.position)
            agent_obs['flame_life'] = flame_life
            agent_obs['game_type'] = game_type.value
            agent_obs['game_env'] = game_env

            for attr in attrs:
                assert hasattr(agent, attr)
                agent_obs[attr] = getattr(agent, attr)
            observations.append(agent_obs)

        return observations
def get_observations ( self , curr_board , agents , bombs , flames , is_partially_observable , agent_view_size , game_type , game_env ) : board_size = len ( curr_board ) def make_bomb_maps ( position ) : ''' Makes an array of an agents bombs and the bombs attributes ''' blast_strengths = np . zeros ( ( board_size , board_size ) ) life = np . zeros ( ( board_size , board_size ) ) moving_direction = np . zeros ( ( board_size , board_size ) ) for bomb in bombs : x , y = bomb . position if not is_partially_observable or in_view_range ( position , x , y ) : blast_strengths [ ( x , y ) ] = bomb . blast_strength life [ ( x , y ) ] = bomb . life if bomb . moving_direction is not None : moving_direction [ ( x , y ) ] = bomb . moving_direction . value return blast_strengths , life , moving_direction def make_flame_map ( position ) : ''' Makes an array of an agents flame life''' life = np . zeros ( ( board_size , board_size ) ) for flame in flames : x , y = flame . position if not is_partially_observable or in_view_range ( position , x , y ) : # +1 needed because flame removal check is done # before flame is ticked down, i.e. flame life # in environment is 2 -> 1 -> 0 -> dead life [ ( x , y ) ] = flame . life + 1 return life def in_view_range ( position , v_row , v_col ) : '''Checks to see if a tile is in an agents viewing area''' row , col = position return all ( [ row >= v_row - agent_view_size , row <= v_row + agent_view_size , col >= v_col - agent_view_size , col <= v_col + agent_view_size ] ) attrs = [ 'position' , 'blast_strength' , 'can_kick' , 'teammate' , 'ammo' , 'enemies' ] alive_agents = [ utility . agent_value ( agent . agent_id ) for agent in agents if agent . is_alive ] observations = [ ] for agent in agents : agent_obs = { 'alive' : alive_agents } board = curr_board . copy ( ) if is_partially_observable : for row in range ( board_size ) : for col in range ( board_size ) : if not in_view_range ( agent . position , row , col ) : board [ row , col ] = constants . Item . Fog . value agent_obs [ 'board' ] = board bomb_blast_strengths , bomb_life , bomb_moving_direction = make_bomb_maps ( agent . position ) agent_obs [ 'bomb_blast_strength' ] = bomb_blast_strengths agent_obs [ 'bomb_life' ] = bomb_life agent_obs [ 'bomb_moving_direction' ] = bomb_moving_direction flame_life = make_flame_map ( agent . position ) agent_obs [ 'flame_life' ] = flame_life agent_obs [ 'game_type' ] = game_type . value agent_obs [ 'game_env' ] = game_env for attr in attrs : assert hasattr ( agent , attr ) agent_obs [ attr ] = getattr ( agent , attr ) observations . append ( agent_obs ) return observations