TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
game.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 "fifopipes.h"
12 #include "gametype.h"
13 #include "openbwprocess.h"
14 #include "torchcraftclient.h"
15 
16 #include "utils/syntax.h"
17 #include <torchcraft/client.h>
18 
19 #include <memory>
20 #include <string>
21 
22 namespace cherrypi {
23 
24 class OpenBwProcess;
25 class PlayScript;
26 
28  explicit GamePlayerOptions(torchcraft::BW::Race race) : race_(race) {}
29  CPI_ARG(torchcraft::BW::Race, race);
30  CPI_ARG(std::string, name);
31 };
32 
33 struct GameOptions {
34  explicit GameOptions(std::string map) : map_(map) {}
35  CPI_ARG(std::string, map);
36  CPI_ARG(std::string, replayPath);
37  CPI_ARG(bool, forceGui) = false;
39 };
40 
42  public:
44  GameOptions const& gameOptions,
45  GamePlayerOptions const& player1,
46  GamePlayerOptions const& player2);
47  // Deprecated constructor
49  std::string const& map,
50  tc::BW::Race race1,
51  tc::BW::Race race2,
52  GameType gameType = GameType::Melee,
53  std::string const& replayPath = std::string(),
54  bool forceGui = false);
55 
56  std::shared_ptr<torchcraft::Client> makeClient1(
58  std::shared_ptr<torchcraft::Client> makeClient2(
60 
61  protected:
63  std::shared_ptr<OpenBwProcess> proc1_;
64  std::shared_ptr<OpenBwProcess> proc2_;
65 };
66 
67 /**
68  * A constructed gameplay scenario for training/testing purposes
69  *
70  * A scenario is defined by the commands that should be executed when the game
71  * starts.
72  * For example, it can spawn units, ask them to move at a certain place,...'
73  */
75  public:
77  GameOptions const& gameOptions,
78  GamePlayerOptions const& player1,
79  GamePlayerOptions const& player2 = GamePlayerOptions(tc::BW::Race::None));
81 
82  std::shared_ptr<torchcraft::Client> makeClient(
84 
85  protected:
86  std::unique_ptr<OpenBwProcess> startProcess() const;
87  std::unique_ptr<OpenBwProcess> proc_;
88  GameSinglePlayer() = default;
89 };
90 
91 // Deprecated constructors, for backward compatibility
93  std::string const& map,
94  std::string const& race,
95  bool forceGui = false);
97  std::string map,
98  std::string myRace,
99  std::string enemyRace = std::string(),
100  bool forceGui = false);
101 } // namespace cherrypi
GamePlayerOptions(torchcraft::BW::Race race)
Definition: game.h:28
A constructed gameplay scenario for training/testing purposes.
Definition: game.h:74
GameType
Definition: gametype.h:12
std::shared_ptr< OpenBwProcess > proc2_
Definition: game.h:64
std::shared_ptr< OpenBwProcess > proc1_
Definition: game.h:63
CPI_ARG(torchcraft::BW::Race, race)
Definition: fifopipes.h:14
GameSinglePlayer GameSinglePlayerMelee(std::string map, std::string myRace, std::string enemyRace=std::string(), bool forceGui=false)
Definition: gamesingleplayer.cpp:68
Definition: game.h:33
Definition: game.h:27
GameOptions(std::string map)
Definition: game.h:34
GameSinglePlayer GameSinglePlayerUMS(std::string const &map, std::string const &race, bool forceGui=false)
Definition: gamesingleplayer.cpp:60
detail::FifoPipes pipes_
Definition: game.h:62
Definition: client.h:27
Main namespace for bot-related code.
Definition: areainfo.cpp:17
std::unique_ptr< OpenBwProcess > proc_
Definition: game.h:87
Definition: game.h:41