BWAPI
BasicAIModule/include/Strategizer.h
Go to the documentation of this file.
00001 #pragma once
00002 /* 
00003  * Strategizer.h
00004  */
00005 #include "GameEvent.h"
00006 // #include "GameStateDB.h"
00007 #include "IncludeAllManagers.h"
00008 #include "Common.h"
00009 
00010 #include "TacticalBuildingPlacer.h"
00011 
00012 #include <BWAPI.h>
00013 
00014 
00015 class Strategizer
00016 {
00017 public:
00018         BuildManager      buildManager;
00019         CombatManager     combatManager;
00020         GasManager        gasManager;
00021         ProductionManager productionManager;    // TODO: remove this once BuildMgr is more complete
00022         ResourceManager   resourceManager;
00023         ScoutManager      scoutManager;
00024         SupplyManager     supplyManager;
00025 
00026 private:
00027         UnitAgentMap      unitAgentMap;
00028         AgentManagerMap   agentManagerMap;
00029 
00030         // Game State analysis
00031         // GameStateDB gsdb;
00032 
00033 public:
00034         
00035         /* Strategizer is a Singleton class, access is through it's instance method */
00036         static Strategizer& instance() { static Strategizer s; return s; }
00037 
00038         /* update - Called by AI Module for each frame */
00039         void update();
00040 
00041         /* draw - draw debug info to screen */
00042         void draw();
00043 
00044         /* onMatchStart - Called by AI Module when a new match begins */
00045         void onMatchStart();
00046 
00047     /* onMatchEnd - Called by AI Module whena  new match ends */
00048     void onMatchEnd(bool isWinner);
00049 
00050         /* onEvent - Called by EventProducer when a new event is detected */
00051         void onEvent(GameEvent& e);
00052   
00053 private:  
00054         // Strategizer is singleton, hence private ctors/assignment
00055         Strategizer() { }
00056         Strategizer(const Strategizer& other);
00057         void operator=(const Strategizer& other);
00058 
00059         // Core update() functions
00060         /* updateUnitAgentMap() - Gives an Agent to new Units, removes Agents of inactive Units */
00061         void updateUnitAgentMap();
00062 
00063         /* updateAgentManagerMap() - Reassigns Agents to Managers based on bid values */
00064         void updateAgentManagerMap();
00065 
00066         /* redistributeAgents() - Reallocate Agents to Managers, and make reassignments
00067            if they more efficiently reallocate */
00068         void redistributeAgents();
00069 
00070         /* updateManagers() - Calls each Manager's update() method */
00071         void updateManagers();
00072 
00073         // Utility
00074         /* remap - Remap a unit of type @type from @src to @dst */
00075         bool remap(BWAPI::UnitType type, Manager &src, Manager &dst);
00076 
00077     /* checkForfeit - Checks to see if we can't win and should just forfeit the match */
00078     bool checkForfeit();
00079 };
00080 
00081 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines