Class FiveGame

java.lang.Object
nl.uu.cs.aplib.exampleUsages.fiveGame.FiveGame

public class FiveGame extends Object
A simple game as an example for agents to play. The game is played by two players on an NxN board. The players take turn to put their pieces. The pieces of player-1 are called "circles", that of player-2 are "crosses". A piece is placed on an empty square. Some squares may be blocked; these are randomly determined when the board was created.

A player wins if she can make a horizontal, vertical, or diagonal connected segment of length 5, consisting of only her pieces.

The game ends in tie if the board is full, and no player wins.

The main-method gives a demo using two random-agents as players.

Author:
wish
  • Field Details

  • Constructor Details

    • FiveGame

      public FiveGame(int size, int numOfBlocked)
      Construct an instance of FiveGame of the specified size x size.
      Parameters:
      size -
      numOfBlocked - This many squares will be randomly selected and blocked.
  • Method Details

    • getState

      public FiveGame.SQUARE[][] getState()
      Get a copy of the game board.
    • getGameStatus

      public FiveGame.GAMESTATUS getGameStatus()
      Get the game status (unfinished/cross-won/circle-won/tie).
    • move

      public boolean move(FiveGame.SQUARE ty, int x, int y)
      Place a piece of the specified type in the given coordinate. If the square is unoccupied, this returns true, else false.
      Parameters:
      ty - Should be either CROSS or CIRCLE.
    • getLastmove

      public FiveGame.Square_ getLastmove()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringShort

      public String toStringShort()
      Produce a string summarizing the status of the game.
    • print

      public void print()
    • printStatus

      public void printStatus()
    • main

      public static void main(String[] args)