Beispiel #1
0
 def move(self, game_state):
     inp = raw_input(self.player + ' turn. Enter <row col action> (action is N/NE/E/SE/S/SW/W/NW/SPIN): ')
     row, col, action = inp.split()
     row = int(row)
     col = int(col)
     action = action.upper()
     res = []
     if(action == 'SPIN'):
         res = SpinAction(row, col)
     else:
         direction_idx = DIRECTIONS.index(Direction(action, (0, 0))) #@UndefinedVariable
         res = MoveAction(row, col, DIRECTIONS[direction_idx])
     return res           
Beispiel #2
0
 def move(self, game_state):
     print game_state
     inp = raw_input(
         self.player +
         ' turn. Enter <row col action> (action is N/NE/E/SE/S/SW/W/NW/SPIN): '
     )
     row, col, action = inp.split()
     row = int(row)
     col = int(col)
     action = action.upper()
     res = []
     if (action == 'SPIN'):
         res = SpinAction(row, col)
     else:
         direction_idx = DIRECTIONS.index(Direction(action, (0, 0)))
         res = MoveAction(row, col, DIRECTIONS[direction_idx])
     return res
Beispiel #3
0
 def the_move(self, game_state):
     print game_state
     inp = raw_input(self.player + ' turn. Enter <row col action> (action is N/NE/E/SE/S/SW/W/NW/SPIN): or STOP\n')
     # option to exit
     if inp.find("STOP") > -1:
         raise self.StopGameException("User stopped the game")
     
     row, col, action = inp.split()
     row = int(row)
     col = int(col)
     action = action.upper()
     res  = []
     if(action == 'SPIN'):
         res  = SpinAction(row, col)
     else:
         direction_idx = DIRECTIONS.index(Direction(action, (0, 0))) #@UndefinedVariable
         res  = MoveAction(row, col, DIRECTIONS[direction_idx])
     return res