Actually, I am writing a code to train a robot in an unspecified grid. The Robot can move only UP/DOWN/LEFT/RIGHT. I start from point [0,0]. initially, my plan was to recursively figure out the coordinates but are there any other alternatives? I get recursion limit violation error as well.
How to write the non-recursive code of the following approach:
def play_episodes(current_point):
global safe_block
if(mine_safe_space(current_point) and visited_before(current_point)):
check_state.add(conversion(current_point))
safe_block += 1
play_episodes([current_point[0] + 1, current_point[1]])
play_episodes([current_point[0] - 1, current_point[1]])
play_episodes([current_point[0], current_point[1] + 1])
play_episodes([current_point[0], current_point[1] - 1])