The number of pieces per player is configurable in custom board files, but this number is not exposed to CPU players, even though it affects the possible moves.
Two ways to represent this information come to mind:
Add a method like game.getPieces() that returns the total number of pieces per player. The number of pieces remaining can easily be calculated by subtracting the pieces already on the board. This is the easiest to implement.
Pass an array that contains the number of pieces remaining for each player to callCPU(). This array varies during the game, as pieces are placed and removed from the board. The main advantage of this representation is that the AI player doesn't have to calculate the number of pieces remaining explicitly. (It's also slightly more flexible, in that it allows games where players have a different number of pieces to play with, though I cannot think of a reason why this would be useful.)
The number of pieces per player is configurable in custom board files, but this number is not exposed to CPU players, even though it affects the possible moves.
Two ways to represent this information come to mind:
game.getPieces()
that returns the total number of pieces per player. The number of pieces remaining can easily be calculated by subtracting the pieces already on the board. This is the easiest to implement.callCPU()
. This array varies during the game, as pieces are placed and removed from the board. The main advantage of this representation is that the AI player doesn't have to calculate the number of pieces remaining explicitly. (It's also slightly more flexible, in that it allows games where players have a different number of pieces to play with, though I cannot think of a reason why this would be useful.)