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