bot
Class Board

java.lang.Object
  extended bybot.Board
All Implemented Interfaces:
Cloneable, Serializable
Direct Known Subclasses:
CleanBoard, CritterBoard, ExitBoard, MultiBoard

public class Board
extends Object
implements Serializable, Cloneable

This holds the maze the bot wanders around in. It is a collection of Squares.

See Also:
Serialized Form

Constructor Summary
Board()
          Make an empty board.
 
Method Summary
 Square addSquare(int x, int y)
          Add point if not already added.
 Square addSquare(Point p)
          Add point if not already added.
 void addSquare(Square s)
          Adds a square unless that location already exists, in which case it does nothing.
 Object clone()
           
 void endAction(Bot b)
          If the board wants to hear about an action being ended, override this and make a special board.
 Point getCenter()
          Get coordinates of the center of the board.
 Dimension getDimensions()
           
 int getHeight()
           
 Square getSquare(int x, int y)
          Get square at given location.
 Square getSquare(Point p)
          Get square at given location.
 Set getSquares()
          Get all the squares on the board.
 Point getTLCorner()
          Get topleft coordinate of board.
 int getWidth()
           
 WinChecker getWinChecker()
          If you want special win conditions for the board, override this.
 boolean hasSquare(int x, int y)
          Is there a square at this location?
 boolean hasSquare(Point p)
          Is there a square at this location?
 boolean hasSquare(Square sq)
          Is this square (or a square with the same coordinates) on the board?
 boolean isKeyBoard()
          Does this board revolve around picking up keys?
static Board loadBoard(File f)
          Load a board from a given file.
static Board loadBoard(InputStream is)
           
 int numSquares()
          How many squares are in this board?
 void save(File f)
          Save this board to a file.
 void save(String fname)
           
 void setInformer(Informer inf)
          If we need to know who our informer is.
 void setStart(int x, int y)
           
 void setStart(Square new_start)
          Set which square is the bot's starting square.
 Square start()
          Get the start square of the bot.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Board

public Board()
Make an empty board.

Method Detail

clone

public Object clone()

loadBoard

public static Board loadBoard(File f)
                       throws IOException
Load a board from a given file.

Throws:
IOException

loadBoard

public static Board loadBoard(InputStream is)
                       throws IOException
Throws:
IOException

save

public void save(String fname)
          throws IOException
Throws:
IOException

save

public void save(File f)
          throws IOException
Save this board to a file.

Throws:
IOException

addSquare

public Square addSquare(int x,
                        int y)
Add point if not already added.


addSquare

public Square addSquare(Point p)
Add point if not already added.


addSquare

public void addSquare(Square s)
Adds a square unless that location already exists, in which case it does nothing.


getTLCorner

public Point getTLCorner()
Get topleft coordinate of board.


getCenter

public Point getCenter()
Get coordinates of the center of the board.


getHeight

public int getHeight()

getWidth

public int getWidth()

getDimensions

public Dimension getDimensions()

setStart

public void setStart(Square new_start)
Set which square is the bot's starting square.


setStart

public void setStart(int x,
                     int y)

start

public Square start()
Get the start square of the bot.


hasSquare

public boolean hasSquare(Point p)
Is there a square at this location?


hasSquare

public boolean hasSquare(int x,
                         int y)
Is there a square at this location?


hasSquare

public boolean hasSquare(Square sq)
Is this square (or a square with the same coordinates) on the board?


getSquare

public Square getSquare(Point p)
Get square at given location.


getSquare

public Square getSquare(int x,
                        int y)
Get square at given location.


getSquares

public Set getSquares()
Get all the squares on the board. WARNING: this set is not cloned, so all changes made to it will affect the board.


getWinChecker

public WinChecker getWinChecker()
If you want special win conditions for the board, override this.


endAction

public void endAction(Bot b)
If the board wants to hear about an action being ended, override this and make a special board.


numSquares

public int numSquares()
How many squares are in this board?

Returns:
Total squares (even ones with blocks in them).

setInformer

public void setInformer(Informer inf)
If we need to know who our informer is. (For CritterBoard)


isKeyBoard

public boolean isKeyBoard()
Does this board revolve around picking up keys?

Returns:
true if the board cares about keys