random_world(size,
wall_density=0.2,
num_init=1,
num_goals=2,
prefix=' Y ' ,
ensure_feasible=False,
timeout=None,
num_trolls=0)
|
|
Generate random gridworld of given size.
While an instance of GridWorld is returned, other views of the result
are possible; e.g., to obtain a description string, use GridWorld.dumps.
- Parameters:
size - a pair, indicating number of rows and columns.
wall_density - the ratio of walls to total number of cells.
num_init - number of possible initial positions.
num_goals - number of positions to be visited infinitely often.
prefix - string to be used as prefix for naming gridworld cell variables.
num_trolls - number of random trolls to generate, each occupies an area of
radius 1. If nonzero, then a list specifying the trolls will
also be returned.
ensure_feasible - guarantee that all goals and initial positions are mutually
reachable, assuming a 4-connected grid. This method may not be
complete, i.e., may fail to return a feasible random gridworld
with the given parameters. Note that "feasibility"
does not account for nondeterminism (in particular, nonzero
num_trolls argument has no effect.)
timeout - if ensure_feasible, then quit if no correct random world is found
before timeout seconds. If timeout is None (default), then do
not impose time constraints.
- Returns: GridWorld, or None if timeout occurs.
|