#include <iostream>
#include <ale_interface.hpp>
#ifdef __USE_SDL
#include <SDL.h>
#endif
using namespace std;
int main(int argc, char** argv) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " rom_file" << std::endl;
return 1;
}
ale::ALEInterface ale;
ale.setInt("random_seed", 123);
ale.setFloat("repeat_action_probability", 0.25);
#ifdef __USE_SDL
ale.setBool("display_screen", true);
ale.setBool("sound", true);
#endif
ale.loadROM(argv[1]);
ale::ActionVect legal_actions = ale.getLegalActionSet();
for (int episode = 0; episode < 10; episode++) {
float totalReward = 0;
while (!ale.game_over()) {
ale::Action a = legal_actions[rand() % legal_actions.size()];
float reward = ale.act(a);
totalReward += reward;
}
cout << "Episode " << episode << " ended with score: " << totalReward
<< endl;
ale.reset_game();
}
return 0;
}