world
Class Tile

java.lang.Object
  |
  +--world.Tile
All Implemented Interfaces:
Comparable, Direction, Locality
Direct Known Subclasses:
BaseTile, PlainTile, WallTile, WaterTile

public abstract class Tile
extends Object
implements Comparable, Direction, Locality

Abstract class that implements board tiles for the ICFP-2002 programming contest entry.

Version:
$Revision: 1.7 $
Author:
Allen D. Ball

Fields inherited from interface world.Direction
EAST, NORTH, SOUTH, WEST
 
Constructor Summary
protected Tile(Board board, int row, int column)
          Creates a tile.
 
Method Summary
 int compareTo(Object object)
          Compares this object with the specified object for order.
 Board getBoard()
          Method to get the containing board.
 int getColumn()
          Method to get the tile column.
 Tile getNeighbor(int direction)
          Method to get the tile's neighbor.
 int getOrdinal()
          Method to get an ordinal ordering for this tile with the other tiles in its board.
 TreeSet getPassages()
          Method to get the set of possible passages from this tile.
 Path getPathTo(Tile end)
          Method to return the path from this tile to the end tile.
 int getRow()
          Method to get the tile row.
 Sack getSack()
          Method to get the tile's sack.
 Tile getTile()
          Method to return tile.
abstract  boolean isLethal()
          Method to determine if the tile is lethal.
abstract  boolean isPassable()
          Method to determine if the tile is passable.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tile

protected Tile(Board board,
               int row,
               int column)
Creates a tile.
Parameters:
board - The playing board.
row - The row position of the tile.
column - The column position of the tile.
See Also:
Position
Method Detail

getBoard

public Board getBoard()
Method to get the containing board.
Returns:
The containing board.

getRow

public int getRow()
Method to get the tile row.
Returns:
The tile row.

getColumn

public int getColumn()
Method to get the tile column.
Returns:
The tile column.

getSack

public Sack getSack()
Method to get the tile's sack.
Returns:
The tile's sack.

getTile

public Tile getTile()
Method to return tile. Used to implement Locality.
Specified by:
getTile in interface Locality
Returns:
The tile.

getNeighbor

public Tile getNeighbor(int direction)
Method to get the tile's neighbor.
Returns:
The neighboring tile.
See Also:
Direction

isPassable

public abstract boolean isPassable()
Method to determine if the tile is passable.
Returns:
True if a robot may occupy the space; false otherwise.

getPassages

public TreeSet getPassages()
Method to get the set of possible passages from this tile.
Returns:
A sorted set of tiles.
See Also:
Tile

isLethal

public abstract boolean isLethal()
Method to determine if the tile is lethal.
Returns:
True if a robot will be killed if it enters the tile; false otherwise.

getPathTo

public Path getPathTo(Tile end)
Method to return the path from this tile to the end tile.
Parameters:
end - The end tile of the path.
Returns:
The path from start to end.

compareTo

public int compareTo(Object object)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Specified by:
compareTo in interface Comparable
Parameters:
object - The object to be compared.
See Also:
Comparable

getOrdinal

public int getOrdinal()
Method to get an ordinal ordering for this tile with the other tiles in its board.


Copyright 2002 Allen D. Ball. All rights reserved.