Commit e074f351 authored by Matthew Hausknecht's avatar Matthew Hausknecht

Fix for elog missing issue.

parent ec2fa47f
......@@ -4,6 +4,8 @@ project(hfo)
# Change these to reflect the location of your librcsc-4.1.0 install
set(LIBRCSC_INCLUDE ~/.local/include)
set(LIBRCSC_LINK ~/.local/lib)
# Add this definition if using Librcsc from https://github.com/mhauskn/librcsc
# add_definitions(-DELOG)
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
......
......@@ -137,8 +137,7 @@ Agent::Agent()
M_action_generator(createActionGenerator()),
lastTrainerMessageTime(-1),
server_port(6008),
server_running(false),
record(false)
server_running(false)
{
boost::shared_ptr< AudioMemory > audio_memory( new AudioMemory );
......@@ -202,25 +201,35 @@ bool Agent::initImpl(CmdLineParser & cmd_parser) {
int numTeammates, numOpponents;
bool playingOffense;
rcsc::ParamMap my_params("Additional options");
my_params.add()("numTeammates", "", &numTeammates, "number of teammates");
my_params.add()("numOpponents", "", &numOpponents, "number of opponents");
my_params.add()("playingOffense", "", &playingOffense,
"are we playing offense or defense");
my_params.add()("serverPort", "", &server_port, "Port to start server on");
record = cmd_parser.count("record") > 0;
my_params.add()
("numTeammates", "", &numTeammates)
("numOpponents", "", &numOpponents)
("playingOffense", "", &playingOffense)
("serverPort", "", &server_port);
cmd_parser.parse(my_params);
if (cmd_parser.count("help") > 0) {
my_params.printHelp( std::cout );
my_params.printHelp(std::cout);
return false;
}
if (cmd_parser.failed()) {
std::cerr << "player: ***WARNING*** detected unsuppprted options: ";
cmd_parser.print( std::cerr );
std::cerr << std::endl;
}
#ifdef ELOG
#else
const std::list<std::string>& args = cmd_parser.args();
if (std::find(args.begin(), args.end(), "--record") != args.end()) {
std::cerr
<< "[Agent Client] ERROR: Action recording requested but no supported."
<< " To enable action recording, install https://github.com/mhauskn/librcsc"
<< " and recompile with -DELOG. See CMakeLists.txt"
<< std::endl;
return false;
}
#endif
if (!result) {
return false;
}
......@@ -340,11 +349,15 @@ void Agent::actionImpl() {
// Update and send the state features
const std::vector<float>& features =
feature_extractor->ExtractFeatures(this->world());
if (record) {
#ifdef ELOG
if (config().record()) {
elog.addText(Logger::WORLD, "GameStatus %d", game_status);
elog.flush();
feature_extractor->LogFeatures();
}
#endif
if (send(newsockfd, &(features.front()),
features.size() * sizeof(float), 0) < 0) {
error("[Agent Server] ERROR sending state features from socket");
......
......@@ -75,7 +75,6 @@ protected:
int server_port; // Port to start the server on
bool server_running; // Is the server running?
int sockfd, newsockfd; // Server sockets
bool record; // Record states + actions
private:
bool doPreprocess();
......
......@@ -31,6 +31,7 @@ FeatureExtractor::FeatureExtractor() :
FeatureExtractor::~FeatureExtractor() {}
void FeatureExtractor::LogFeatures() {
#ifdef ELOG
assert(feature_vec.size() == numFeatures);
std::stringstream ss;
for (int i=0; i<numFeatures; ++i) {
......@@ -38,6 +39,7 @@ void FeatureExtractor::LogFeatures() {
}
elog.addText(Logger::WORLD, "StateFeatures %s", ss.str().c_str());
elog.flush();
#endif
}
void FeatureExtractor::addAngFeature(const rcsc::AngleDeg& ang) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment