BWAPI
Agents/Agent.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include "defines.h"
00004 
00005 class Agent
00006 {
00007 protected:
00008         Unit* _unit;
00009         Task* _currentTask;
00010         Environment* _env;
00011 
00012         int _taskHeldFrames;
00013         int _taskActionFrame;
00014 
00015         AgentTypeSet _types;
00016 
00017         AgentDisposition _disposition;
00018 
00019         double _currentAptitude;
00020 
00021         bool _canDoSomethingElse;
00022 
00023         ProtectUnitTask* _protectUnitTask;
00024 
00025         Position _targetPosition;
00026         Position _lastPosition;
00027         MapSector* _sector;
00028 
00029         double _tempValue;
00030 
00031 public:
00032         static Agent* createAgent(Unit* unit, Environment* env);
00033 
00034         static AgentMap filterMap(AgentMap* agents, AgentType type, bool finished = true);
00035         static AgentMap filterMap(AgentMap* agents, UnitType type, bool finished = true);
00036         static AgentMap filterMap(AgentMap* agents, TaskType type, bool finished = true);
00037         
00038         static Agent* closestAgent(AgentMap* agents, AgentType type, Position pos);
00039         static Agent* closestAgent(AgentMap* agents, UnitType type, Position pos);
00040         static Agent* closestAgent(AgentMap* agents, TaskType type, Position pos);
00041 
00042         Agent(Unit* unit, Environment* env);
00043         virtual ~Agent(void);
00044 
00045         bool isType(AgentType);
00046 
00047         virtual void initialize();
00048         virtual void refresh();
00049 
00050         Unit* getUnit();
00051         UnitType getUnitType();
00052         Position getUnitPosition();
00053 
00054         Position getTargetPosition();
00055         void setTargetPosition(Position pos);
00056 
00057         bool canAttackAir();
00058         bool canAttackGround();
00059 
00060         int getAirWeaponDamage();
00061         int getGroundWeaponDamage();
00062 
00063         int getAirWeaponRange();
00064         int getGroundWeaponRange();
00065 
00066         ProtectUnitTask* getProtectUnitTask();
00067         void setProtectUnitTask(ProtectUnitTask* task);
00068 
00069         UnitSet getEnemiesInRange(int range);
00070         UnitSet getEnemiesInRangeAirAttack();
00071         UnitSet getEnemiesInRangeGroundAttack(bool sieged = false);
00072         
00073         Unit* getBestTargetInRange(int range, bool ignoreUnarmed = true);
00074         Unit* getBestTargetInAttackRange(bool ignoreUnarmed = true, bool sieged = false);
00075 
00076         void assignTask(Task* task);
00077         //void removeDeletedTask();
00078         Task* getCurrentTask();
00079         bool isCurrentTaskType(TaskType type);
00080 
00081         int getTaskHeldTime();
00082 
00083         bool isFinished();
00084 
00085         void step();
00086         virtual void executeUnitBehavior();
00087 
00088         void setDisposition(AgentDisposition disposition);
00089         AgentDisposition getDisposition();
00090 
00091         void setCurrentAptitude(double aptitude);
00092         double getCurrentAptitude();
00093 
00094         void setTempValue(double value);
00095         double getTempValue();
00096 
00097         void setSector(MapSector* sector);
00098         MapSector* getSector();
00099 
00100         virtual void cleanup();
00101 
00102         virtual void displayInfo(int &row);
00103 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines