Search
Class Map represents the actual maze (well, its map). It is a required input parameter of all problem environments (SearchProblem, MDPProblem, RLProblem).
Map
With the exception of creation, you will never need to work with the map directly. It provides the problem environments with information about the dimensions of the map, which positions (States) are free, what the start state is, where the goal states are, where the danger states are, whether a transition from one state to another is possible, etc.
State
A map can be represented/specified in many ways. In kuimaze2 we use two:
kuimaze2
The meaning of individual characters/colors:
.
#
S
G
D
A map can be created from a multiline string using Map.from_string() class method:
Map.from_string()
>>> from kuimaze2 import Map >>> MAP = """ S#.G .D.D .... """ >>> m = Map.from_string(MAP) >>> m.width 4 >>> m.height 3 >>> m.start State(r=0, c=0) >>> m.goals {State(r=0, c=3)} >>> m.dangers {State(r=1, c=1), State(r=1, c=3)}
To create a map from a bitmap picture, do the following:
from kuimaze2.map_image import map_from_image map = map_from_image("../maps/normal/normal2.png")