Skip to content
LeeBreisacher edited this page Nov 29, 2010 · 4 revisions

Writing an AI for Scribe

This is a guide to writing your own AI for Scribe. If you have any questions or comments, please email me at [email protected]. If you write an AI that you think is particularly good, and you think I should include it in the app, please issue a pull request.

To create an AI for Scribe, create a new Java class that extends the abstract class tyler.breisacher.scribe.AIPlayer. The only method you have to override is itsYourTurn, which the Scribe application will call when it is your turn, to inform your AI that it is its turn to move. The itsYourTurn method should examine the current state of the board, and return a GridPosition representing the move it wants to make. The variable board will already be set to the ScribeBoard for the current game. You can examine the state of the board using the following methods:

  • ScribeBoard.getEnabledMiniGrids() - returns a List of all the MiniGrids that are currently enabled. This will either be a single MiniGrid, or all the MiniGrids that have at least one open square.
  • ScribeBoard.get(x, y) - returns the MiniGrid at position (x, y) where x and y are 0, 1, or 2.
  • MiniGrid.getEmptyCells() - returns a List of the positions of all the empty cells within a MiniGrid
  • MiniGrid.get(x, y) - returns the color of the square at position (x, y) of the MiniGrid
  • ScribeBoard.getLastMove(ScribeMark) - returns the GridPosition of a player's most recent move. The AI is always the blue player, so to see the opponent's last move, pass ScribeMark.RED as the argument.

Once you have used these functions to get the information you want about the current state of the board, you should select a MiniGrid, the position of a square in that MiniGrid, then return a GridPosition to make your move.

Clone this wiki locally