18#ifndef INCLUDED_RLINTERFACE
19#define INCLUDED_RLINTERFACE
22#include "third_party/mongoose/mongoose.h"
24#include <condition_variable>
96 static void*
MgCallback(mg_event event,
struct mg_connection *conn,
const struct mg_request_info *request_info);
103 std::string
Step(std::vector<GameCommand>&& commands);
115 std::string
Evaluate(std::string&& code);
120 std::vector<std::string>
GetTemplates(
const std::vector<std::string>& names)
const;
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
Definition: Player.h:24
Implements an interface providing fundamental capabilities required for reinforcement learning (over ...
Definition: RLInterface.h:83
std::string Step(std::vector< GameCommand > &&commands)
Process commands, update the simulation by one turn.
Definition: RLInterface.cpp:73
bool TryGetGameMessage(GameMessage &msg)
Internal helper.
Definition: RLInterface.cpp:297
void ApplyMessage(const GameMessage &msg)
Process any pending messages from the RL client.
Definition: RLInterface.cpp:332
std::vector< std::string > GetTemplates(const std::vector< std::string > &names) const
Definition: RLInterface.cpp:93
mg_context * m_Context
Definition: RLInterface.h:163
ScenarioConfig m_ScenarioConfig
Definition: RLInterface.h:154
static void * MgCallback(mg_event event, struct mg_connection *conn, const struct mg_request_info *request_info)
Definition: RLInterface.cpp:111
std::mutex m_MsgLock
Definition: RLInterface.h:159
std::string m_ReturnValue
Definition: RLInterface.h:155
std::string SendGameMessage(GameMessage &&msg)
Internal helper.
Definition: RLInterface.cpp:64
std::string m_Code
Definition: RLInterface.h:161
static std::string GetRequestContent(struct mg_connection *conn)
Definition: RLInterface.cpp:282
~Interface()
Definition: RLInterface.cpp:56
void TryApplyMessage()
Non-blocking call to process any pending messages from the RL client.
Definition: RLInterface.cpp:308
std::condition_variable m_MsgApplied
Definition: RLInterface.h:160
bool m_NeedsGameState
Definition: RLInterface.h:156
std::mutex m_Lock
Definition: RLInterface.h:158
std::string GetGameState() const
Definition: RLInterface.cpp:435
Interface(const char *server_address)
Definition: RLInterface.cpp:43
bool IsGameRunning() const
Definition: RLInterface.cpp:446
GameMessage m_GameMessage
Definition: RLInterface.h:153
std::string Reset(ScenarioConfig &&scenario)
Reset the game state according to scenario, cleaning up existing games if required.
Definition: RLInterface.cpp:79
std::string Evaluate(std::string &&code)
Evaluate JS code in the engine such as applying arbitrary modifiers.
Definition: RLInterface.cpp:86
@ None
Definition: main.cpp:135
Definition: RLInterface.cpp:42
GameMessageType
Definition: RLInterface.h:44
Definition: RLInterface.h:38
int playerID
Definition: RLInterface.h:39
std::string json_cmd
Definition: RLInterface.h:40
Holds messages from the RL client to the game.
Definition: RLInterface.h:55
std::vector< GameCommand > commands
Definition: RLInterface.h:57
GameMessageType type
Definition: RLInterface.h:56
Definition: RLInterface.h:31
bool saveReplay
Definition: RLInterface.h:32
std::string content
Definition: RLInterface.h:34
player_id_t playerID
Definition: RLInterface.h:33