Inteligentna_smieciarka/succ.py

31 lines
1.2 KiB
Python
Raw Normal View History

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