diff --git a/src/environment/ale_state.cpp b/src/environment/ale_state.cpp index df9339f7d..33f987b27 100644 --- a/src/environment/ale_state.cpp +++ b/src/environment/ale_state.cpp @@ -244,7 +244,7 @@ void ALEState::applyActionPaddles(Event* event, } // Now update the paddle positions - updatePaddlePositions(event, delta_left, delta_right); + updatePaddlePositions(event, delta_a, delta_b); // Handle reset if (player_a_action == RESET || player_b_action == RESET) @@ -302,82 +302,82 @@ void ALEState::setDifficultySwitches(Event* event, unsigned int value) { event->set(Event::ConsoleRightDifficultyB, !((value & 2) >> 1)); } -void ALEState::applyActionJoysticks(Event* event, +void ALEState::applyActionJoysticks(Event* event_obj, int player_a_action, int player_b_action) { // Reset keys - resetKeys(event); + resetKeys(event_obj); switch (player_a_action) { case PLAYER_A_NOOP: break; case PLAYER_A_FIRE: - event->set(Event::JoystickZeroFire, 1); + event_obj->set(Event::JoystickZeroFire, 1); break; case PLAYER_A_UP: - event->set(Event::JoystickZeroUp, 1); + event_obj->set(Event::JoystickZeroUp, 1); break; case PLAYER_A_RIGHT: - event->set(Event::JoystickZeroRight, 1); + event_obj->set(Event::JoystickZeroRight, 1); break; case PLAYER_A_LEFT: - event->set(Event::JoystickZeroLeft, 1); + event_obj->set(Event::JoystickZeroLeft, 1); break; case PLAYER_A_DOWN: - event->set(Event::JoystickZeroDown, 1); + event_obj->set(Event::JoystickZeroDown, 1); break; case PLAYER_A_UPRIGHT: - event->set(Event::JoystickZeroUp, 1); - event->set(Event::JoystickZeroRight, 1); + event_obj->set(Event::JoystickZeroUp, 1); + event_obj->set(Event::JoystickZeroRight, 1); break; case PLAYER_A_UPLEFT: - event->set(Event::JoystickZeroUp, 1); - event->set(Event::JoystickZeroLeft, 1); + event_obj->set(Event::JoystickZeroUp, 1); + event_obj->set(Event::JoystickZeroLeft, 1); break; case PLAYER_A_DOWNRIGHT: - event->set(Event::JoystickZeroDown, 1); - event->set(Event::JoystickZeroRight, 1); + event_obj->set(Event::JoystickZeroDown, 1); + event_obj->set(Event::JoystickZeroRight, 1); break; case PLAYER_A_DOWNLEFT: - event->set(Event::JoystickZeroDown, 1); - event->set(Event::JoystickZeroLeft, 1); + event_obj->set(Event::JoystickZeroDown, 1); + event_obj->set(Event::JoystickZeroLeft, 1); break; case PLAYER_A_UPFIRE: - event->set(Event::JoystickZeroUp, 1); - event->set(Event::JoystickZeroFire, 1); + event_obj->set(Event::JoystickZeroUp, 1); + event_obj->set(Event::JoystickZeroFire, 1); break; case PLAYER_A_RIGHTFIRE: - event->set(Event::JoystickZeroRight, 1); - event->set(Event::JoystickZeroFire, 1); + event_obj->set(Event::JoystickZeroRight, 1); + event_obj->set(Event::JoystickZeroFire, 1); break; case PLAYER_A_LEFTFIRE: - event->set(Event::JoystickZeroLeft, 1); - event->set(Event::JoystickZeroFire, 1); + event_obj->set(Event::JoystickZeroLeft, 1); + event_obj->set(Event::JoystickZeroFire, 1); break; case PLAYER_A_DOWNFIRE: - event->set(Event::JoystickZeroDown, 1); - event->set(Event::JoystickZeroFire, 1); + event_obj->set(Event::JoystickZeroDown, 1); + event_obj->set(Event::JoystickZeroFire, 1); break; case PLAYER_A_UPRIGHTFIRE: - event->set(Event::JoystickZeroUp, 1); - event->set(Event::JoystickZeroRight, 1); - event->set(Event::JoystickZeroFire, 1); + event_obj->set(Event::JoystickZeroUp, 1); + event_obj->set(Event::JoystickZeroRight, 1); + event_obj->set(Event::JoystickZeroFire, 1); break; case PLAYER_A_UPLEFTFIRE: - event->set(Event::JoystickZeroUp, 1); - event->set(Event::JoystickZeroLeft, 1); - event->set(Event::JoystickZeroFire, 1); + event_obj->set(Event::JoystickZeroUp, 1); + event_obj->set(Event::JoystickZeroLeft, 1); + event_obj->set(Event::JoystickZeroFire, 1); break; case PLAYER_A_DOWNRIGHTFIRE: - event->set(Event::JoystickZeroDown, 1); - event->set(Event::JoystickZeroRight, 1); - event->set(Event::JoystickZeroFire, 1); + event_obj->set(Event::JoystickZeroDown, 1); + event_obj->set(Event::JoystickZeroRight, 1); + event_obj->set(Event::JoystickZeroFire, 1); break; case PLAYER_A_DOWNLEFTFIRE: - event->set(Event::JoystickZeroDown, 1); - event->set(Event::JoystickZeroLeft, 1); - event->set(Event::JoystickZeroFire, 1); + event_obj->set(Event::JoystickZeroDown, 1); + event_obj->set(Event::JoystickZeroLeft, 1); + event_obj->set(Event::JoystickZeroFire, 1); break; case RESET: - event->set(Event::ConsoleReset, 1); + event_obj->set(Event::ConsoleReset, 1); Logger::Info << "Sending Reset...\n"; break; default: @@ -388,74 +388,74 @@ void ALEState::applyActionJoysticks(Event* event, case PLAYER_B_NOOP: break; case PLAYER_B_FIRE: - event->set(Event::JoystickOneFire, 1); + event_obj->set(Event::JoystickOneFire, 1); break; case PLAYER_B_UP: - event->set(Event::JoystickOneUp, 1); + event_obj->set(Event::JoystickOneUp, 1); break; case PLAYER_B_RIGHT: - event->set(Event::JoystickOneRight, 1); + event_obj->set(Event::JoystickOneRight, 1); break; case PLAYER_B_LEFT: - event->set(Event::JoystickOneLeft, 1); + event_obj->set(Event::JoystickOneLeft, 1); break; case PLAYER_B_DOWN: - event->set(Event::JoystickOneDown, 1); + event_obj->set(Event::JoystickOneDown, 1); break; case PLAYER_B_UPRIGHT: - event->set(Event::JoystickOneUp, 1); - event->set(Event::JoystickOneRight, 1); + event_obj->set(Event::JoystickOneUp, 1); + event_obj->set(Event::JoystickOneRight, 1); break; case PLAYER_B_UPLEFT: - event->set(Event::JoystickOneUp, 1); - event->set(Event::JoystickOneLeft, 1); + event_obj->set(Event::JoystickOneUp, 1); + event_obj->set(Event::JoystickOneLeft, 1); break; case PLAYER_B_DOWNRIGHT: - event->set(Event::JoystickOneDown, 1); - event->set(Event::JoystickOneRight, 1); + event_obj->set(Event::JoystickOneDown, 1); + event_obj->set(Event::JoystickOneRight, 1); break; case PLAYER_B_DOWNLEFT: - event->set(Event::JoystickOneDown, 1); - event->set(Event::JoystickOneLeft, 1); + event_obj->set(Event::JoystickOneDown, 1); + event_obj->set(Event::JoystickOneLeft, 1); break; case PLAYER_B_UPFIRE: - event->set(Event::JoystickOneUp, 1); - event->set(Event::JoystickOneFire, 1); + event_obj->set(Event::JoystickOneUp, 1); + event_obj->set(Event::JoystickOneFire, 1); break; case PLAYER_B_RIGHTFIRE: - event->set(Event::JoystickOneRight, 1); - event->set(Event::JoystickOneFire, 1); + event_obj->set(Event::JoystickOneRight, 1); + event_obj->set(Event::JoystickOneFire, 1); break; case PLAYER_B_LEFTFIRE: - event->set(Event::JoystickOneLeft, 1); - event->set(Event::JoystickOneFire, 1); + event_obj->set(Event::JoystickOneLeft, 1); + event_obj->set(Event::JoystickOneFire, 1); break; case PLAYER_B_DOWNFIRE: - event->set(Event::JoystickOneDown, 1); - event->set(Event::JoystickOneFire, 1); + event_obj->set(Event::JoystickOneDown, 1); + event_obj->set(Event::JoystickOneFire, 1); break; case PLAYER_B_UPRIGHTFIRE: - event->set(Event::JoystickOneUp, 1); - event->set(Event::JoystickOneRight, 1); - event->set(Event::JoystickOneFire, 1); + event_obj->set(Event::JoystickOneUp, 1); + event_obj->set(Event::JoystickOneRight, 1); + event_obj->set(Event::JoystickOneFire, 1); break; case PLAYER_B_UPLEFTFIRE: - event->set(Event::JoystickOneUp, 1); - event->set(Event::JoystickOneLeft, 1); - event->set(Event::JoystickOneFire, 1); + event_obj->set(Event::JoystickOneUp, 1); + event_obj->set(Event::JoystickOneLeft, 1); + event_obj->set(Event::JoystickOneFire, 1); break; case PLAYER_B_DOWNRIGHTFIRE: - event->set(Event::JoystickOneDown, 1); - event->set(Event::JoystickOneRight, 1); - event->set(Event::JoystickOneFire, 1); + event_obj->set(Event::JoystickOneDown, 1); + event_obj->set(Event::JoystickOneRight, 1); + event_obj->set(Event::JoystickOneFire, 1); break; case PLAYER_B_DOWNLEFTFIRE: - event->set(Event::JoystickOneDown, 1); - event->set(Event::JoystickOneLeft, 1); - event->set(Event::JoystickOneFire, 1); + event_obj->set(Event::JoystickOneDown, 1); + event_obj->set(Event::JoystickOneLeft, 1); + event_obj->set(Event::JoystickOneFire, 1); break; case RESET: - event->set(Event::ConsoleReset, 1); + event_obj->set(Event::ConsoleReset, 1); Logger::Info << "Sending Reset...\n"; break; default: diff --git a/src/environment/stella_environment.cpp b/src/environment/stella_environment.cpp index 668ce2a50..510a14a47 100644 --- a/src/environment/stella_environment.cpp +++ b/src/environment/stella_environment.cpp @@ -279,7 +279,7 @@ void StellaEnvironment::emulate( m_state.applyActionPaddles( event, player_a_action, paddle_a_strength, - player_b_action, paddle_b_strength, + player_b_action, paddle_b_strength ); m_osystem->console().mediaSource().update(); diff --git a/src/environment/stella_environment.hpp b/src/environment/stella_environment.hpp index fc4b7278e..f2a59a0b2 100644 --- a/src/environment/stella_environment.hpp +++ b/src/environment/stella_environment.hpp @@ -59,7 +59,7 @@ class StellaEnvironment { * number plus the frame skip. */ reward_t act(Action player_a_action, Action player_b_action, - float paddle_a_strength, float paddle_b_strength); + float paddle_a_strength = 1.0, float paddle_b_strength = 1.0); /** Applies the given continuous actions (e.g. updating paddle positions when * the paddle is used) and performs one simulation step in Stella. Returns the