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':
2023-04-19 22:12:02 +02:00
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'W'))
successors.append(State(st, 'RIGHT', st.xpos, st.ypos, 'E'))
2023-04-19 21:40:40 +02:00
if st.ypos > 0:
2023-04-19 22:12:02 +02:00
successors.append(State(st, 'FORWARD', st.xpos, st.ypos - 50, 'N'))
2023-04-19 21:40:40 +02:00
if st.orientation == 'S':
2023-04-19 22:12:02 +02:00
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'E'))
successors.append(State(st,'RIGHT', st.xpos, st.ypos, 'W'))
2023-04-19 21:40:40 +02:00
if st.ypos < 750:
2023-04-19 22:12:02 +02:00
successors.append(State(st, 'FORWARD', st.xpos, st.ypos + 50, 'S'))
2023-04-19 21:40:40 +02:00
if st.orientation == 'W':
2023-04-19 22:12:02 +02:00
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'S'))
successors.append(State(st,'RIGHT', st.xpos, st.ypos, 'N'))
2023-04-19 21:40:40 +02:00
if st.xpos > 0:
2023-04-19 22:12:02 +02:00
successors.append(State(st, 'FORWARD', st.xpos - 50, st.ypos, 'W'))
2023-04-19 21:40:40 +02:00
if st.orientation == 'E':
2023-04-19 22:12:02 +02:00
successors.append(State(st, 'LEFT', st.xpos, st.ypos, 'N'))
successors.append(State(st, 'RIGHT', st.xpos, st.ypos, 'S'))
2023-04-19 21:40:40 +02:00
if st.xpos < 750:
2023-04-19 22:12:02 +02:00
successors.append(State(st, 'FORWARD', st.xpos + 50, st.ypos, 'E'))
return successors