Beispiel #1
0
 def genmove(self):
     ''' politely ask user for a move. '''
     
     size = self.engine.board.size
     move = None
     while True:
         print("move:")
         move = sys.stdin.readline()
         if move.strip().lower() == "quit":
             sys.exit(0)
         
         move = Utils.parse_vertex(move, size)
         if Utils.valid_coord(move, size) and Utils.check_move(self.engine.board, move, self.colour, []):
             break
         else:
             print("invalid move")
     return move
Beispiel #2
0
 def play(self, color, vertex):
     vertex = Utils.parse_vertex(vertex, self._board.size)  # may be None
     color = 1 if color[0].lower() == "b" else 2
     self.apply_move(vertex, color)