Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def successors_of(state):
  2.     # Generate valid moves
  3.     valid_moves = []
  4.     for i in range(len(state)):
  5.         if state[i] == 1 or state[i] == 2:
  6.             continue
  7.         count = 1
  8.         while count < state[i]/2:
  9.             new_state = state.copy()
  10.             new_state[i] = new_state[i]-count
  11.             new_state.append(count)
  12.             new_state.sort(reverse=True)
  13.             valid_moves.append((count,new_state))
  14.             count += 1
  15.     return valid_moves
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement