TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
gathererc.h
1 /*
2  * Copyright (c) 2017-present, Facebook, Inc.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #pragma once
9 
10 #include "controller.h"
11 #include "modules/gatherer/gathererassignments.h"
12 
13 namespace cherrypi {
14 
15 /**
16  * Controls gathering workers for GathererModule.
17  * - Bookkeeping for SharedController lives in gathererc.cpp
18  * - Micromanagement and worker defense lives in gatherermicro.cpp
19  */
21  public:
22  using SharedController::SharedController;
23 
24  virtual void addUnit(State*, Unit* worker, UpcId) override;
25  virtual void removeUnit(State*, Unit* worker, UpcId) override;
26  virtual bool keepUnit(State*, Unit* worker) const override;
27  virtual void step(State*) override;
28  virtual const char* getName() const override {
29  return "Gatherer";
30  };
31 
32  protected:
34  std::vector<Unit*> proxyBuilders;
35  std::vector<Unit*> proxies;
36  std::vector<Unit*> invaders;
37  std::vector<Unit*> bastions;
38 
39  /// True if we have ever been proxied (an enemy attempted to build structures
40  /// in or near our base
41  bool wasProxied = false;
42 
43  /// Decide what to do with a worker this frame.
44  void micro(State*, Unit* worker, Unit* resource);
45 
46  void gather(State*, Unit* worker, Unit* resource, bool dropResources = false);
47  void flee(State*, Unit* worker, Unit* resource);
48  void chase(State*, Unit* worker, Unit* target);
49  void attack(State*, Unit* worker, Unit* target);
50 };
51 
52 } // namespace cherrypi
Game state.
Definition: state.h:42
virtual bool keepUnit(State *, Unit *worker) const override
Decide whether to keep a unit.
Definition: gathererc.cpp:36
virtual void removeUnit(State *, Unit *worker, UpcId) override
Remove a unit from this controller.
Definition: gathererc.cpp:30
std::vector< Unit * > invaders
Definition: gathererc.h:36
virtual void step(State *) override
Advance controller state and produce UPCs.
Definition: gatherermicro.cpp:109
void attack(State *, Unit *worker, Unit *target)
Issue a UPC to command a worker to attack a unit.
Definition: gatherermicro.cpp:522
Assigns workers to resources for optimal gathering.
Definition: gathererassignments.h:18
virtual const char * getName() const override
A name for this Controller, for debugging purposes.
Definition: gathererc.h:28
bool wasProxied
True if we have ever been proxied (an enemy attempted to build structures in or near our base...
Definition: gathererc.h:41
std::vector< Unit * > bastions
Definition: gathererc.h:37
void gather(State *, Unit *worker, Unit *resource, bool dropResources=false)
Issue a UPC to command a worker to gather a resource.
Definition: gatherermicro.cpp:452
Represents a unit in the game.
Definition: unitsinfo.h:35
void flee(State *, Unit *worker, Unit *resource)
Issue a UPC to command a worker to flee.
Definition: gatherermicro.cpp:502
std::vector< Unit * > proxies
Definition: gathererc.h:35
virtual void addUnit(State *, Unit *worker, UpcId) override
Add a unit to this controller.
Definition: gathererc.cpp:21
Controls gathering workers for GathererModule.
Definition: gathererc.h:20
std::vector< Unit * > proxyBuilders
Definition: gathererc.h:34
Main namespace for bot-related code.
Definition: areainfo.cpp:17
GathererAssignments assignments
Definition: gathererc.h:30
void micro(State *, Unit *worker, Unit *resource)
Decide what to do with a worker this frame.
Definition: gatherermicro.cpp:313
int UpcId
Definition: basetypes.h:23
void chase(State *, Unit *worker, Unit *target)
Issue a UPC to command a worker to chase an enemy proxy builder, to ensure that they don&#39;t do anythin...
Definition: gatherermicro.cpp:513
Base class for Controllers shared between multiple tasks.
Definition: controller.h:216