Search
After this lab session, a student
kuimaze2
03-search
kuimaze2.SearchProblem
SearchProblem
maps/easy_intro/easy_intro_1.png
>>> from kuimaze2 import SearchProblem >>> from kuimaze2.map_image import map_from_image >>> map_path = 'maps/easy_intro/easy_intro_1.png' >>> env = SearchProblem(map_from_image(map_path), graphics=True)
render()
>>> env.render()
>>> start = env.get_start() >>> start State(r=0, c=1) >>> env.get_goals() # Notice the different return type, this returns a list of possible goals [State(r=2, c=4)] >>> actions = env.get_actions(start) >>> actions [<Action.UP: 0>, <Action.RIGHT: 1>, <Action.DOWN: 2>, <Action.LEFT: 3>] >>> new_state = env.get_transition_result(start, actions[1]) >>> new_state (State(r=0, c=2), 1) >>> texts = {State(0,0): "S", State(0,1): "1"} >>> env.render(texts = texts) >>> env.render(texts = texts, current_state=State(0,0), next_states=[State(1,0)])
env.render()
example_search.py
Agent.find_path()
01-easy-search
agent.py
01-easy_search
lab01quiz