#include <iostream>
#include <ale_interface.hpp>
#include <cstdlib>
#ifndef __USE_SDL
#error Video recording example is disabled as it requires SDL. Recompile with -DUSE_SDL=ON.
#else
#include <SDL.h>
using namespace std;
int main(int argc, char** argv) {
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " rom_file" << std::endl;
return 1;
}
ale::ALEInterface ale;
ale.setInt("random_seed", 123);
ale.setBool("display_screen", true);
ale.setBool("sound", true);
std::string recordPath = "record";
std::cout << std::endl;
ale.setString("record_screen_dir", recordPath.c_str());
ale.setString("record_sound_filename", (recordPath + "/sound.wav").c_str());
ale.setInt("fragsize", 64);
std::string cmd = "mkdir ";
cmd += recordPath;
system(cmd.c_str());
ale.loadROM(argv[1]);
ale::ActionVect legal_actions = ale.getLegalActionSet();
while (!ale.game_over()) {
ale::Action a = legal_actions[rand() % legal_actions.size()];
ale.act(a);
}
std::cout << std::endl;
std::cout << "Recording complete. To create a video, you may want to run \n"
" doc/scripts/videoRecordingExampleJoinXXX.sh. See manual for "
"details.."
<< std::endl;
return 0;
}
#endif