|
TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
An Agent represents the micromanagement state of one of our units. More...
#include <agent.h>
Public Member Functions | |
| std::shared_ptr< UPCTuple > | microDelete () |
| Hand control of the unit over to the Agent for fighting. More... | |
| std::shared_ptr< UPCTuple > | microFlee () |
| Hand control of the unit over to the Agent for fleeing. More... | |
| void | postCommand (tc::BW::UnitCommandType command) |
| Issues a command to the Agent's unit by posting it to the Blackboard. More... | |
| std::shared_ptr< UPCTuple > | attack (Position const &pos) |
| Convenience method for issuing an attack-move UPC. More... | |
| std::shared_ptr< UPCTuple > | attack (Unit *u) |
| Convenience method for issuing an attack-unit UPC. More... | |
| std::shared_ptr< UPCTuple > | moveTo (Position pos, bool protect=true) |
| Convenience method for issuing a move UPC. More... | |
| std::shared_ptr< UPCTuple > | moveTo (Vec2 pos, bool protect=true) |
| Convenience method for issuing a move UPC. More... | |
| std::shared_ptr< UPCTuple > | filterMove (const movefilters::PositionFilters &pfs) |
| Convenience method for issuing a move UPC using movefilters. More... | |
| std::shared_ptr< UPCTuple > | smartMove (const Position &tgt) |
| Convenience method for issuing a threat-aware move UPC. More... | |
| std::shared_ptr< UPCTuple > | smartMove (Unit *tgt) |
| Convenience method for issuing a threat-aware move UPC. More... | |
| std::shared_ptr< UPCTuple > | tryCastSpellOnUnit (const BuildType *spell, std::function< double(Unit *const)> scoring, double minimumScore) |
| Attempt to cast a spell targeting a unit. More... | |
| std::shared_ptr< UPCTuple > | tryCastSpellOnArea (const BuildType *spell, double areaWidth, double areaHeight, std::function< double(Unit *const)> scoring, double minimumScore, std::function< Position(Position input)> positionTransform=[](auto p){return p;}) |
| Attempt to cast a spell targeting an area. More... | |
Public Attributes | |
| SquadTask * | task |
| To what squad does this unit belong? More... | |
| Unit * | unit |
| What unit is this Agent controlling? More... | |
| State * | state |
| The current game state. More... | |
| std::shared_ptr< Behavior > | behaviorDelete |
| Behaviors to perform when receiving a Delete UPC. More... | |
| std::shared_ptr< Behavior > | behaviorFlee |
| Behaviors to perform when receiving a Flee UPC. More... | |
| MicroAction | currentAction |
| What action has been selected for this unit by a Behavior? More... | |
| std::vector< Unit * > | legalTargets |
| Who is this unit intended to fight? More... | |
| Unit * | target = nullptr |
| Who has this unit decided to kill? More... | |
| bool | targetInRange = false |
| Is the target in range right now? This accounts for latency and unit/target velocities. More... | |
| bool | prevTargetInRange = false |
| Unit * | attacking = nullptr |
| Tracks the last target this unit was commanded to attack. More... | |
| bool | wantsToFight = false |
| Has this unit joined the vanguard of its squad? Or is it on the way? More... | |
| int | lastMicroFrame = -1 |
| On what frame was this unit last micromanaged? More... | |
| int | lastTarget = -1 |
| On what frame did this unit last choose a target? More... | |
| int | lastMove = -1 |
| On what frame did this unit start moving? -1 when the unit is attacking, rather than moving. More... | |
| int | lastAttack = -1 |
| On what frame did this unit start attacking? -1 when the unit is not attacking. More... | |
| Position | lastMoveTo |
| If we attempted to move the unit, the last position to which we attempted to move it. More... | |
| Position | lastPosition |
| The unit's position last time we micromanaged it. More... | |
| int | stuckFrames = 0 |
| How many consecutive frames has this unit been inadvertently idle? More... | |
| int | mutaliskTurning = 0 |
| Is this unit a Mutalisk turning to face a Scourge? Used to apply the triangle method for kiting Scourge with Mutalisks. More... | |
| Position | formationPosition = kInvalidPosition |
| SquadTask organizes its units into a formation for attacking. More... | |
| int | formationCounter = 0 |
| Used by SquadTask in calculating formations. More... | |
Static Public Attributes | |
| static constexpr int | unstickTriggerFrames = 9 |
| How many frames of being stuck before we attempt to un-stick a unit. More... | |
Protected Member Functions | |
| void | preMicro () |
| Prepare the unit for micro. More... | |
An Agent represents the micromanagement state of one of our units.
Agents belong to a SquadTask, which invokes microFlee() or microDelete().
From there, the Agent, will forward control to a series of Behaviors, each of which is given the opportunity to do one of the following:
Convenience method for issuing an attack-move UPC.
Convenience method for issuing an attack-unit UPC.
| std::shared_ptr< UPCTuple > cherrypi::Agent::filterMove | ( | const movefilters::PositionFilters & | pfs | ) |
Convenience method for issuing a move UPC using movefilters.
| std::shared_ptr< UPCTuple > cherrypi::Agent::microDelete | ( | ) |
Hand control of the unit over to the Agent for fighting.
| std::shared_ptr< UPCTuple > cherrypi::Agent::microFlee | ( | ) |
Hand control of the unit over to the Agent for fleeing.
Convenience method for issuing a move UPC.
Convenience method for issuing a move UPC.
| void cherrypi::Agent::postCommand | ( | tc::BW::UnitCommandType | command | ) |
Issues a command to the Agent's unit by posting it to the Blackboard.
|
protected |
Prepare the unit for micro.
Convenience method for issuing a threat-aware move UPC.
Convenience method for issuing a threat-aware move UPC.
| std::shared_ptr< UPCTuple > cherrypi::Agent::tryCastSpellOnArea | ( | const BuildType * | spell, |
| double | areaWidth, | ||
| double | areaHeight, | ||
| std::function< double(Unit *const)> | scoring, | ||
| double | minimumScore, | ||
| std::function< Position(Position input)> | positionTransform = [](auto p) { return p; } |
||
| ) |
Attempt to cast a spell targeting an area.
Returns a UPC if an acceptable target was found; null otherwise.
| std::shared_ptr< UPCTuple > cherrypi::Agent::tryCastSpellOnUnit | ( | const BuildType * | spell, |
| std::function< double(Unit *const)> | scoring, | ||
| double | minimumScore | ||
| ) |
Attempt to cast a spell targeting a unit.
Returns a UPC if an acceptable target was found; null otherwise.
| Unit* cherrypi::Agent::attacking = nullptr |
Tracks the last target this unit was commanded to attack.
| std::shared_ptr<Behavior> cherrypi::Agent::behaviorDelete |
Behaviors to perform when receiving a Delete UPC.
| std::shared_ptr<Behavior> cherrypi::Agent::behaviorFlee |
Behaviors to perform when receiving a Flee UPC.
| MicroAction cherrypi::Agent::currentAction |
What action has been selected for this unit by a Behavior?
| int cherrypi::Agent::formationCounter = 0 |
Used by SquadTask in calculating formations.
| Position cherrypi::Agent::formationPosition = kInvalidPosition |
| int cherrypi::Agent::lastAttack = -1 |
On what frame did this unit start attacking? -1 when the unit is not attacking.
| int cherrypi::Agent::lastMicroFrame = -1 |
On what frame was this unit last micromanaged?
| int cherrypi::Agent::lastMove = -1 |
On what frame did this unit start moving? -1 when the unit is attacking, rather than moving.
| Position cherrypi::Agent::lastMoveTo |
If we attempted to move the unit, the last position to which we attempted to move it.
| Position cherrypi::Agent::lastPosition |
The unit's position last time we micromanaged it.
| int cherrypi::Agent::lastTarget = -1 |
On what frame did this unit last choose a target?
| std::vector<Unit*> cherrypi::Agent::legalTargets |
Who is this unit intended to fight?
| int cherrypi::Agent::mutaliskTurning = 0 |
Is this unit a Mutalisk turning to face a Scourge? Used to apply the triangle method for kiting Scourge with Mutalisks.
| bool cherrypi::Agent::prevTargetInRange = false |
| State* cherrypi::Agent::state |
The current game state.
| int cherrypi::Agent::stuckFrames = 0 |
How many consecutive frames has this unit been inadvertently idle?
| Unit* cherrypi::Agent::target = nullptr |
Who has this unit decided to kill?
| bool cherrypi::Agent::targetInRange = false |
Is the target in range right now? This accounts for latency and unit/target velocities.
| SquadTask* cherrypi::Agent::task |
To what squad does this unit belong?
|
static |
How many frames of being stuck before we attempt to un-stick a unit.
| bool cherrypi::Agent::wantsToFight = false |
Has this unit joined the vanguard of its squad? Or is it on the way?
1.8.11