Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jp.ac.nii.icpc2010.playfield
Interface IPlayField

    public interface IPlayField

Read-only interface to the play field.

Playfields use a 2D coordinate system. X-values increase from left to right, and Y-values increase from top to bottom.

     0----------------->x
     |        ^
     |        -y
     |    <-x    +x>
     |        +y
     |        v
     |
     v
     y

This interface is not meant to be implemented by user classes. It is mainly intended to provide access to the field provided by the framework. If you want to make your own field class, you may consider making a different interface.

It is usually enough to use the various convenience methods provided for interacting with the field, but the below explanation may be useful in some cases.

Objects on the playfield are identified by integer codes. getObjectAt(x, y) obtains the object at a given position. This object can be either a coin (FIELD_COIN), a wall (FIELD_WALL), or an empty square (FIELD_FREE). Only FIELD_FREE and FIELD_COIN are safe to pass through.

In addition, the object can be the trail of an enemy tron. AbstractPlayer.getTrailIdOf(id) gets the trail code for the player identified by "id". Id numbers range from 0 and upwards. getTrons() in this class can be used to get all trons, and then getId() can be used on each to obtain their id code. BasePlayer.getEnemyIds() can also be used to obtain enemy tron ids.

See Also:
  `AbstractPlayer`, `BasePlayer`, `ITron`

Field Summary
`static int` | `FIELD_COIN` A coin.
`static int` | `FIELD_FREE` An empty square.
`static int` | `FIELD_WALL` A wall.

Method Summary
`int` | `getHeight()` Obtain the height (in units) of the field
`int` | `getNumOfPlayers()` Get the number of players in the play field.
`int` | `getObjectAt(int x, int y)` Obtain Object ID at a certain position in the field.
`int` | `getRemainingRounds()` Return remaining rounds in this match.
`int` | `getRemainingTurns()` Return remaining turns in this round.
`int` | `getRound()` Return number of current round.
`java.util.Vector<ITron>` | `getTrons()` Obtain Trons on this playfield.
`int` | `getTurn()` Return number of current turn.
`int` | `getWidth()` Obtain the width (in units) of the field
`int[]` | `stepOne(int x, int y, FieldDirection dir)` Return the new coordinates of the tron after stepping one step.

Field Detail

### FIELD_FREE

    static final int FIELD_FREE

  An empty square. Trons can move through walls.

  See Also:
    Constant Field Values

### FIELD_WALL

    static final int FIELD_WALL

  A wall. Trons cannot move through walls.

  See Also:
    Constant Field Values

### FIELD_COIN

    static final int FIELD_COIN

  A coin. Trons can move through coins, and they get points for doing so.

  See Also:
    Constant Field Values

Method Detail

### getWidth

    int getWidth()

  Obtain the width (in units) of the field

  Returns:

### getHeight

    int getHeight()

  Obtain the height (in units) of the field

  Returns:

### getObjectAt

    int getObjectAt(int x,
                    int y)

  Obtain Object ID at a certain position in the field.

  Parameters:
    `x` -
    `y` -
  Returns:
    One of the values above (FIELD_FREE ... FIELD_WALL), or a Tron trail ID.

### getTrons

    java.util.Vector<ITron> getTrons()

  Obtain Trons on this playfield.

  Returns:

### stepOne

    int[] stepOne(int x,
                  int y,
                  FieldDirection dir)

  Return the new coordinates of the tron after stepping one step. This function takes care of wrapping over the edge of the field, etc.

  Parameters:
    `x` - Current position X
    `y` - Current position Y
    `dir` - Direction to step in
  Returns:
    Array of size 2; position 0 is x, position 1 is y

### getNumOfPlayers

    int getNumOfPlayers()

  Get the number of players in the play field.

  Returns:

### getTurn

    int getTurn()

  Return number of current turn.

  Returns:

### getRound

    int getRound()

  Return number of current round.

  Returns:

### getRemainingTurns

    int getRemainingTurns()

  Return remaining turns in this round.

  Returns:

### getRemainingRounds

    int getRemainingRounds()

  Return remaining rounds in this match.

  Returns:

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD