TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
gamevsbot.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 #include <memory>
9 #include <string>
10 
11 #include <torchcraft/client.h>
12 
13 #include "forkserver.h"
14 #include "game.h"
15 
16 #include "fifopipes.h"
17 #include "gametype.h"
18 
19 namespace cherrypi {
20 
21 class OpenBwProcess;
22 class PlayScript;
23 
24 /**
25  * Launches a game against a DLL bot using OpenBW.
26  *
27  * This scenario is backed by OpenBwProcess.
28  */
30  public:
32  std::string const& map,
33  torchcraft::BW::Race myRace,
34  std::string const& enemyBot,
35  GameType gameType = GameType::Melee,
36  std::string const& replayPath = std::string(),
37  bool forceGui = false);
38 
39  std::shared_ptr<torchcraft::Client> makeClient(
41 
42  private:
43  detail::FifoPipes pipes_;
44  std::shared_ptr<OpenBwProcess> proc1_;
45  std::shared_ptr<OpenBwProcess> proc2_;
46 };
47 
48 /**
49  * Launches a game series against a bot using StarCraft: Brood War(TM) via Wine.
50  *
51  * makeClient() can be called repeatedly to advance the series after each game.
52  *
53  * This scenario is backed by /scripts/ladder/play.
54  */
56  public:
58  std::vector<std::string> maps,
59  std::string enemyBot,
60  std::string outputPath = "playoutput",
61  std::vector<EnvVar> vars = {});
63  std::string map,
64  std::string enemyBot,
65  std::string outputPath = "playoutput",
66  std::vector<EnvVar> vars = {});
67  ~GameVsBotInWine();
68 
69  /// Construct a client to connect to a new game in the series.
70  std::shared_ptr<torchcraft::Client> makeClient(
72 
73  /// Whether to automatically delete the series path when destructing the
74  /// instance.
75  void setAutoDelete(bool autoDelete);
76 
77  /// The number of games that have been started in this series.
78  /// Calling makeClient() will increase this counter.
79  size_t numGamesStarted() const {
80  return numGamesStarted_;
81  }
82 
83  /// Path to playoutput directory for this series
84  std::string path() const {
85  return path_;
86  }
87 
88  /// Enemy bot as specified in the constructor
89  std::string enemyBot() const {
90  return enemyBot_;
91  }
92 
93  private:
94  std::shared_ptr<PlayScript> proc_;
95  std::string enemyBot_;
96  size_t numGamesStarted_ = 0;
97  std::string path_;
98  bool autoDelete_ = false;
99 };
100 
101 } // namespace cherrypi
std::shared_ptr< torchcraft::Client > makeClient(torchcraft::Client::Options opts=torchcraft::Client::Options())
Definition: gamevsbot.cpp:64
GameType
Definition: gametype.h:12
std::string path() const
Path to playoutput directory for this series.
Definition: gamevsbot.h:84
std::string enemyBot() const
Enemy bot as specified in the constructor.
Definition: gamevsbot.h:89
Launches a game series against a bot using StarCraft: Brood War(TM) via Wine.
Definition: gamevsbot.h:55
GameVsBotInOpenBW(std::string const &map, torchcraft::BW::Race myRace, std::string const &enemyBot, GameType gameType=GameType::Melee, std::string const &replayPath=std::string(), bool forceGui=false)
Definition: gamevsbot.cpp:29
Definition: fifopipes.h:14
size_t numGamesStarted() const
The number of games that have been started in this series.
Definition: gamevsbot.h:79
Launches a game against a DLL bot using OpenBW.
Definition: gamevsbot.h:29
Definition: client.h:27
Main namespace for bot-related code.
Definition: areainfo.cpp:17