#include <unitSimulation.h>
Inheritance diagram for unitSimulation:
Public Member Functions | |
unitSimulation (mapAbstraction *, bool keepStats=false) | |
construct a unit simulation. | |
virtual | ~unitSimulation () |
delete a unit simulation. | |
bool | saveHistory (char *, bool includeMap=true) |
bool | loadHistory (char *) |
Load a history file into the simulation. | |
virtual void | addUnit (unit *) |
add a unit to the simulation. | |
virtual void | addUnit (unit *, bool block) |
add a unit to the simulation. | |
virtual void | addUnitGroup (unitGroup *) |
Add unit group to simulation. | |
unitGroup * | getUnitGroup (int which) |
Get the nth unit group. | |
unit * | getUnit (int which) |
Get the nth unit. | |
unit * | findUnit (int x, int y) |
Find a unit in the world. | |
bool | setIgnoreOnTarget (unit *, bool) |
Set ignoreOnTatget status of nth unit. | |
virtual void | advanceTime (double amount) |
advance time in the simulation. | |
void | setRealTime (bool) |
Determines whether the simulation strives to run in "real" time or be more accurate. | |
bool | getRealTime () |
void | setLockstepTime (bool b) |
bool | getLockstepTime () |
void | setAsynchronous () |
Set if the simulation is asynchronous. | |
void | setSynchronous () |
void | setSimulationPaused (bool val) |
bool | getSimulationPaused () |
double | getSimulationTime () |
return the current inside the simulation | |
double | getDisplayTime () |
return the current time being drawn | |
void | setDisplayTime (double val) |
Set the time currently displayed. | |
void | offsetDisplayTime (double val) |
Offset the display time. | |
void | openGLDraw () |
void | print (bool forceOutput=true) |
virtual bool | done () |
done returns true when all units/groups say they are done. | |
bool | nodeOccupied (node *currNode) |
reservationProvider interface | |
bool | tileOccupied (int x, int y) |
virtual bool | canMove (node *, node *, double, unit *) |
virtual bool | reserveMove (node *, node *, double, unit *) |
virtual bool | clearMove (node *, node *, double, unit *) |
virtual void | clearAllReservations () |
void | clearAllUnits () |
clear all units in simulation. | |
void | setUseBlocking (bool val) |
turns unit blocking on and off | |
void | setmapAbstractionDisplay (int _whichMap=kUnitSimulationMap) |
Set which map is returned from getMapAbstraction. | |
int | getDisplayMapNumber () |
Return which map is being currently displayed. | |
Map * | getMap () |
Returns the underlying map. | |
mapAbstraction * | getMapAbstraction () |
Returns the abstract map from the simulation. | |
mapAbstraction * | getMapAbstraction (int _which) |
Returns the nth groups abstract map. | |
mapAbstraction * | getMapAbstractionDisplay () |
Returns the abstract map currently being displayed. | |
void | cyclemapAbstractionDisplay () |
Cycle which abstract map should be displayed. | |
void | setPenalty (double pen) |
setPenalty for thinking. | |
double | getPenalty () |
getPenalty for thinking. | |
void | toggleNoOpenGLDraw () |
Toggle open GL display. | |
void | setMoveStochasticity (double _stochasticity) |
set chance for move failing. | |
double | getMoveStochasticity () |
statCollection * | getStats () |
void | printCollectedStats (bool v) |
void | getRandomLocation (int &x, int &y, tTerrain terrain=kGround) |
void | getRandomLocation (int x1, int y1, int &x2, int &y2, tTerrain terrain=kGround) |
Get random location which is guaranteed to be pathable from the given location and which is not occupied by any other objects in the world so far. | |
void | getRandomLocations (int &x1, int &y1, int &x2, int &y2, tTerrain terrain=kGround) |
Get random location which is guaranteed to be pathable and which is not occupied by any other objects in the world so far. | |
bool | canCrossDiagonally () |
void | setCanCrossDiagonally (bool cross) |
Protected Member Functions | |
unitInfo * | findUnit (unit *) |
virtual void | doPreTimestepCalc () |
virtual void | doTimestepCalc () |
virtual void | doPostTimestepCalc () |
void | stepUnitTime (unitInfo *) |
step time for a single unit. | |
void | setAgentLocation (unitInfo *, bool success=false, bool timer=false) |
void | updateMap () |
bool | updatemapAbstraction () |
void | drawBlockedSquare (int x, int y) |
bool | findUnitDisplayTime (unitInfo *ui) |
Protected Attributes | |
Map * | map |
mapAbstraction * | aMap |
bitVector * | bv |
int | which_map |
int | map_width |
int | map_height |
int | map_revision |
std::vector< unitInfo * > | units |
std::vector< unitInfo * > | displayUnits |
std::vector< unitGroup * > | unitGroups |
std::priority_queue< const unitInfo *, std::vector< unitInfo * >, unitInfoCompare > | moveQ |
double | currTime |
double | viewTime |
bool | asynch |
bool | blocking |
bool | realTime |
bool | pause |
bool | lockstepTime |
double | penalty |
double | stochasticity |
bool | unitsMoved |
bool | disallowDiagonalCrossingMoves |
double | currDist |
bool | noOpenGLDraw |
bool | keepHistory |
statCollection | stats |
|
construct a unit simulation. construct a unit simulation around a given map. |
|
delete a unit simulation. The unit simulation will delete all units (display and otherwise) as well as all groups that have been added to the simulation. |
|
add a unit to the simulation. Adds a unit to the simulation. You can optionally set whether this unit blocks the places where it stands, which can differ from the simulation default. If the unit's current x/y location is valid, the unit will be placed there. Otherwise it will be added to a random location on the map. If a unit is part of a group, it should be added to that group before being added to the simulation. Reimplemented in unitRaceSimulation. |
|
add a unit to the simulation. Adds a unit to the simulation. If the unit's current x/y location is valid, the unit will be placed there. Otherwise it will be added to a random location on the map. If a unit is part of a group, it should be added to that group before being added to the simulation. Reimplemented in unitRaceSimulation. |
|
Add unit group to simulation. Adds a unit group to the simulation. Unit groups are in simulation mostly for memory management and display purposes. |
|
advance time in the simulation. This is the basic function for stepping time in the simulation. The simulation will advance all units by this amount (seconds -- although really unitless) If we are in real-time mode, each unit will get one move per this time step. Otherwise, we will step units iteratively until they have all moved as often as they can in this amount of time. Once a unit returns kStay they are giving up any movement until this time step is finished. |
|
|
|
Implements reservationProvider. |
|
Implements reservationProvider. |
|
clear all units in simulation. removes and deletes all units & unit groups from the simulation. |
|
Implements reservationProvider. |
|
Cycle which abstract map should be displayed. selects the next possibile abstract map to be returned from getMapAbstraction. |
|
done returns true when all units/groups say they are done. For episodic tasks we may want to run a set number of times, or until learning converges, etc. This is a way of detecting this so we can stop the simulation or start a new episode. Reimplemented in unitRaceSimulation. |
|
|
|
Reimplemented in patUnitSimulation, and unitRaceSimulation. |
|
Reimplemented in unitRaceSimulation. |
|
|
|
|
|
Find a unit in the world. Return the unit on location x, y, if there is one. Otherwise returns NULL. |
|
|
|
Return which map is being currently displayed.
|
|
return the current time being drawn
|
|
|
|
Returns the underlying map.
Implements mapProvider. |
|
Returns the nth groups abstract map. (0 is the actual map of the world.) |
|
Returns the abstract map from the simulation.
Implements mapProvider. |
|
Returns the abstract map currently being displayed.
|
|
|
|
getPenalty for thinking. Gets the multiplier used to penalize thinking time. |
|
Get random location which is guaranteed to be pathable from the given location and which is not occupied by any other objects in the world so far.
|
|
|
|
Get random location which is guaranteed to be pathable and which is not occupied by any other objects in the world so far.
|
|
|
|
|
|
return the current inside the simulation
Implements simulationInfo. |
|
|
|
Get the nth unit.
|
|
Get the nth unit group.
|
|
Load a history file into the simulation. Returns true if the history loads. Loading a history causes all units currently in the simulation to be removed and turns the history on. |
|
reservationProvider interface
Implements reservationProvider. |
|
Offset the display time. When a history is kept, this allows you to offset the displayed time. New values for the view time below 0 will be truncated to 0. Values above the current simulation time will be set to the current simulation time. |
|
|
|
|
|
|
|
Implements reservationProvider. |
|
|
|
|
|
Set if the simulation is asynchronous.
|
|
|
|
Set the time currently displayed. When a history is kept, this allows you to shift the display to any time. Values below 0 will be truncated to 0. Values above the current simulation time will be set to the current simulation time. Ignored if history isn't being kept. |
|
Set ignoreOnTatget status of nth unit.
|
|
|
|
Set which map is returned from getMapAbstraction. if you want to view the map of one of the groups instead of the actual world, you can use thsi function to choose. The default value is the actual world map. Pass 1..n to select the 1st to nth unit group's map. |
|
set chance for move failing. This is the chance that a move will just fail. |
|
setPenalty for thinking. Sets the multiplier used to penalize thinking time. |
|
Determines whether the simulation strives to run in "real" time or be more accurate. In real-time mode each unit get a maximum of 1 move each time step, and the current time for any unit is set to the current time after any time step, so that things run more in real-time. In non-real-time mode the simulation allows units to run until they have used up all the time they are alloted. This may run as much as nx slower than real time mode, if all units are using up all their time. If a unit wants to stay, they forfeit the rest of their turn time. This has implications when units are chasing each other around, but really helps when units are sitting around doing nothing. |
|
|
|
|
|
turns unit blocking on and off
|
|
step time for a single unit. This function takes care of all the simulation details for moving a single unit, doing timing, etc. When overloading advanceTime, this function can be called for each unit that moves. |
|
|
|
Toggle open GL display.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|