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.players
Class AbstractPlayer

    java.lang.Object
      jp.ac.nii.icpc2010.players.AbstractPlayer

All Implemented Interfaces:
  Player

Direct Known Subclasses:
  BasePlayer

    public abstract class AbstractPlayer

extends java.lang.Object
implements Player

The AbstractPlayer class contains functions for querying the position of the players, details on the playfield and the remaining time per round.

This is the most basic class that all players must extend. Players also have the option to extend BasePlayer, which contains some additional convenience functions.

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

For an explanation of tron IDs and trail IDs, see the IPlayField class.

See Also:
  `IPlayField`

Field Summary
`protected int` | `id` ID of this player
`protected static int` | `OBJECT_COIN` A coin.
`protected static int` | `OBJECT_FREE` An empty square.
`protected static int` | `OBJECT_WALL` A wall.
`protected IPlayField` | `playField` Reference to the field information class.

Constructor Summary
`AbstractPlayer(int id, IPlayField playField)`

Method Summary
`protected int` | `getId()` Obtain the ID of this Tron.
`protected IPlayField` | `getPlayField()` Obtain the current playfield.
`protected int` | `getRemainingTime()` Obtain the remaining time to compute the current input.
`protected int` | `getTrailId()` Get the Object ID of the trail of this player's tron
`protected int` | `getTrailIdOf(int id)` Return the object ID of the trail of a given tron .
`protected int` | `getTronIdOf(int trail)` Inverse of getTrailIdOf.
`protected int` | `getX()` Get the X-coordinate of this player's tron.
`protected int` | `getXOf(int id)` Given a tron id, this method returns the x-coordinate of the specified tron.
`protected int` | `getY()` Get the Y-coordinate of this player's tron.
`protected int` | `getYOf(int id)` Given a tron id, this method returns the y-coordinate of the specified tron.
`void` | `setFinishTime(long finishTime)` Internal framework use only.
`void` | `setPlayField(IPlayField playField)` Internal framework use only.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface jp.ac.nii.icpc2010.players.Player
`getInput`

Field Detail

### id

    protected int id

  ID of this player

### playField

    protected IPlayField playField

  Reference to the field information class.

### OBJECT_FREE

    protected static final int OBJECT_FREE

  An empty square. Trons can move through walls.

  See Also:
    Constant Field Values

### OBJECT_WALL

    protected static final int OBJECT_WALL

  A wall. Trons cannot move through walls.

  See Also:
    Constant Field Values

### OBJECT_COIN

    protected static final int OBJECT_COIN

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

  See Also:
    Constant Field Values

Constructor Detail

### AbstractPlayer

    public AbstractPlayer(int id,
                          IPlayField playField)

Parameters:
  `id` - the id of the tron
  `playField` - a reference of the playfield

Method Detail

### setFinishTime

    public final void setFinishTime(long finishTime)

  Internal framework use only. This function is called by PlayerRunProcess. You are NOT allowed to call this method.

  Parameters:
    `finishTime` -

### setPlayField

    public final void setPlayField(IPlayField playField)

  Internal framework use only. This function is called by PlayerManager. You are NOT allowed to call this method.

  Parameters:
    `playField` -

### getId

    protected int getId()

  Obtain the ID of this Tron.

  Returns:
    the unique id of this Tron

### getPlayField

    protected IPlayField getPlayField()

  Obtain the current playfield.

  Returns:
    A reference to the current playfield

### getXOf

    protected int getXOf(int id)

  Given a tron id, this method returns the x-coordinate of the specified tron.

  Parameters:
    `id` - the id of the tron
  Returns:
    the x-coordinate of the tron

### getYOf

    protected int getYOf(int id)

  Given a tron id, this method returns the y-coordinate of the specified tron.

  Parameters:
    `id` - the id of the tron
  Returns:
    the y-coordinate of the tron

### getX

    protected int getX()

  Get the X-coordinate of this player's tron.

  Returns:
    the current x-coord of this tron

### getY

    protected int getY()

  Get the Y-coordinate of this player's tron.

  Returns:
    the current y-coord of this tron

### getTrailIdOf

    protected int getTrailIdOf(int id)

  Return the object ID of the trail of a given tron .

  Parameters:
    `id` - the id of the tron
  Returns:
    the object id of that tron's trail

### getTrailId

    protected int getTrailId()

  Get the Object ID of the trail of this player's tron

  Returns:
    the object trail of this tron
  See Also:
    `getTrailIdOf`

### getTronIdOf

    protected int getTronIdOf(int trail)

  Inverse of getTrailIdOf. Return Tron ID of given Object ID

  Parameters:
    `trail` - the trail id
  Returns:
    the id of the corresponding tron
  See Also:
    `getTrailIdOf`

### getRemainingTime

    protected int getRemainingTime()

  Obtain the remaining time to compute the current input. It is recommended that you use the following form with this method: while (getRemainingTime() > 10) { compute(); ... } For a value >= 10, since it is difficult to measure values less than 10 ms on some operating systems. You may have to use 15 or 20, but more should not be necessary.

  Returns:
    the remaining time in milliseconds

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