Inteligentna_smieciarka/succ.py
Maksymilian Mikołajczak bdb0ed2d3c basic bfs implementation
2023-04-19 22:12:02 +02:00

31 lines
1.2 KiB
Python

from state import State
def succ(st: State):
successors = []
if st.orientation == 'N':
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'W'))
successors.append(State(st, 'RIGHT', st.xpos, st.ypos, 'E'))
if st.ypos > 0:
successors.append(State(st, 'FORWARD', st.xpos, st.ypos - 50, 'N'))
if st.orientation == 'S':
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'E'))
successors.append(State(st,'RIGHT', st.xpos, st.ypos, 'W'))
if st.ypos < 750:
successors.append(State(st, 'FORWARD', st.xpos, st.ypos + 50, 'S'))
if st.orientation == 'W':
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'S'))
successors.append(State(st,'RIGHT', st.xpos, st.ypos, 'N'))
if st.xpos > 0:
successors.append(State(st, 'FORWARD', st.xpos - 50, st.ypos, 'W'))
if st.orientation == 'E':
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'N'))
successors.append(State(st, 'RIGHT', st.xpos, st.ypos, 'S'))
if st.xpos < 750:
successors.append(State(st, 'FORWARD', st.xpos + 50, st.ypos, 'E'))
return successors