BWAPI
UAlbertaBot_src/Projects/UAlbertaBot/Source/base/WorkerData.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include "Common.h"
00004 
00005 class WorkerMoveData
00006 {
00007 public:
00008 
00009         int mineralsNeeded;
00010         int gasNeeded;
00011         BWAPI::Position position;
00012 
00013         WorkerMoveData(int m, int g, BWAPI::Position p)
00014         {
00015                 mineralsNeeded = m;
00016                 gasNeeded = g;
00017                 position = p;
00018         }
00019 
00020         WorkerMoveData() {}
00021 };
00022 
00023 class WorkerData 
00024 {
00025 
00026 public:
00027 
00028         enum WorkerJob {Minerals, Gas, Build, Combat, Idle, Repair, Move, Scout, Default};
00029 
00030 private:
00031 
00032         std::set<BWAPI::Unit *>                                                 workers;
00033         std::set<BWAPI::Unit *>                                                 depots;
00034 
00035         std::map<BWAPI::Unit *, enum WorkerJob>                 workerJobMap;
00036         std::map<BWAPI::Unit *, BWAPI::Unit *>                  workerMineralMap;
00037         std::map<BWAPI::Unit *, BWAPI::Unit *>                  workerDepotMap;
00038         std::map<BWAPI::Unit *, BWAPI::Unit *>                  workerRefineryMap;
00039         std::map<BWAPI::Unit *, BWAPI::Unit *>                  workerRepairMap;
00040         std::map<BWAPI::Unit *, WorkerMoveData>                 workerMoveMap;
00041         std::map<BWAPI::Unit *, BWAPI::UnitType>                workerBuildingTypeMap;
00042 
00043         std::map<BWAPI::Unit *, int>                                    depotWorkerCount;
00044         std::map<BWAPI::Unit *, int>                                    refineryWorkerCount;
00045 
00046         void                                                                                    clearPreviousJob(BWAPI::Unit * unit);
00047 
00048 public:
00049 
00050         WorkerData();
00051 
00052         void                                    workerDestroyed(BWAPI::Unit * unit);
00053         void                                    addDepot(BWAPI::Unit * unit);
00054         void                                    removeDepot(BWAPI::Unit * unit);
00055         void                                    addWorker(BWAPI::Unit * unit);
00056         void                                    addWorker(BWAPI::Unit * unit, WorkerJob job, BWAPI::Unit * jobUnit);
00057         void                                    addWorker(BWAPI::Unit * unit, WorkerJob job, BWAPI::UnitType jobUnitType);
00058         void                                    setWorkerJob(BWAPI::Unit * unit, WorkerJob job, BWAPI::Unit * jobUnit);
00059         void                                    setWorkerJob(BWAPI::Unit * unit, WorkerJob job, WorkerMoveData wmd);
00060         void                                    setWorkerJob(BWAPI::Unit * unit, WorkerJob job, BWAPI::UnitType jobUnitType);
00061 
00062         int                                             getNumWorkers();
00063         int                                             getNumMineralWorkers();
00064         int                                             getNumGasWorkers();
00065         int                                             getNumIdleWorkers();
00066         char                                    getJobCode(BWAPI::Unit * unit);
00067 
00068         void                                    getMineralWorkers(std::set<BWAPI::Unit *> & mw);
00069         void                                    getGasWorkers(std::set<BWAPI::Unit *> & mw);
00070         void                                    getBuildingWorkers(std::set<BWAPI::Unit *> & mw);
00071         void                                    getRepairWorkers(std::set<BWAPI::Unit *> & mw);
00072         
00073         bool                                    depotIsFull(BWAPI::Unit * depot);
00074         int                                             getMineralsNearDepot(BWAPI::Unit * depot);
00075 
00076         int                                             getNumAssignedWorkers(BWAPI::Unit * unit);
00077         BWAPI::Unit *                   getMineralToMine(BWAPI::Unit * worker);
00078 
00079         enum WorkerJob                  getWorkerJob(BWAPI::Unit * unit);
00080         BWAPI::Unit *                   getWorkerResource(BWAPI::Unit * unit);
00081         BWAPI::Unit *                   getWorkerDepot(BWAPI::Unit * unit);
00082         BWAPI::Unit *                   getWorkerRepairUnit(BWAPI::Unit * unit);
00083         BWAPI::UnitType                 getWorkerBuildingType(BWAPI::Unit * unit);
00084         WorkerMoveData                  getWorkerMoveData(BWAPI::Unit * unit);
00085 
00086         void                                    drawDepotDebugInfo();
00087 
00088         const std::set<BWAPI::Unit *> & getWorkers() const { return workers; }
00089 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines