TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
upcs.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 <memory>
11 
12 #include "upc.h"
13 
14 namespace cherrypi {
15 namespace utils {
16 
17 inline auto makeSharpUPC(Unit* u, Command c) {
18  auto upc = std::make_shared<UPCTuple>();
19  upc->unit[u] = 1;
20  upc->command[c] = 1;
21  return upc;
22 }
23 inline auto makeSharpUPC(Unit* u, Position p, Command c) {
24  auto upc = std::make_shared<UPCTuple>();
25  upc->unit[u] = 1;
26  upc->position = p;
27  upc->command[c] = 1;
28  return upc;
29 }
30 inline auto makeSharpUPC(Unit* u, Unit* p, Command c) {
31  auto upc = std::make_shared<UPCTuple>();
32  upc->unit[u] = 1;
33  upc->position = UPCTuple::UnitMap{{p, 1}};
34  upc->command[c] = 1;
35  return upc;
36 }
37 inline auto makeSharpUPC(Unit* u, Position p, Command c, BuildType const* ct) {
38  auto upc = std::make_shared<UPCTuple>();
39  upc->unit[u] = 1;
40  upc->position = p;
41  upc->command[c] = 1;
42  upc->state = UPCTuple::BuildTypeMap{{ct, 1}};
43  return upc;
44 }
45 inline auto makeSharpUPC(Unit* u, Unit* p, Command c, BuildType const* ct) {
46  auto upc = std::make_shared<UPCTuple>();
47  upc->unit[u] = 1;
48  upc->position = UPCTuple::UnitMap{{p, 1}};
49  upc->command[c] = 1;
50  upc->state = UPCTuple::BuildTypeMap{{ct, 1}};
51  return upc;
52 }
53 inline auto makeSharpUPC(UPCTuple& other_upc, Unit* u, Command c) {
54  auto upc = std::make_shared<UPCTuple>(other_upc);
55  upc->unit[u] = 1;
56  upc->command[c] = 1;
57  return upc;
58 }
59 
60 } // namespace utils
61 } // namespace cherrypi
Command
Abstract "meta" commands for UPCTuples.
Definition: basetypes.h:314
Represents and holds information about buildable types (units, upgrades, techs).
Definition: buildtype.h:36
std::unordered_map< BuildType const *, float > BuildTypeMap
Definition: upc.h:48
(Unit, Position, Command) tuple.
Definition: upc.h:43
Represents a unit in the game.
Definition: unitsinfo.h:35
std::unordered_map< Unit *, float > UnitMap
Definition: upc.h:46
auto makeSharpUPC(Unit *u, Command c)
Definition: upcs.h:17
Main namespace for bot-related code.
Definition: areainfo.cpp:17