TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
playscript.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 "forkserver.h"
11 
12 #include <memory>
13 #include <string>
14 #include <vector>
15 
16 namespace torchcraft {
17 class Client;
18 }
19 
20 namespace cherrypi {
21 
22 /*
23  * Manages a series of games against opponent, cycling through maps.
24  * This will create files on the local filesystem (check the play script)!
25  * These files are not deleted.
26  * The bot play script is external.
27  */
28 class PlayScript {
29  public:
30  PlayScript(
31  std::vector<EnvVar> const& vars,
32  std::string script = "/workspace/scripts/ladder/play");
33  ~PlayScript();
34 
35  /// Connect a TorchCraft client to this instance.
36  /// Returns whether the client connected successfully connected.
37  /// Note that this function can be called multiple times. After
38  /// a game ends, it can be called again to start and connect to
39  /// the next game in the series.
40  bool connect(torchcraft::Client* client, int timeoutMs = -1);
41 
42  private:
43  int waitReadyPipeFd_ = 0;
44  int waitPipeFd_ = 0;
45  int readPipeFd_ = 0;
46 
47  int nConnects_ = 0;
48 
49  int scriptPid_ = 0;
50  int termPid_ = 0;
51  int termPipeFd_ = 0;
52 };
53 
54 } // namespace cherrypi
Copyright (c) 2015-present, Facebook, Inc.
Definition: openbwprocess.h:17
Definition: playscript.h:28
Definition: client.h:25
Main namespace for bot-related code.
Definition: areainfo.cpp:17