Package com.codingame.gameengine.core
Class AbstractPlayer
java.lang.Object
com.codingame.gameengine.core.AbstractPlayer
- Direct Known Subclasses:
AbstractMultiplayerPlayer
,AbstractSoloPlayer
The representation of the/a player's AI during the game's execution.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An Exception thrown bygetOutputs()
when the player's AI did not respond in time after anexecute()
. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
execute()
Executes the player for a maximum of turnMaxTime milliseconds and store the output.final String
Returns a string that will be converted into the real avatar by the viewer, if it exists.abstract int
Returns the number of lines that the player must return.final String
Returns a string that will be converted into the real nickname by the viewer.Gets the output obtained after an execution.final void
sendInputLine
(String line) Adds a new line to the input to send to the player on execute.
-
Field Details
-
index
protected int index
-
-
Constructor Details
-
AbstractPlayer
public AbstractPlayer()
-
-
Method Details
-
getNicknameToken
Returns a string that will be converted into the real nickname by the viewer.- Returns:
- the player's nickname token.
-
getAvatarToken
Returns a string that will be converted into the real avatar by the viewer, if it exists.- Returns:
- the player's avatar token.
-
sendInputLine
Adds a new line to the input to send to the player on execute.- Parameters:
line
- The input to send.
-
execute
public final void execute()Executes the player for a maximum of turnMaxTime milliseconds and store the output. -
getOutputs
Gets the output obtained after an execution.- Returns:
- a list of output lines
- Throws:
AbstractPlayer.TimeoutException
- if the player's AI crashes or stops responding
-
getExpectedOutputLines
public abstract int getExpectedOutputLines()Returns the number of lines that the player must return. If the player do not write that amount of lines before the timeout delay, no outputs at all will be available for this player. The game engine will not read more than the expected output lines. Extra lines will be available for next turn.- Returns:
- the expected amount of lines the player must output
-