TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
builder.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 "cherrypi.h"
11 #include "module.h"
12 #include "state.h"
13 
14 #include <deque>
15 #include <list>
16 #include <unordered_map>
17 #include <vector>
18 
19 namespace cherrypi {
20 
21 /**
22  * Shared data among all builder controllers.
23  */
26 
28  std::deque<int> mineralsHistory;
29  std::deque<int> gasHistory;
31  double currentGasPerFrame = 0.0;
32 
33  std::unordered_map<Unit*, std::tuple<int, const BuildType*, Position>>
35 };
36 
37 /**
38  * A general-purpose unit production module.
39  *
40  * This module consumes a Create UPC with a sharp createType and attempts to
41  * create it. Units are optional; by default, an appropriate and not-so-busy
42  * worker or producer will be selected. Positions are required for buildings
43  * that need to be placed by a worker unit.
44  *
45  * A build task will be created for every UPC consumed, regardless of current
46  * resources, and it will continually be attempted to be built. The exception is
47  * that tasks fail if a building that needed to be placed by a worker unit was
48  * requested but the desired build location is no longer valid. Units will be
49  * created in the order UPCs are consumed, unless we have spare resources which
50  * may allow later UPCs to be fulfilled first.
51  */
52 class BuilderModule : public Module {
53  public:
55  virtual ~BuilderModule() = default;
56 
57  virtual void step(State* s) override;
58 
59  // TODO: Get rid of remaining module state.
60  std::shared_ptr<BuilderControllerData> bcdata_;
61 };
62 
63 } // namespace cherrypi
double currentGasPerFrame
Definition: builder.h:31
Game state.
Definition: state.h:42
BuilderModule()
Definition: builder.h:54
Shared data among all builder controllers.
Definition: builder.h:24
tc::Resources res
Definition: builder.h:25
std::deque< int > gasHistory
Definition: builder.h:29
std::deque< int > mineralsHistory
Definition: builder.h:28
Definition: frame.h:166
std::unordered_map< Unit *, std::tuple< int, const BuildType *, Position > > recentAssignedBuilders
Definition: builder.h:34
int lastIncomeHistoryUpdate
Definition: builder.h:27
double currentMineralsPerFrame
Definition: builder.h:30
A general-purpose unit production module.
Definition: builder.h:52
std::shared_ptr< BuilderControllerData > bcdata_
Definition: builder.h:60
Main namespace for bot-related code.
Definition: areainfo.cpp:17
Interface for bot modules.
Definition: module.h:30