Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add game_mode option #20

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ build
dist
*.pyc
.tox

*.iml
3 changes: 2 additions & 1 deletion atari_py/ale_interface/src/common/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions atari_py/ale_interface/src/emucore/Settings.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ void Settings::setDefaultSettings() {
boolSettings.insert(pair<string, bool>("color_averaging", false));
boolSettings.insert(pair<string, bool>("send_rgb", false));
intSettings.insert(pair<string, int>("frame_skip", 1));
intSettings.insert(pair<string, int>("game_mode", 0));
floatSettings.insert(pair<string, float>("repeat_action_probability", 0.25));
stringSettings.insert(pair<string, string>("rom_file", ""));

Expand Down
9 changes: 9 additions & 0 deletions atari_py/ale_interface/src/environment/ale_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions atari_py/ale_interface/src/environment/stella_environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down