Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kartikkukreja/b23945f25ef3237f07d9 to your computer and use it in GitHub Desktop.
Save kartikkukreja/b23945f25ef3237f07d9 to your computer and use it in GitHub Desktop.
Checkers Evaluation Function: Piece Weight Difference
def piecesCount(state):
# 1 for a normal piece, 1.5 for a king
black, white = 0, 0
for row in state.grid:
for cell in row:
if cell == 'b': black += 1.0
elif cell == 'B': black += 1.5
elif cell == 'w': white += 1.0
elif cell == 'W': white += 1.5
return black - white if IsPlayerBlack else white - black
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment