Skip to content

Commit

Permalink
Update state.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zew15101 authored Dec 9, 2019
1 parent 23eda7a commit 0d01475
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
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

0 comments on commit 0d01475

Please sign in to comment.