diff --git a/state.py b/state.py index 3af08e5..4284965 100644 --- a/state.py +++ b/state.py @@ -202,11 +202,13 @@ def generate_moves(self, board, color): break return possible_moves - #Generate successors for moves, needs implemented + #Generate successors for moves def generate_successors(self, board, color): successors = [] - #for move in self.generate_moves(board, color): - + for move in self.generate_moves(board, color): + board_copy = State(board) + board_copy.movePiece(move[0], move[1]) + successors.append(board_copy.board, color, move) return successors #Evaluation function @@ -217,4 +219,11 @@ def eval(self, board, playerColor, opponentColor): return -1 * math.inf if opponent_moves == 0: return math.inf - return len(player_moves) - (len(opponent_moves)*3) \ No newline at end of file + return len(player_moves) - (len(opponent_moves)*3) + + def makeMove(self, color): + if len(self.generate_moves(self.board, color)) > 0: + move = Minimax(self, 0, color, math.inf * -1, math.inf) + self.movePiece(move[0], move[1]) + else: + self.gameOver = 1