public class ForwardModel extends Game
Game.Bucket
avatarLastAction, avatars, block_size, bucketList, charMapping, classConst, collisionEffects, counter, definedEffects, definedEOSEffects, eosEffects, fwdModel, gameTick, historicEvents, humanPlayer, is_stochastic, isEnded, iSubTypes, key_handler, ki, kill_list, MAX_SPRITES, nextSpriteID, no_counters, no_players, num_sprites, parameters, pathf, resources_colors, resources_limits, screenSize, shieldedEffects, singletons, size, spriteGroups, spriteOrder, templateSprites, terminations, timeEffects, wi
Constructor and Description |
---|
ForwardModel(Game a_gameState,
int playerID)
Constructor for StateObservation.
|
Modifier and Type | Method and Description |
---|---|
void |
advance(Types.ACTIONS action)
Advances the forward model using the action supplied.
|
void |
advance(Types.ACTIONS[] actions)
Advances the forward model using the actions supplied.
|
void |
buildStringLevel(java.lang.String[] levelString,
int randomSeed) |
ForwardModel |
copy()
Creates a copy of this forward model.
|
java.util.ArrayList<Types.ACTIONS> |
getAvatarActions(boolean includeNIL)
Returns the actions that are available in this game for
the avatar.
|
java.util.ArrayList<Types.ACTIONS> |
getAvatarActions(int playerID,
boolean includeNIL)
Method overloaded for multi player games.
|
int |
getAvatarHealthPoints()
Returns the health points of the avatar.
|
int |
getAvatarHealthPoints(int playerID)
Method overloaded for multi player games.
|
Types.ACTIONS |
getAvatarLastAction()
Returns the avatar's last move.
|
Types.ACTIONS |
getAvatarLastAction(int playerID)
Method overloaded for multi player games.
|
int |
getAvatarLimitHealthPoints()
Returns the limit of health points this avatar can have.
|
int |
getAvatarLimitHealthPoints(int playerID)
Method overloaded for multi player games.
|
int |
getAvatarMaxHealthPoints()
Returns the maximum amount of health points.
|
int |
getAvatarMaxHealthPoints(int playerID)
Method overloaded for multi player games.
|
Vector2d |
getAvatarOrientation()
Returns the orientation of the avatar.
|
Vector2d |
getAvatarOrientation(int playerID)
Method overloaded for multi player games.
|
Vector2d |
getAvatarPosition()
Returns the position of the avatar.
|
Vector2d |
getAvatarPosition(int playerID)
Method overloaded for multi player games.
|
java.util.HashMap<java.lang.Integer,java.lang.Integer> |
getAvatarResources()
Returns the resources in the avatar's possession.
|
java.util.HashMap<java.lang.Integer,java.lang.Integer> |
getAvatarResources(int playerID)
Method overloaded for multi player games.
|
double |
getAvatarSpeed()
Returns the speed of the avatar.
|
double |
getAvatarSpeed(int playerID)
Method overloaded for multi player games.
|
int |
getAvatarType()
Returns the avatar's type.
|
int |
getAvatarType(int playerID)
Method overloaded for multi player games.
|
java.util.TreeSet<Event> |
getEventsHistory()
Returns the list of historic events happened in this game so far.
|
java.util.ArrayList<Observation>[] |
getFromAvatarSpPositions(Vector2d refPosition)
Returns a list of observations of objects created by the avatar's actions.
|
double |
getGameScore()
Gets the game score of this state.
|
double |
getGameScore(int playerID)
Method overloaded for multi player games.
|
int |
getGameTick()
Gets the current game tick of this particular state.
|
Types.WINNER |
getGameWinner()
Indicates if there is a game winner in the current observation.
|
java.util.ArrayList<Observation>[] |
getImmovablePositions(Vector2d refPosition)
Observations of static objects in the game.
|
java.util.ArrayList<Observation>[] |
getMovablePositions(Vector2d refPosition)
Returns a list with observations of sprites that move, but are NOT NPCs.
|
Types.WINNER[] |
getMultiGameWinner()
Method overloaded for multi player games.
|
int |
getNoPlayers()
Method used to access the number of players in a game.
|
java.util.ArrayList<Observation>[] |
getNPCPositions(Vector2d refPosition)
Returns a list of observations of NPC in the game.
|
java.util.ArrayList<Observation>[][] |
getObservationGrid()
Returns a grid with all observations in the level.
|
java.util.ArrayList<Observation>[] |
getPortalsPositions(Vector2d refPosition) |
java.util.Random |
getRandomGenerator()
Returns the sampleRandom generator of this forward model.
|
java.util.ArrayList<Observation>[] |
getResourcesPositions(Vector2d refPosition) |
java.awt.Dimension |
getWorldDimension()
Returns the world dimensions, in pixels.
|
boolean |
isAvatarAlive()
Returns true if the avatar is alive
|
boolean |
isAvatarAlive(int playerID)
Method overloaded for multi player games, returns true if the avatar is still alive.
|
boolean |
isGameOver()
Indicates if the game is over or if it hasn't finished yet.
|
boolean |
isMultiGameOver()
Indicates if the game is over or if it hasn't finished yet.
|
void |
printObservationGrid()
Prints the observation grid.
|
void |
removeSpriteObservation(VGDLSprite sprite)
Removes an sprite observation.
|
void |
setNewSeed(int seed)
Sets a new seed for the forward model's random generator (creates a new object)
|
protected void |
tick()
Performs one tick for the game, calling update(this) in all sprites.
|
void |
update(Game a_gameState)
Dumps the game state into 'this' object.
|
protected void |
updateAvatars(Types.ACTIONS action,
int playerID)
Calls update(this) in avatar sprites.
|
_updateCollisionDict, abort, addShield, addSprite, addSprite, addSprite, addSprite, addTimeEffect, buildLevel, changeSpriteOrder, checkTimeOut, clearAll, clearInteractionTerminationData, createAvatars, disqualify, disqualify, eventHandling, getAvatar, getAvatar, getAvatars, getBlockSize, getCharMapping, getCollisionEffects, getDefinedEffects, getDefinedEosEffects, getEosEffects, getFullResult, getInteractionData, getMaxSprites, getMultiWinner, getNoCounters, getNumDisabledSprites, getNumSprites, getObservation, getObservationMulti, getParameters, getPath, getResourceColor, getResourceLimit, getScore, getScore, getScreenSize, getSpriteData, getSpriteGroup, getSpriteOrder, getSprites, getSubSpritesGroup, getSubTypes, getTempAvatar, getTerminationData, getTerminations, getValueCounter, getWinner, getWinner, handleResult, initForwardModel, initMulti, initSprites, killSprite, loadDefaultConstr, parseParameters, playGame, playOnlineGame, printLearningResult, printResult, reset, reverseDirection, runGame, setAvatar, setAvatar, setAvatarLastAction, setAvatarLastAction, setCharMapping, setParameters, setStochastic, terminationHandling
public ForwardModel(Game a_gameState, int playerID)
a_gameState
- public final void update(Game a_gameState)
a_gameState
- game to take the state from.public final void removeSpriteObservation(VGDLSprite sprite)
sprite
- sprite to remove.public void printObservationGrid()
public final java.util.Random getRandomGenerator()
getRandomGenerator
in class Game
public void setNewSeed(int seed)
seed
- the new seed.public int getNoPlayers()
getNoPlayers
in class Game
protected void updateAvatars(Types.ACTIONS action, int playerID)
action
- Action to be performed by the avatar for this game tick.protected void tick()
public final void advance(Types.ACTIONS action)
action
- public final void advance(Types.ACTIONS[] actions)
actions
- array of actions of all players (index in array corresponds
to playerID).public final ForwardModel copy()
public double getGameScore()
public double getGameScore(int playerID)
playerID
- ID of the player to query.public int getGameTick()
getGameTick
in class Game
public Types.WINNER getGameWinner()
public Types.WINNER[] getMultiGameWinner()
public boolean isGameOver()
isGameOver
in class Game
public boolean isMultiGameOver()
public java.awt.Dimension getWorldDimension()
public Vector2d getAvatarPosition()
public Vector2d getAvatarPosition(int playerID)
playerID
- ID of the player to query.public double getAvatarSpeed()
public double getAvatarSpeed(int playerID)
playerID
- ID of the player to query.public Vector2d getAvatarOrientation()
public Vector2d getAvatarOrientation(int playerID)
playerID
- ID of the player to query.public java.util.ArrayList<Types.ACTIONS> getAvatarActions(boolean includeNIL)
includeNIL
- true to include Types.ACTIONS.ACTION_NIL in the array of actions.public java.util.ArrayList<Types.ACTIONS> getAvatarActions(int playerID, boolean includeNIL)
playerID
- ID of the player to query.public java.util.HashMap<java.lang.Integer,java.lang.Integer> getAvatarResources()
public java.util.HashMap<java.lang.Integer,java.lang.Integer> getAvatarResources(int playerID)
playerID
- ID of the player to query.public Types.ACTIONS getAvatarLastAction()
public Types.ACTIONS getAvatarLastAction(int playerID)
playerID
- ID of the player to query.public int getAvatarType()
public int getAvatarType(int playerID)
playerID
- ID of the player to query.public int getAvatarHealthPoints()
public int getAvatarHealthPoints(int playerID)
playerID
- ID of the player to query.public int getAvatarMaxHealthPoints()
public int getAvatarMaxHealthPoints(int playerID)
playerID
- ID of the player to query.public int getAvatarLimitHealthPoints()
public int getAvatarLimitHealthPoints(int playerID)
playerID
- ID of the player to query.public boolean isAvatarAlive()
public boolean isAvatarAlive(int playerID)
playerID
- ID of the player to query.public java.util.ArrayList<Observation>[][] getObservationGrid()
public java.util.TreeSet<Event> getEventsHistory()
public java.util.ArrayList<Observation>[] getNPCPositions(Vector2d refPosition)
refPosition
- Reference position to use when sorting this array,
by ascending distance to this point.public java.util.ArrayList<Observation>[] getImmovablePositions(Vector2d refPosition)
refPosition
- Reference position to use when sorting this array,
by ascending distance to this point.public java.util.ArrayList<Observation>[] getMovablePositions(Vector2d refPosition)
refPosition
- Reference position to use when sorting this array,
by ascending distance to this point.public java.util.ArrayList<Observation>[] getResourcesPositions(Vector2d refPosition)
public java.util.ArrayList<Observation>[] getPortalsPositions(Vector2d refPosition)
public java.util.ArrayList<Observation>[] getFromAvatarSpPositions(Vector2d refPosition)
refPosition
- Reference position to use when sorting this array,
by ascending distance to this point.public void buildStringLevel(java.lang.String[] levelString, int randomSeed)
buildStringLevel
in class Game