Created
July 11, 2015 18:09
-
-
Save kartikkukreja/b23945f25ef3237f07d9 to your computer and use it in GitHub Desktop.
Checkers Evaluation Function: Piece Weight Difference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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