TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
upctocommand.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 <set>
11 #include <vector>
12 
13 #include "module.h"
14 #include "unitsinfo.h"
15 
16 namespace cherrypi {
17 
18 /**
19  * The last module run in each frame.
20  * Consumes all remaining unambiguous (sharp) UPCs and issues BWAPI commands
21  * via TorchCraft.
22  */
23 class UPCToCommandModule : public Module {
24  public:
26  virtual ~UPCToCommandModule() = default;
27 
28  virtual void step(State* s);
29 
30  private:
31  struct UPCToCommandState {
32  std::set<const Unit*> commandToUnit;
33  std::vector<tc::Client::Command> commands;
34  std::vector<int> upcIds;
35  };
36 
37  void checkDuplicateCommand(
38  State* state,
39  const Unit*,
40  UpcId newUpcId,
41  UPCToCommandState&);
42  void registerCommand(
43  State*,
44  const Unit*,
45  UpcId,
46  tc::Client::Command,
47  UPCToCommandState&);
48  void stepUPC(State*, UPCToCommandState&, UpcId, UPCTuple* const);
49  void postGameCommand(State*, UPCToCommandState&);
50  void temporaryDebugDrawing(State*, UPCToCommandState&);
51 };
52 
53 } // namespace cherrypi
Game state.
Definition: state.h:42
UPCToCommandModule()
Definition: upctocommand.h:25
(Unit, Position, Command) tuple.
Definition: upc.h:43
virtual ~UPCToCommandModule()=default
Represents a unit in the game.
Definition: unitsinfo.h:35
virtual void step(State *s)
Definition: upctocommand.cpp:252
The last module run in each frame.
Definition: upctocommand.h:23
Main namespace for bot-related code.
Definition: areainfo.cpp:17
int UpcId
Definition: basetypes.h:23
Interface for bot modules.
Definition: module.h:30