Game Scores & Heuristics

Game Scores & Heuristics

All games have two methods that return a score (in AbstractGameState):

  • getGameScore(playerID) (must be implemented)
  • _getHeuristicScore(playerID) (optional)

The first of these is the inherent score in a game (number of victory points for example). The latter provides a means for games to provide a heuristic scoring function that may provide a better general guide to an AI player of how well they are doing in the given game state.

For an example of this, have a look at games.coltexpress.ColtExpressHeuristic.

Custom heuristics for AI players

Each game in the framework provides its own heuristic. If desired, the game heuristics can be overwritten specifically within an AI player, and the game state evaluated using this custom heuristic. The new heuristic has to implement the IStateHeuristic interface along with its evaluateState(AbstractGameState gs, int playerId) function. The agents implemented in the framework (OSLA, RMHC, MCTS) all support custom heuristics.

To use one of these agents with a custom heuristics, just supply it in the constructor: players.add(new OSLAPlayer(new CustomHeuristics()), or as part of the Parameters (for MCTS and RMHC). If no heuristic is provided, then the agent uses the default getHeuristicScore function from the game. When creating a new player the developer should take care of handling the custom Heuristics as the AbstractPlayer does not enforce its usage.

All heuristics should ideally support the ITunableParameters interface, as this allows them to be easily tuned as described in Optimising an AI. See any of the existing Heuristics for examples to follow.