Skip to content

Commit

Permalink
Changed Model Evaluation Function For Categorical Model
Browse files Browse the repository at this point in the history
  • Loading branch information
silverlightning926 committed Jun 22, 2024
1 parent a9e14b9 commit 0ca007e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/play/model_vs_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ def get_legal_moves(board: chess.Board):


def evaluate_board(board: chess.Board):
turn = board.turn

encoded_board = encode_board(board)
encoded_board = np.reshape(encoded_board, (1, 8, 8, 12))

prediction = model.predict(encoded_board, verbose=0, batch_size=1)
return prediction[0][0]
prediction = model.predict(encoded_board)

if turn:
return prediction[0][0]

return prediction[0][1]


def minimax(board: chess.Board, depth: int, alpha: float, beta, maximizing_player: bool):
Expand Down
10 changes: 8 additions & 2 deletions src/play/player_vs_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ def get_legal_moves(board: chess.Board):


def evaluate_board(board: chess.Board):
turn = board.turn

encoded_board = encode_board(board)
encoded_board = np.reshape(encoded_board, (1, 8, 8, 12))

prediction = model.predict(encoded_board, verbose=0, batch_size=1)
return prediction[0][0]
prediction = model.predict(encoded_board)

if turn:
return prediction[0][0]

return prediction[0][1]


def minimax(board: chess.Board, depth: int, alpha: float, beta, maximizing_player: bool):
Expand Down

0 comments on commit 0ca007e

Please sign in to comment.