|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.farafin.snEADy.player.Player
public abstract class Player
This is the basic player class which your player should be extended from.
The interface 'Serializable' is necessary for us to controll how much ram-space a player needs.
Please implement it in each of your classes, there is not more to do than just implement it,
no realization of methods is required. Java gives this interface standard methods which we
use for controlling the Players ram-space.
Dies ist die Basisspieler Klasse von welcher der euer Spieler abgeleitet werden soll.
Das Interface 'Serializable' ist nötuig, damit wir kontrollieren können wie viel ram-Speicher ein
Spieler benutzt. Bitte implementiert dieses Interface in jede eurer Klassen, aber ihr braucht
keine Methoden davon zu realisieren. Java gibt Standardmethoden vor, die wir benutzen um den
Speicherverbrauch das Spielers festzustellen.
Field Summary | |
---|---|
static java.lang.String |
comment
Overwrite this variable to print it in the player menu. |
private long |
maxTime
The maximal amount of time in milliseconds the player is allowed to think. |
private C_DebugMonitor |
monitor
This is the small window for debug informations of the player Dies ist das kleine Fenster für die debug-ausgaben der Spieler. |
private java.lang.String |
name
The name of the player. |
private long |
startTime
Here is the system time stored at which the players calculation method was started. |
private int |
turnDirection
The direction the head of the snake should turn to. |
Fields inherited from interface de.farafin.snEADy.player.PubConstants |
---|
EAST, EXIT, FREE, IN_ACTION, IN_EXIT, IN_HEAVEN, LENGTH, NORTH, PLAYER_0, PLAYER_1, PLAYER_2, PLAYER_3, PLAYER_4, PLAYER_5, PLAYER_6, PLAYER_7, PLAYER_8, PLAYER_9, POINTS, SHORTER, SLOWDOWN, SOUTH, SPEED, TURN_LEFT, TURN_NONE, TURN_RIGHT, WALL, WEST |
Constructor Summary | |
---|---|
Player()
default constructor |
Method Summary | |
---|---|
protected abstract void |
calculate(GameInfo gInfo,
LevelInfo lInfo,
SnakeInfo[] sInfo,
OwnSnakeInfo oInfo)
This is the method you should implement. |
java.lang.String |
getName()
|
int |
getTurnDirection()
|
protected long |
msDone()
this Method returns the number of milliseconds the player has calculated jet. |
protected long |
msLeft()
this Method returns the number of milliseconds the player has left for his calculation. |
protected void |
say(OwnSnakeInfo oInfo,
java.lang.String str)
This method prints your string into the debug monitor window. |
protected void |
sayNow(OwnSnakeInfo oInfo,
java.lang.String str)
This method prints your string into the debug monitor window. |
void |
setMonitor(C_DebugMonitor monitor)
|
protected void |
setName(java.lang.String name)
|
protected void |
setTurnDirection(int turn)
|
void |
startCalculation(GameInfo gInfo,
LevelInfo lInfo,
SnakeInfo[] sInfo,
OwnSnakeInfo oInfo)
This method is called when the player begins to calculate his next move. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String name
private int turnDirection
PubConstants.TURN_LEFT
,
PubConstants.TURN_NONE
,
PubConstants.TURN_RIGHT
private long startTime
private long maxTime
private C_DebugMonitor monitor
public static java.lang.String comment
Constructor Detail |
---|
public Player()
Method Detail |
---|
public void startCalculation(GameInfo gInfo, LevelInfo lInfo, SnakeInfo[] sInfo, OwnSnakeInfo oInfo)
gInfo
- game informations lInfo
- level informations sInfo
- an array of informations about all other snakes in the field. oInfo
- Informations about the own Snake GameInfo
,
LevelInfo
,
SnakeInfo
,
OwnSnakeInfo
protected abstract void calculate(GameInfo gInfo, LevelInfo lInfo, SnakeInfo[] sInfo, OwnSnakeInfo oInfo)
gInfo
- game informations lInfo
- level informations sInfo
- an array of informations about all other snakes in the field. oInfo
- Informations about the own Snake GameInfo
,
LevelInfo
,
SnakeInfo
,
OwnSnakeInfo
protected long msLeft()
protected long msDone()
public java.lang.String getName()
protected void setName(java.lang.String name)
name
- The name to set.public int getTurnDirection()
protected void setTurnDirection(int turn)
turn
- set the direction the player should turn to.protected void say(OwnSnakeInfo oInfo, java.lang.String str)
oInfo
- OwnSnakeInfo, is required to identify the player who prints the textstr
- the string that should be printedprotected void sayNow(OwnSnakeInfo oInfo, java.lang.String str)
oInfo
- OwnSnakeInfo, is required to identify the player who prints the textstr
- the string that should be printedpublic void setMonitor(C_DebugMonitor monitor)
monitor
- The monitor to set. (not very intresting for the player)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |