cz.cvut.agents.rph.reversi
Class ReversiPlayer

java.lang.Object
  extended by cz.cvut.agents.rph.reversi.ReversiPlayer
All Implemented Interfaces:
ReversiPlayerInterface, java.rmi.Remote
Direct Known Subclasses:
DummyPlayer, WrongMovePlayer

public abstract class ReversiPlayer
extends java.lang.Object
implements ReversiPlayerInterface

General template for a reversi player. Extend this class and place your player in the cz.cvut.agents.rph.reversi.players package. Author: Ondrej Vanek Date: 10/3/12 Time: 10:09 AM


Field Summary
protected  int height
          Height of the board.
protected  int myColor
          Color of my stones.
protected  int opponentColor
          Color of opponent's stones.
protected  int width
          Width of the board.
 
Constructor Summary
ReversiPlayer()
           
 
Method Summary
 void endGame()
          This method is used only in the tournament.
 int getEmptySquareColor()
          Gets the color of the empty square.
 int getMyColor()
          Gets the color of the player.
abstract  java.lang.String getName()
          Returns name of the reversi player.
 int getOpponentColor()
          Gets the color of the opponent player.
 void init(int boardWidth, int boardHeight, int myColor, int opponentColor)
          Initializes the player with game parameters.
abstract  ReversiMove makeNextMove(int[][] board)
          This method is called by the reversi server when the player has to compute the next move.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

width

protected int width
Width of the board.


height

protected int height
Height of the board.


myColor

protected int myColor
Color of my stones.


opponentColor

protected int opponentColor
Color of opponent's stones.

Constructor Detail

ReversiPlayer

public ReversiPlayer()
Method Detail

init

public void init(int boardWidth,
                 int boardHeight,
                 int myColor,
                 int opponentColor)
Initializes the player with game parameters. You can override this method to do your own initialization.

Specified by:
init in interface ReversiPlayerInterface
Parameters:
boardWidth - WIDTH of the board
boardHeight - HEIGHT of the board
myColor - color of the player
opponentColor - color of the opponent

getMyColor

public final int getMyColor()
Gets the color of the player.

Specified by:
getMyColor in interface ReversiPlayerInterface
Returns:
color of the player.

getOpponentColor

public final int getOpponentColor()
Gets the color of the opponent player.

Specified by:
getOpponentColor in interface ReversiPlayerInterface
Returns:
color of the opponent player.

getEmptySquareColor

public final int getEmptySquareColor()
Gets the color of the empty square.

Specified by:
getEmptySquareColor in interface ReversiPlayerInterface
Returns:
color of the empty square.

getName

public abstract java.lang.String getName()
Returns name of the reversi player. Return your username!

Specified by:
getName in interface ReversiPlayerInterface
Returns:

makeNextMove

public abstract ReversiMove makeNextMove(int[][] board)
This method is called by the reversi server when the player has to compute the next move. The method returns a ReversiMove class encapsulating the coordinates of the stone to be put on the board.

Specified by:
makeNextMove in interface ReversiPlayerInterface
Parameters:
board - - contains actual map of the board represented by two-dimensional matrix. Each sqaure contains number of -1 representing empty square and number 0 and 1 representing players' stones.
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

endGame

public final void endGame()
This method is used only in the tournament.

Specified by:
endGame in interface ReversiPlayerInterface