TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
player.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 <condition_variable>
11 #include <mutex>
12 #include <thread>
13 #include <vector>
14 
15 #include "baseplayer.h"
16 #include "cherrypi.h"
17 #include "module.h"
18 #include "state.h"
19 
20 namespace cherrypi {
21 
22 /**
23  * The main bot object for complete games of StarCraft.
24  *
25  * This class is used to play StarCraft Broodwar (TM) via the TorchCraft bridge.
26  * The behavior and actions of the player are determined by a user-supplied list
27  * of bot modules.
28  */
29 class Player : public BasePlayer {
30  using ClientCommands = std::vector<tc::Client::Command>;
31 
32  public:
33  Player(std::shared_ptr<tc::Client> client);
34  Player(const Player&) = delete;
35  Player& operator=(const Player&) = delete;
36 
37  /// UI update frequency of Broodwar instance. Set this before calling init().
38  void setFrameskip(int n);
39  /// Combine n server-side frames before taking any action.
40  /// Set this before calling init().
41  void setCombineFrames(int n);
42  /// Run bot step in separate thread to prevent blocking game execution.
43  /// Defaults to false.
44  void setNonBlocking(bool nonBlocking);
45 
46  void setMapHack(bool on) {
47  mapHack_ = on;
48  }
49 
50  virtual void init() override;
51  void run();
52 
53  private:
54  bool mapHack_ = false;
55 };
56 
57 } // namespace cherrypi
Player(std::shared_ptr< tc::Client > client)
Definition: player.cpp:22
void setCombineFrames(int n)
Combine n server-side frames before taking any action.
Definition: player.cpp:31
Player & operator=(const Player &)=delete
The main bot object.
Definition: baseplayer.h:28
void setFrameskip(int n)
UI update frequency of Broodwar instance. Set this before calling init().
Definition: player.cpp:24
void setMapHack(bool on)
Definition: player.h:46
virtual void init() override
Definition: player.cpp:45
void run()
Definition: player.cpp:84
void setNonBlocking(bool nonBlocking)
Run bot step in separate thread to prevent blocking game execution.
Definition: player.cpp:38
Main namespace for bot-related code.
Definition: areainfo.cpp:17
The main bot object for complete games of StarCraft.
Definition: player.h:29