29 lines
969 B
Python
29 lines
969 B
Python
|
def succ(xpos, ypos, orientation):
|
||
|
successors = []
|
||
|
|
||
|
if orientation == 'N':
|
||
|
successors.append(['LEFT', xpos, ypos, 'W'])
|
||
|
successors.append(['RIGHT', xpos, ypos, 'E'])
|
||
|
if ypos > 0:
|
||
|
successors.append(['FORWARD', xpos, ypos - 50, 'N'])
|
||
|
|
||
|
if orientation == 'S':
|
||
|
successors.append(['LEFT', xpos, ypos, 'E'])
|
||
|
successors.append(['RIGHT', xpos, ypos, 'W'])
|
||
|
if ypos < 750:
|
||
|
successors.append(['FORWARD', xpos, ypos + 50, 'S'])
|
||
|
|
||
|
if orientation == 'W':
|
||
|
successors.append(['LEFT', xpos, ypos, 'S'])
|
||
|
successors.append(['RIGHT', xpos, ypos, 'N'])
|
||
|
if xpos > 0:
|
||
|
successors.append(['FORWARD', xpos - 50, ypos, 'W'])
|
||
|
|
||
|
if orientation == 'E':
|
||
|
successors.append(['LEFT',xpos, ypos, 'N'])
|
||
|
successors.append(['RIGHT', xpos, ypos, 'S'])
|
||
|
if xpos < 750:
|
||
|
successors.append(['FORWARD', xpos + 50, ypos, 'E'])
|
||
|
|
||
|
return successors
|