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 BasePlayer

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

All Implemented Interfaces:
  Player

    public class BasePlayer

extends AbstractPlayer

Players may extend this class to receive some additional convenience functions. It is not necessary to extend BasePlayer; you may opt to extend AbstractPlayer directly instead.

See Also:
  `AbstractPlayer`

Field Summary

Fields inherited from class jp.ac.nii.icpc2010.players.AbstractPlayer
`id, OBJECT_COIN, OBJECT_FREE, OBJECT_WALL, playField`

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

Method Summary
`java.util.List<int[]>` | `getAdjacentPos(int x, int y)` Obtain the list of positions next to the current position.
`FieldDirection[]` | `getDirs()` Obtain the array of directions
`java.util.ArrayList<java.lang.Integer>` | `getEnemyIds()` Obtain the list of enemy ids
`FieldDirection` | `getInput()` Override this method to control the agent.
`java.awt.Point` | `getPosition(int id)` Obtain the position of the player
`int[]` | `getPositionById(int id)` Obtain the position of the player
`java.util.List<FieldDirection>` | `getRandomDirs()` Obtain the list of directions in randomised order
`java.util.List<FieldDirection>` | `getSafeDirs(int x, int y)` Obtain the array of safe directions
`boolean` | `isCoin(int x, int y)` Is there a coin on the cell?
`boolean` | `isEnemyTron(int x, int y)` Is it a trail of enemies?
`boolean` | `isFree(int x, int y)` Is it a free cell?
`boolean` | `isMyTron(int x, int y)` Is it a trail of my Tron?
`boolean` | `isSafe(int x, int y)` Is it safe to walk on the indicated coordinates? Currently this is true if it is either FIELD_FREE or FIELD_COIN.
`boolean` | `isTron(int x, int y)` Is it a trail?
`boolean` | `isWall(int x, int y)` Is it a wall?

Methods inherited from class jp.ac.nii.icpc2010.players.AbstractPlayer
`getId, getPlayField, getRemainingTime, getTrailId, getTrailIdOf, getTronIdOf, getX, getXOf, getY, getYOf, setFinishTime, setPlayField`

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

Constructor Detail

### BasePlayer

    public BasePlayer(int id,
                      IPlayField playField)

Method Detail

### getEnemyIds

    public java.util.ArrayList<java.lang.Integer> getEnemyIds()

  Obtain the list of enemy ids

  Returns:
    ArrayList of ids

### isFree

    public boolean isFree(int x,
                          int y)

  Is it a free cell?

  Parameters:
    `x` - Current position X
    `y` - Current position Y
  Returns:

### isCoin

    public boolean isCoin(int x,
                          int y)

  Is there a coin on the cell?

  Parameters:
    `x` - Current position X
    `y` - Current position Y
  Returns:

### isWall

    public boolean isWall(int x,
                          int y)

  Is it a wall?

  Parameters:
    `x` - Current position X
    `y` - Current position Y
  Returns:

### isMyTron

    public boolean isMyTron(int x,
                            int y)

  Is it a trail of my Tron?

  Parameters:
    `x` - Current position X
    `y` - Current position Y
  Returns:

### isEnemyTron

    public boolean isEnemyTron(int x,
                               int y)

  Is it a trail of enemies?

  Parameters:
    `x` - Current position X
    `y` - Current position Y
  Returns:

### isTron

    public boolean isTron(int x,
                          int y)

  Is it a trail?

  Parameters:
    `x` - Current position X
    `y` - Current position Y
  Returns:

### isSafe

    public boolean isSafe(int x,
                          int y)

  Is it safe to walk on the indicated coordinates? Currently this is true if it is either FIELD_FREE or FIELD_COIN.

  Parameters:
    `x` - Current position X
    `y` - Current position Y
  Returns:

### getPositionById

    public int[] getPositionById(int id)

  Obtain the position of the player

  Parameters:
    `id` - Target player's id
  Returns:
    Array of size 2; position 0 is x, position 1 is y

### getPosition

    public java.awt.Point getPosition(int id)

  Obtain the position of the player

  Parameters:
    `id` - Target player's id
  Returns:
    Point with the player's position

### getDirs

    public FieldDirection[] getDirs()

  Obtain the array of directions

  Returns:
    Up, Down, Left, Right

### getRandomDirs

    public java.util.List<FieldDirection> getRandomDirs()

  Obtain the list of directions in randomised order

  Returns:
    Shuffled array of Up, Down, Left, Right

### getSafeDirs

    public java.util.List<FieldDirection> getSafeDirs(int x,
                                                      int y)

  Obtain the array of safe directions

  Parameters:
    `x` - Current position X
    `y` - Current position Y
  Returns:
    array list of directions

### getAdjacentPos

    public java.util.List<int[]> getAdjacentPos(int x,
                                                int y)

  Obtain the list of positions next to the current position. In the resulting list, every item is an integer array of length 2. The first value in each array is the X-position, the second is the Y-position.

  Parameters:
    `x` - Current position X
    `y` - Current position Y
  Returns:
    List of positions.

### getInput

    public FieldDirection getInput()

  Override this method to control the agent. This method currently always returns FieldDirection.UP. If you extend this class, you should override this method and change its behaviour to something more intelligent.

  Returns:
    FieldDirection.Up

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