TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
cherrypi.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 // __attribute__((unused)) is a GCC-specific feature
11 #ifdef __GNUC__
12 #define ATTR_UNUSED __attribute__((unused))
13 #else
14 #define ATTR_UNUSED
15 #endif
16 
17 #include "basetypes.h"
18 #include "registry.h"
19 
20 #include <torchcraft/state.h>
21 
22 #include <chrono>
23 #include <string>
24 
25 /*** FOR PARAMETER OPTIMIZATION */
26 #define DFOASG(mean, var) \
27  mean // this is a gaussian with given mean and variance
28 
29 /**
30  * Main namespace for bot-related code.
31  */
32 namespace cherrypi {
33 
34 namespace tc = ::torchcraft;
35 
36 using Duration = std::chrono::nanoseconds;
37 // We want a steady high-resolution clock (ideally with sub-ms precision)
38 // TODO: Use a different clock on systems where steady_clock's resolution is
39 // too low (VS2013?)
40 using hires_clock = std::chrono::steady_clock;
41 
42 void init(int64_t randomSeed);
43 void init();
44 // Needs to be called manually
45 void initLogging(
46  const char* execName,
47  std::string logSinkDir,
48  bool logSinkToStderr);
49 // Called by init(); a noop on non-POSIX systems
51 void shutdown(bool logSinkToStderr);
52 
53 /// Set a frame number to prefix log messages with
54 void setLoggingFrame(int frame);
55 
56 /// Reset the frame number for log messages
57 void unsetLoggingFrame();
58 
59 } // namespace cherrypi
Copyright (c) 2015-present, Facebook, Inc.
Definition: openbwprocess.h:17
void setLoggingFrame(int frame)
Set a frame number to prefix log messages with.
Definition: cherrypi.cpp:374
std::chrono::nanoseconds Duration
Definition: cherrypi.h:36
void initLogging(const char *execName, std::string logSinkDir, bool logSinkToStderr)
Definition: cherrypi.cpp:343
std::chrono::steady_clock hires_clock
Definition: cherrypi.h:40
void installSignalHandlers()
Definition: cherrypi.cpp:321
void unsetLoggingFrame()
Reset the frame number for log messages.
Definition: cherrypi.cpp:378
void shutdown(bool logSinkToStderr)
Definition: cherrypi.cpp:364
Main namespace for bot-related code.
Definition: areainfo.cpp:17
void init(int64_t randomSeed)
Definition: cherrypi.cpp:293