mlpy.environments.gridworld.GridWorld¶
-
class
mlpy.environments.gridworld.GridWorld(width=20, height=20, agents=None, filename=None)[source]¶ Bases:
mlpy.environments.EnvironmentA gridworld consisting of a 2d-grid.
A gridworld’s basic unit is a cell. Each cell has four neighbors corresponding to the actions the agent can take in the four compass directions (N, S, E, W).
Parameters: width : int
The number of cells in the x-direction.
height : int
The number of cells in the y-direction.
agents : Agent or list[Agent]
A list of agents that act in the gridworld.
filename : str
The name of the file containing the configuration of the gridworld.
Notes
Within the gridworld, the agent’s location is denoted by o.
Attributes
heightThe number of cells in the y-direction. midThe module’s unique identifier. widthThe number of cells in the x-direction. Methods
add_agents(agent)Add an agent to the environment. enter(t)Enter the environment and all agents. exit()Exit the environment and all agents. find_cells(data)Find the cells containing given data. get_agent(mid)Return the agent specified by the id. get_cell(loc)Return the cell based on its x/y-coordinates. is_complete()Checks if the environment has completed. load(f)Loads the world from file. make_cell(x, y)Create the new cell. move_coords(cell, move)Returns the coordinates of the neighboring cell the agent transitions to following the given move. random_location()Find a random unoccupied location within the grid. reset(t, **kwargs)Reset the agent’s state. save([f])Save the world to file. set_start_loc(loc)Set the agent’s starting location. update(dt)Update the agents.