diff --git a/.gitignore b/.gitignore index a932274..0da9b2a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ build dist *.pyc .tox + +*.iml diff --git a/atari_py/ale_interface/src/common/Constants.h b/atari_py/ale_interface/src/common/Constants.h index 0918c2a..6278822 100644 --- a/atari_py/ale_interface/src/common/Constants.h +++ b/atari_py/ale_interface/src/common/Constants.h @@ -68,7 +68,8 @@ enum Action { SAVE_STATE = 43, LOAD_STATE = 44, SYSTEM_RESET = 45, - LAST_ACTION_INDEX = 50 + LAST_ACTION_INDEX = 50, + SELECT = 51 }; #define PLAYER_A_MAX (18) diff --git a/atari_py/ale_interface/src/emucore/Settings.cxx b/atari_py/ale_interface/src/emucore/Settings.cxx index fe1224c..f00adcc 100644 --- a/atari_py/ale_interface/src/emucore/Settings.cxx +++ b/atari_py/ale_interface/src/emucore/Settings.cxx @@ -707,6 +707,7 @@ void Settings::setDefaultSettings() { boolSettings.insert(pair("color_averaging", false)); boolSettings.insert(pair("send_rgb", false)); intSettings.insert(pair("frame_skip", 1)); + intSettings.insert(pair("game_mode", 0)); floatSettings.insert(pair("repeat_action_probability", 0.25)); stringSettings.insert(pair("rom_file", "")); diff --git a/atari_py/ale_interface/src/environment/ale_state.cpp b/atari_py/ale_interface/src/environment/ale_state.cpp index b8fbc70..600dddd 100644 --- a/atari_py/ale_interface/src/environment/ale_state.cpp +++ b/atari_py/ale_interface/src/environment/ale_state.cpp @@ -222,6 +222,8 @@ void ALEState::applyActionPaddles(Event* event, int player_a_action, int player_ // Handle reset if (player_a_action == RESET || player_b_action == RESET) event->set(Event::ConsoleReset, 1); + if (player_a_action == SELECT || player_b_action == SELECT) + event->set(Event::ConsoleSelect, 1); // Now add the fire event switch (player_a_action) { @@ -353,6 +355,9 @@ void ALEState::setActionJoysticks(Event* event, int player_a_action, int player_ case RESET: event->set(Event::ConsoleReset, 1); break; + case SELECT: + event->set(Event::ConsoleSelect, 1); + break; default: ale::Logger::Error << "Invalid Player A Action: " << player_a_action; exit(-1); @@ -450,6 +455,9 @@ void ALEState::setActionJoysticks(Event* event, int player_a_action, int player_ event->set(Event::ConsoleReset, 1); ale::Logger::Info << "Sending Reset..." << endl; break; + case SELECT: + event->set(Event::ConsoleSelect, 1); + break; default: ale::Logger::Error << "Invalid Player B Action: " << player_b_action << endl; exit(-1); @@ -462,6 +470,7 @@ void ALEState::setActionJoysticks(Event* event, int player_a_action, int player_ * ***************************************************************************/ void ALEState::resetKeys(Event* event) { event->set(Event::ConsoleReset, 0); + event->set(Event::ConsoleSelect, 0); event->set(Event::JoystickZeroFire, 0); event->set(Event::JoystickZeroUp, 0); event->set(Event::JoystickZeroDown, 0); diff --git a/atari_py/ale_interface/src/environment/stella_environment.cpp b/atari_py/ale_interface/src/environment/stella_environment.cpp index 83a065a..0440d1c 100644 --- a/atari_py/ale_interface/src/environment/stella_environment.cpp +++ b/atari_py/ale_interface/src/environment/stella_environment.cpp @@ -75,6 +75,10 @@ void StellaEnvironment::reset() { emulate(PLAYER_A_NOOP, PLAYER_B_NOOP, noopSteps); // reset for n steps + int game_mode = m_osystem->settings().getInt("game_mode"); + for (int i = 0; i < game_mode; i++) { + emulate(SELECT, PLAYER_B_NOOP, 1); + } emulate(RESET, PLAYER_B_NOOP, m_num_reset_steps); // reset the rom (after emulating, in case the NOOPs led to reward)