#include <cstdlib>
#include <ctime>
#include <memory>
#include <sstream>
#include "emucore/m6502/src/bspf/src/bspf.hxx"
#include "emucore/Console.hxx"
#include "emucore/Event.hxx"
#include "emucore/PropsSet.hxx"
#include "emucore/Settings.hxx"
#include "emucore/FSNode.hxx"
#include "emucore/OSystem.hxx"
#if (defined(WIN32) || defined(__MINGW32__))
#include "os_dependent/SettingsWin32.hxx"
#include "os_dependent/OSystemWin32.hxx"
#else
#include "os_dependent/SettingsUNIX.hxx"
#include "os_dependent/OSystemUNIX.hxx"
#endif
#include "controllers/ale_controller.hpp"
#include "controllers/fifo_controller.hpp"
#include "controllers/rlglue_controller.hpp"
#include "common/Constants.h"
#include "ale_interface.hpp"
namespace ale {
namespace {
std::unique_ptr<OSystem> theOSystem;
std::unique_ptr<Settings> theSettings;
ALEController* createController(OSystem* osystem, std::string type) {
if (type.empty()) {
std::cerr << "You must specify a controller type (via -game_controller)."
<< std::endl;
exit(1);
} else if (type == "fifo") {
std::cerr << "Game will be controlled through FIFO pipes." << std::endl;
return new FIFOController(osystem, false);
} else if (type == "fifo_named") {
std::cerr << "Game will be controlled through named FIFO pipes."
<< std::endl;
return new FIFOController(osystem, true);
} else if (type == "rlglue") {
std::cerr << "Game will be controlled through RL-Glue." << std::endl;
return new RLGlueController(osystem);
} else {
std::cerr << "Invalid controller type: " << type << " " << std::endl;
exit(1);
}
}
} }
int main(int argc, char* argv[]) {
ale::ALEInterface::disableBufferedIO();
std::cerr << ale::ALEInterface::welcomeMessage() << std::endl;
ale::ALEInterface::createOSystem(ale::theOSystem, ale::theSettings);
std::string romfile = ale::theOSystem->settings().loadCommandLine(argc, argv);
ale::ALEInterface::loadSettings(romfile, ale::theOSystem);
std::string controller_type =
ale::theOSystem->settings().getString("game_controller");
std::unique_ptr<ale::ALEController> controller(
ale::createController(ale::theOSystem.get(), controller_type));
controller->run();
ale::theOSystem.reset(NULL);
return 0;
}