de.tabacha.cgo
Interface Board

All Superinterfaces:
java.lang.Cloneable
All Known Implementing Classes:
DefaultBoard

public interface Board
extends java.lang.Cloneable

A data model for (conway)go boards.
Why using an interface when there is only one implementation? Because there isn't only one, one of the AI classes provides an own read-only implementation, and you're free to write others. A synchronized implementation does not exist yet.
$Id: Board.java,v 1.11 2004/12/23 21:42:43 mk Exp $

Version:
$Revision: 1.11 $

Method Summary
 void addPiece(Field f)
          Puts a piece (aka player) on the board.
 void addPiece(int col, int row)
          Puts a piece (aka player) on the board.
 java.lang.Object clone()
          Returns a deep copy of this object.
 Field getBall()
          Returns the actual field of the ball.
 void move(Move move)
          Makes a move.
 byte on(Field field)
          Returns the content of the specified field on the board.
 byte on(int col, int row)
          Returns the content of the field on the specified row and column.
 void removePiece(Field f)
          Removes a piece (aka player) from the board.
 void removePiece(int col, int row)
          Removes a piece (aka player) from the board.
 void reset()
          Initializes the field, setting it to the start position.
 void setBall(Field newBallField)
          Sets the actual field of the ball.
 void setBall(int col, int row)
          Sets the actual field of the ball.
 byte[][] toArray()
          Returns this object as a two-dimensional array containing the contents of the fields.
 Board upsideDown()
          Returns a copy of this board mirrored along the x-axis.
 boolean whoseTurn()
          Returns the player who has to move.
 

Method Detail

reset

public void reset()
Initializes the field, setting it to the start position.


upsideDown

public Board upsideDown()
Returns a copy of this board mirrored along the x-axis.


clone

public java.lang.Object clone()
Returns a deep copy of this object.


toArray

public byte[][] toArray()
Returns this object as a two-dimensional array containing the contents of the fields.


whoseTurn

public boolean whoseTurn()
Returns the player who has to move.

Returns:
UP or DOWN, declared in Constants.

on

public byte on(int col,
               int row)
Returns the content of the field on the specified row and column.

Returns:
EMPTY, PIECE or BALL; declared in Constants.

on

public byte on(Field field)
Returns the content of the specified field on the board.

Returns:
EMPTY, PIECE or BALL; declared in Constants.

getBall

public Field getBall()
Returns the actual field of the ball.


setBall

public void setBall(Field newBallField)
Sets the actual field of the ball.


setBall

public void setBall(int col,
                    int row)
Sets the actual field of the ball.


addPiece

public void addPiece(Field f)
Puts a piece (aka player) on the board. No warning if the field wasn't empty.


addPiece

public void addPiece(int col,
                     int row)
Puts a piece (aka player) on the board. No warning if the field wasn't empty.


removePiece

public void removePiece(Field f)
Removes a piece (aka player) from the board. No warning if there wasn't a piece on this field.


removePiece

public void removePiece(int col,
                        int row)
Removes a piece (aka player) from the board. No warning if there wasn't a piece on this field.


move

public void move(Move move)
          throws InvalidMoveException
Makes a move. If successfully performed, it's the next player's turn.

Throws:
InvalidMoveException - If the move was not correct.