From 1ebbdb4e0facd96cdeeddd314cadb666dfac2bac Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Tue, 12 Dec 2017 16:54:54 -0600 Subject: [PATCH 01/29] added SOR2 cpp and hpp files --- src/games/supported/StreetsOfRage2.cpp | 231 +++++++++++++++++++++++++ src/games/supported/StreetsOfRage2.hpp | 77 +++++++++ 2 files changed, 308 insertions(+) create mode 100644 src/games/supported/StreetsOfRage2.cpp create mode 100644 src/games/supported/StreetsOfRage2.hpp diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp new file mode 100644 index 0000000..f5dd1f1 --- /dev/null +++ b/src/games/supported/StreetsOfRage2.cpp @@ -0,0 +1,231 @@ +/* ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ +#include "../RomUtils.hpp" +#include + +#include "../RomUtils.hpp" + +#include "RleSystem.hxx" +#include "RleException.h" + +#include "StreetsOfRage2.hpp" +#include + + +using namespace rle; + + +StreetsOfRage2Settings::StreetsOfRage2Settings() { + reset(); + + + + minimalActions = {JOYPAD_NOOP, + JOYPAD_DOWN, //Walk down + JOYPAD_UP, // Walk up + JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + + JOYPAD_GENESIS_A, // Special attack + JOYPAD_GENESIS_B, // Regular attack + + JOYPAD_GENESIS_C, // Jump + + JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right + + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + JOYPAD_GENESIS_B | JOYPAD_RIGHT, + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack + JOYPAD_GENESIS_A | JOYPAD_GENESIS_B //Directed special attack + + }; +} + + +/* create a new instance of the rom */ +RomSettings* StreetsOfRage2Settings::clone() const { + RomSettings* rval = new StreetsOfRage2Settings(); + *rval = *this; + return rval; +} + + +void StreetsOfRage2Settings::step(const RleSystem& system) { +// Read out current score, health, lives, kills + reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); + m_lives = readRam(&system, 0xEF82); + m_health = readRam(&system, 0xEF80); + +// update the reward + m_reward = score - m_score; + m_score = score; + +// Update terminal status + if ((m_lives == 0) &&(m_health == 0)){ + m_terminal = true; + } + +// Get level information + m_current_level = readRam(&system, 0xFC42); + int m_end_level = system.settings()->getInt("SOR2_end_level"); + int m_progress_1 = readRam(&system, 0xFC44); + int m_progress_2 = readRam(&system, 0xFCCE); + + // Level 1 + if (m_end_level == 1){ + if ((m_current_level == 0) && (m_progress_1 == 0) && (m_progress_2 == 12)){ + m_terminal = true; + } + }// Level 2 + else if (m_end_level == 2){ + if ((m_current_level == 2) && (m_progress_1 == 0) && (m_progress_2 == 12)){ + m_terminal = true; + } + }// Level 3 + else if (m_end_level == 3){ + if ((m_current_level == 4) && (m_progress_1 == 0) && (m_progress_2 == 16)){ + m_terminal = true; + } + }// Level 4 + else if (m_end_level == 4){ + if ((m_current_level == 6) && (m_progress_1 == 0) && (m_progress_2 == 22)){ + m_terminal = true; + } + }// Level 5 + else if (m_end_level == 5){ + if ((m_current_level == 8) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + m_terminal = true; + } + }// Level 6 + else if (m_end_level == 6){ + if ((m_current_level == 10) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + m_terminal = true; + } + }// Level 7 + else if (m_end_level == 7){ + if ((m_current_level == 12) && (m_progress_1 == 0) && (m_progress_2 == 18)){ + m_terminal = true; + } + }// Level 8 + else if (m_end_level == 8){ + if ((m_current_level == 16) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + m_terminal = true; + } + } +}; + + + +/* reset the state of the game */ +void StreetsOfRage2Settings::reset() { + m_reward = 0; + m_score = 0; + m_terminal = false; +} + + +/* saves the state of the rom settings */ +void StreetsOfRage2Settings::saveState( Serializer & ser ) { + ser.putInt(m_reward); + ser.putInt(m_score); + ser.putBool(m_terminal); +} + + +// loads the state of the rom settings +void StreetsOfRage2Settings::loadState( Deserializer & des ) { + m_reward = des.getInt(); + m_score = des.getInt(); + m_terminal = des.getBool(); +} + + +ActionVect StreetsOfRage2Settings::getStartingActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + +// wait for intro to end + INSERT_NOPS(5*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(0.4*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + +// select 1 player + INSERT_NOPS(0.5*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(3*num_of_nops) + +// choose character + string player_1_character = system.settings()->getString("SOR2_player_1_character"); + if("axel" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("max" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_LEFT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("blaze" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("skate" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + } + + +// wait for level to begin + INSERT_NOPS(4 * num_of_nops) + + + return startingActions; +} + + + +void StreetsOfRage2Settings::startingOperations(RleSystem& system){ + //set difficulty + int difficulty = system.settings()->getInt("SOR2_difficulty"); + if(1 == difficulty){ + writeRam(&system, 0xFD04, 0x0); + }else if(2 == difficulty){ + writeRam(&system, 0xFD04, 0x2); + }else if(3 == difficulty){ + writeRam(&system, 0xFD04, 0x4); + }else if(4 == difficulty){ + writeRam(&system, 0xFD04, 0x6); + }else if(5 == difficulty){ + writeRam(&system, 0xFD04, 0x8); + }else if(6 == difficulty){ + writeRam(&system, 0xFD04, 0x10); + } + + //set number of continues. By Default continues set to zero. + writeRam(&system,0xEFA4,0x0); + + //set start level + int start_level = system.settings()->getInt("SOR2_start_level"); + writeRam(&system, 0xFD0E, (start_level-1) * 0x1); + + //set number of lives + //(This sets the number of lives for the game. Would need to do + //this differently if you wanted to set the number of lives differently in + //2 player mode.) + int num_lives = system.settings()->getInt("SOR2_lives"); + writeRam(&system, 0xFD06, (num_lives-1) * 0x1); + +} + diff --git a/src/games/supported/StreetsOfRage2.hpp b/src/games/supported/StreetsOfRage2.hpp new file mode 100644 index 0000000..d03d596 --- /dev/null +++ b/src/games/supported/StreetsOfRage2.hpp @@ -0,0 +1,77 @@ +/* ***************************************************************************** + * The line 67 is based on Xitari's code, from Google Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ + +#ifndef __STREETS_OF_RAGE_2_SETTINGS_HPP__ +#define __STREETS_OF_RAGE_2_SETTINGS_HPP__ +/* RL wrapper for AtariCollection settings */ + +#include "../GenesisSettings.hpp" +#include + +namespace rle { + +class StreetsOfRage2Settings : public GenesisSettings { + + public: + + StreetsOfRage2Settings(); + + // reset + void reset(); + + // the rom-name + const char* rom() const { return "streets_of_rage_2"; } + + // create a new instance of the rom + RomSettings* clone() const; + + // process the latest information from ALE + void step(const RleSystem& system); + + + // saves the state of the rom settings + void saveState( Serializer & ser ); + + + // loads the state of the rom settings + void loadState( Deserializer & des ); + + + virtual const int lives() { return 0; } + + virtual ActionVect getStartingActions(const RleSystem& system); + + void startingOperations(RleSystem& system); + private: + reward_t m_score; + int m_current_level; + int m_lives; +}; + +} // namespace rle + +#endif // __STREETS_OF_RAGE_2_SETTINGS_HPP__ From 7876ffcbb68c181a9d3dfeacb629ffad9c09fb7f Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Tue, 12 Dec 2017 16:58:05 -0600 Subject: [PATCH 02/29] updated Roms.cpp to include SOR2 --- src/games/Roms.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/games/Roms.cpp b/src/games/Roms.cpp index a5bdee6..da6040d 100644 --- a/src/games/Roms.cpp +++ b/src/games/Roms.cpp @@ -40,6 +40,7 @@ // genesis games #include "supported/SonicTheHedgehog.hpp" +#include "supported/StreetsOfRage2.hpp" // Atari Games //#include "supported/Breakout.hpp" From 552791f8b414269ee3faf18bd0731864bbfeeb66 Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Tue, 12 Dec 2017 17:03:25 -0600 Subject: [PATCH 03/29] updated SOR2 specific settings --- src/environment/Settings.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index d5acb50..30ad9a5 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -329,18 +329,25 @@ void Settings::setDefaultSettings() { // Game-Specific Settings - // Mortal Kombat + // Mortal Kombat boolSettings.emplace(std::make_pair("MK_random_position", true)); stringSettings.emplace(std::make_pair("MK_difficulty", "medium")); stringSettings.emplace(std::make_pair("MK_player1_character", "cage")); stringSettings.emplace(std::make_pair("MK_player2_character", "scorpion")); intSettings.emplace(std::make_pair("MK_opponent_character", 0)); - // Super Mario Kart - stringSettings.emplace(std::make_pair("SUPER_MARIO_KART_player1_character", "bowser")); + // Streets Of Rage 2 + intSettings.emplace(std::make_pair("SOR2_start_level", 1)); + intSettings.emplace(std::make_pair("SOR2_end_level", 1)); + intSettings.emplace(std::make_pair("SOR2_difficulty", 1)); + intSettings.emplace(std::make_pair("SOR2_lives", 3)); + intSettings.emplace(std::make_pair("SOR2_player_1_character", "axel")); - //Super Double Dragon - stringSettings.emplace(std::make_pair("DDRAGON_reward_strategy", "score")); + // Super Mario Kart + stringSettings.emplace(std::make_pair("SUPER_MARIO_KART_player1_character", "bowser")); + + //Super Double Dragon + stringSettings.emplace(std::make_pair("DDRAGON_reward_strategy", "score")); for (map::iterator it = stringSettings.begin(); it != stringSettings.end(); it++) { From 627d6d0bdbd0abe2c557c5ae607ca927227bb5c0 Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Tue, 12 Dec 2017 17:20:51 -0600 Subject: [PATCH 04/29] updated SOR2 header file --- src/games/supported/StreetsOfRage2.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/games/supported/StreetsOfRage2.hpp b/src/games/supported/StreetsOfRage2.hpp index d03d596..01f095d 100644 --- a/src/games/supported/StreetsOfRage2.hpp +++ b/src/games/supported/StreetsOfRage2.hpp @@ -70,6 +70,7 @@ class StreetsOfRage2Settings : public GenesisSettings { reward_t m_score; int m_current_level; int m_lives; + int m_health; }; } // namespace rle From a959ba172f466e4c6c271edcf70b9e449b39721f Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Tue, 12 Dec 2017 17:42:35 -0600 Subject: [PATCH 05/29] updated Roms.cpp with SOR2 --- src/games/Roms.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/games/Roms.cpp b/src/games/Roms.cpp index da6040d..94787d0 100644 --- a/src/games/Roms.cpp +++ b/src/games/Roms.cpp @@ -183,8 +183,10 @@ static const RomSettings *roms[] = { new AladdinSettings(), new StreetFighterIISettings(), new BustAMoveSettings(), -// Genesis games - new SonicTheHedgehogSettings() + + //Genesis games + new SonicTheHedgehogSettings(), + new StreetsOfRage2Settings(), }; From 24dbecd1e64a53c94f62ac4cb83f82e93af2222b Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Tue, 12 Dec 2017 18:25:54 -0600 Subject: [PATCH 06/29] fixed but in Settings.cxx --- src/environment/Settings.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index 30ad9a5..598b529 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -341,7 +341,7 @@ void Settings::setDefaultSettings() { intSettings.emplace(std::make_pair("SOR2_end_level", 1)); intSettings.emplace(std::make_pair("SOR2_difficulty", 1)); intSettings.emplace(std::make_pair("SOR2_lives", 3)); - intSettings.emplace(std::make_pair("SOR2_player_1_character", "axel")); + stringSettings.emplace(std::make_pair("SOR2_player_1_character", "axel")); // Super Mario Kart stringSettings.emplace(std::make_pair("SUPER_MARIO_KART_player1_character", "bowser")); From cae3f754b9adac138aa58d51cf58411efb3cd76b Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Sun, 17 Dec 2017 16:25:18 -0600 Subject: [PATCH 07/29] made changes to facilate testing SOR2 --- src/games/supported/StreetsOfRage2.cpp | 111 +++++++++++++++++-------- src/games/supported/StreetsOfRage2.hpp | 5 +- 2 files changed, 82 insertions(+), 34 deletions(-) diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index f5dd1f1..112b8a0 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -29,25 +29,25 @@ StreetsOfRage2Settings::StreetsOfRage2Settings() { - minimalActions = {JOYPAD_NOOP, + minimalActions = {//JOYPAD_NOOP, JOYPAD_DOWN, //Walk down - JOYPAD_UP, // Walk up - JOYPAD_LEFT, // Walk left - JOYPAD_RIGHT, // Walk right + //JOYPAD_UP, // Walk up + //JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT , // Walk right JOYPAD_GENESIS_A, // Special attack - JOYPAD_GENESIS_B, // Regular attack + // JOYPAD_GENESIS_B, // Regular attack - JOYPAD_GENESIS_C, // Jump + // JOYPAD_GENESIS_C, // Jump - JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left - JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right + // JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or - JOYPAD_GENESIS_B | JOYPAD_RIGHT, - JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack - JOYPAD_GENESIS_A | JOYPAD_GENESIS_B //Directed special attack + // JOYPAD_GENESIS_B | JOYPAD_RIGHT, + // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack + // JOYPAD_GENESIS_A | JOYPAD_GENESIS_B //Directed special attack }; } @@ -62,6 +62,30 @@ RomSettings* StreetsOfRage2Settings::clone() const { void StreetsOfRage2Settings::step(const RleSystem& system) { +// Begin code for testing + // Fix Agent health + writeRam(&system, 0xEF80, 0x68); + + // Make invincible + writeRam(&system, 0xEF50, 0x14); + + // Freeze Time + writeRam(&system, 0xFC3C, 0x99); + + // Fix enemy health and lives + writeRam(&system, 0xF180, 0x0); + writeRam(&system, 0xF182, 0x0); + writeRam(&system, 0xF280, 0x0); + writeRam(&system, 0xF282, 0x0); + writeRam(&system, 0xF380, 0x0); + writeRam(&system, 0xF382, 0x0); + writeRam(&system, 0xF480, 0x0); + writeRam(&system, 0xF482, 0x0); + writeRam(&system, 0xF580, 0x0); + writeRam(&system, 0xF582, 0x0); +// End code for testing + + // Read out current score, health, lives, kills reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); m_lives = readRam(&system, 0xEF82); @@ -72,54 +96,66 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { m_score = score; // Update terminal status - if ((m_lives == 0) &&(m_health == 0)){ + if ((m_lives == 0) && (m_health == 0)){ + std::cout << "LOST GAME" << std::endl; m_terminal = true; } // Get level information - m_current_level = readRam(&system, 0xFC42); - int m_end_level = system.settings()->getInt("SOR2_end_level"); + m_current_level = (readRam(&system, 0xFC42) / 2) + 1; + m_end_level = system.settings()->getInt("SOR2_end_level"); + if((m_end_level < m_current_level) or (m_end_level > 8)){ + m_end_level = m_current_level; + } int m_progress_1 = readRam(&system, 0xFC44); int m_progress_2 = readRam(&system, 0xFCCE); // Level 1 if (m_end_level == 1){ - if ((m_current_level == 0) && (m_progress_1 == 0) && (m_progress_2 == 12)){ + if ((m_current_level == 1) && (m_progress_1 == 0) && (m_progress_2 == 12)){ + std::cout << "Beat level 1" << std::endl; m_terminal = true; } }// Level 2 else if (m_end_level == 2){ if ((m_current_level == 2) && (m_progress_1 == 0) && (m_progress_2 == 12)){ + std::cout << "Beat level 2" << std::endl; m_terminal = true; } }// Level 3 else if (m_end_level == 3){ - if ((m_current_level == 4) && (m_progress_1 == 0) && (m_progress_2 == 16)){ + if ((m_current_level == 3) && (m_progress_1 == 0) && (m_progress_2 == 16)){ + std::cout << "Beat level 3" << std::endl; m_terminal = true; } }// Level 4 else if (m_end_level == 4){ - if ((m_current_level == 6) && (m_progress_1 == 0) && (m_progress_2 == 22)){ + if ((m_current_level == 4) && (m_progress_1 == 0) && (m_progress_2 == 22)){ + std::cout << "Beat level 4" << std::endl; m_terminal = true; } }// Level 5 else if (m_end_level == 5){ - if ((m_current_level == 8) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + if ((m_current_level == 5) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + std::cout << "Beat level 5" << std::endl; m_terminal = true; } }// Level 6 else if (m_end_level == 6){ - if ((m_current_level == 10) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + if ((m_current_level == 6) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + std::cout << "Beat level 6" << std::endl; m_terminal = true; } }// Level 7 else if (m_end_level == 7){ - if ((m_current_level == 12) && (m_progress_1 == 0) && (m_progress_2 == 18)){ + if ((m_current_level == 7) && (m_progress_1 == 0) && (m_progress_2 == 18)){ + std::cout << "Beat level 7" << std::endl; m_terminal = true; } }// Level 8 else if (m_end_level == 8){ - if ((m_current_level == 16) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + if ((m_current_level == 8) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + std::cout << "Beat level 8" << std::endl; m_terminal = true; } } @@ -198,18 +234,18 @@ ActionVect StreetsOfRage2Settings::getStartingActions(const RleSystem& system){ void StreetsOfRage2Settings::startingOperations(RleSystem& system){ //set difficulty - int difficulty = system.settings()->getInt("SOR2_difficulty"); - if(1 == difficulty){ + m_difficulty = system.settings()->getInt("SOR2_difficulty"); + if(1 == m_difficulty){ writeRam(&system, 0xFD04, 0x0); - }else if(2 == difficulty){ + }else if(2 == m_difficulty){ writeRam(&system, 0xFD04, 0x2); - }else if(3 == difficulty){ + }else if(3 == m_difficulty){ writeRam(&system, 0xFD04, 0x4); - }else if(4 == difficulty){ + }else if(4 == m_difficulty){ writeRam(&system, 0xFD04, 0x6); - }else if(5 == difficulty){ + }else if(5 == m_difficulty){ writeRam(&system, 0xFD04, 0x8); - }else if(6 == difficulty){ + }else if(6 == m_difficulty){ writeRam(&system, 0xFD04, 0x10); } @@ -217,15 +253,24 @@ void StreetsOfRage2Settings::startingOperations(RleSystem& system){ writeRam(&system,0xEFA4,0x0); //set start level - int start_level = system.settings()->getInt("SOR2_start_level"); - writeRam(&system, 0xFD0E, (start_level-1) * 0x1); + m_start_level = system.settings()->getInt("SOR2_start_level"); + if((m_start_level < 1) || (m_start_level > 7)){ + std::cout << "Start level out of bounds. Starting at level 1" << std::endl; + writeRam(&system, 0xFD0E, 0x0); + }else { + writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); + } //set number of lives //(This sets the number of lives for the game. Would need to do //this differently if you wanted to set the number of lives differently in //2 player mode.) - int num_lives = system.settings()->getInt("SOR2_lives"); - writeRam(&system, 0xFD06, (num_lives-1) * 0x1); - + m_lives = system.settings()->getInt("SOR2_lives"); + if((m_lives < 0) || (m_lives > 9)){ + std::cout << "Number of lives must be between 1 and 9. Initializing agent with 3 lives" << std::endl; + writeRam(&system, 0xFD06, 0x2); + }else { + writeRam(&system, 0xFD06, (m_lives-1) * 0x1); + } } diff --git a/src/games/supported/StreetsOfRage2.hpp b/src/games/supported/StreetsOfRage2.hpp index 01f095d..2abaa97 100644 --- a/src/games/supported/StreetsOfRage2.hpp +++ b/src/games/supported/StreetsOfRage2.hpp @@ -68,9 +68,12 @@ class StreetsOfRage2Settings : public GenesisSettings { void startingOperations(RleSystem& system); private: reward_t m_score; - int m_current_level; + int m_start_level; + int m_end_level; + int m_current_level; int m_lives; int m_health; + int m_difficulty; }; } // namespace rle From 04da36e5df9facda11689ff4255985976181c70a Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Sun, 17 Dec 2017 16:28:44 -0600 Subject: [PATCH 08/29] changed minimal action list temporarily --- src/games/supported/StreetsOfRage2.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index 112b8a0..129cb59 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -35,16 +35,16 @@ StreetsOfRage2Settings::StreetsOfRage2Settings() { //JOYPAD_LEFT, // Walk left JOYPAD_RIGHT , // Walk right - JOYPAD_GENESIS_A, // Special attack - // JOYPAD_GENESIS_B, // Regular attack + // JOYPAD_GENESIS_A, // Special attack + JOYPAD_GENESIS_B, // Regular attack // JOYPAD_GENESIS_C, // Jump // JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right - JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam - JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + // JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or // JOYPAD_GENESIS_B | JOYPAD_RIGHT, // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack // JOYPAD_GENESIS_A | JOYPAD_GENESIS_B //Directed special attack From 32f45cb5500954a7ec532c49043caacf4bb26915 Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Sun, 17 Dec 2017 16:41:03 -0600 Subject: [PATCH 09/29] more small changes for testing --- src/games/supported/StreetsOfRage2.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index 129cb59..e696def 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -31,7 +31,10 @@ StreetsOfRage2Settings::StreetsOfRage2Settings() { minimalActions = {//JOYPAD_NOOP, JOYPAD_DOWN, //Walk down - //JOYPAD_UP, // Walk up + JOYPAD_DOWN, + JOYPAD_DOWN, + JOYPAD_DOWN, + //JOYPAD_UP, // Walk up //JOYPAD_LEFT, // Walk left JOYPAD_RIGHT , // Walk right @@ -43,7 +46,7 @@ StreetsOfRage2Settings::StreetsOfRage2Settings() { // JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right - // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam // JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or // JOYPAD_GENESIS_B | JOYPAD_RIGHT, // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack @@ -253,7 +256,7 @@ void StreetsOfRage2Settings::startingOperations(RleSystem& system){ writeRam(&system,0xEFA4,0x0); //set start level - m_start_level = system.settings()->getInt("SOR2_start_level"); + m_start_level = 2; //system.settings()->getInt("SOR2_start_level"); if((m_start_level < 1) || (m_start_level > 7)){ std::cout << "Start level out of bounds. Starting at level 1" << std::endl; writeRam(&system, 0xFD0E, 0x0); From 6825b2969d6332cb9897319c555f81b8c16e4b02 Mon Sep 17 00:00:00 2001 From: Jon Michaux Date: Sun, 17 Dec 2017 17:57:21 -0600 Subject: [PATCH 10/29] changed code for testing --- src/games/supported/StreetsOfRage2.cpp | 92 +++++++++++++------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index e696def..5c0568b 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -29,28 +29,24 @@ StreetsOfRage2Settings::StreetsOfRage2Settings() { - minimalActions = {//JOYPAD_NOOP, + minimalActions = {JOYPAD_NOOP, JOYPAD_DOWN, //Walk down - JOYPAD_DOWN, - JOYPAD_DOWN, - JOYPAD_DOWN, - //JOYPAD_UP, // Walk up - //JOYPAD_LEFT, // Walk left - JOYPAD_RIGHT , // Walk right + JOYPAD_UP, // Walk up + JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT , // Walk right - // JOYPAD_GENESIS_A, // Special attack - JOYPAD_GENESIS_B, // Regular attack + JOYPAD_GENESIS_A, // Special attack + JOYPAD_GENESIS_B, // Regular attack - // JOYPAD_GENESIS_C, // Jump - - // JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C, // Jump + JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right - JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam - // JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or - // JOYPAD_GENESIS_B | JOYPAD_RIGHT, - // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack - // JOYPAD_GENESIS_A | JOYPAD_GENESIS_B //Directed special attack + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + JOYPAD_GENESIS_B | JOYPAD_RIGHT, + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack + JOYPAD_GENESIS_A | JOYPAD_GENESIS_B //Directed special attack }; } @@ -66,36 +62,40 @@ RomSettings* StreetsOfRage2Settings::clone() const { void StreetsOfRage2Settings::step(const RleSystem& system) { // Begin code for testing - // Fix Agent health - writeRam(&system, 0xEF80, 0x68); + if(system.settings()->getBool("SOR2_test") == true){ + + // Fix Agent health + writeRam(&system, 0xEF80, 0x68); - // Make invincible - writeRam(&system, 0xEF50, 0x14); + // Make invincible + writeRam(&system, 0xEF50, 0x14); - // Freeze Time - writeRam(&system, 0xFC3C, 0x99); - - // Fix enemy health and lives - writeRam(&system, 0xF180, 0x0); - writeRam(&system, 0xF182, 0x0); - writeRam(&system, 0xF280, 0x0); - writeRam(&system, 0xF282, 0x0); - writeRam(&system, 0xF380, 0x0); - writeRam(&system, 0xF382, 0x0); - writeRam(&system, 0xF480, 0x0); - writeRam(&system, 0xF482, 0x0); - writeRam(&system, 0xF580, 0x0); - writeRam(&system, 0xF582, 0x0); + // Freeze Time + writeRam(&system, 0xFC3C, 0x99); + + // Fix enemy health and lives + writeRam(&system, 0xF180, 0x0); + writeRam(&system, 0xF182, 0x0); + writeRam(&system, 0xF280, 0x0); + writeRam(&system, 0xF282, 0x0); + writeRam(&system, 0xF380, 0x0); + writeRam(&system, 0xF382, 0x0); + writeRam(&system, 0xF480, 0x0); + writeRam(&system, 0xF482, 0x0); + writeRam(&system, 0xF580, 0x0); + writeRam(&system, 0xF582, 0x0); +} // End code for testing // Read out current score, health, lives, kills - reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); + // Score set to 0. Will read score from gym wrapper + reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); m_lives = readRam(&system, 0xEF82); - m_health = readRam(&system, 0xEF80); + m_health = readRam(&system, 0xEF80); // update the reward - m_reward = score - m_score; + m_reward = score - m_score; m_score = score; // Update terminal status @@ -105,9 +105,9 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { } // Get level information - m_current_level = (readRam(&system, 0xFC42) / 2) + 1; + m_current_level = (readRam(&system, 0xFC42) / 2) + 1; m_end_level = system.settings()->getInt("SOR2_end_level"); - if((m_end_level < m_current_level) or (m_end_level > 8)){ + if((m_end_level < m_current_level) || (m_end_level > 8)){ m_end_level = m_current_level; } int m_progress_1 = readRam(&system, 0xFC44); @@ -253,13 +253,13 @@ void StreetsOfRage2Settings::startingOperations(RleSystem& system){ } //set number of continues. By Default continues set to zero. - writeRam(&system,0xEFA4,0x0); + writeRam(&system,0xEFA4,0x0); //set start level - m_start_level = 2; //system.settings()->getInt("SOR2_start_level"); + m_start_level = 2; //system.settings()->getInt("SOR2_start_level"); if((m_start_level < 1) || (m_start_level > 7)){ - std::cout << "Start level out of bounds. Starting at level 1" << std::endl; - writeRam(&system, 0xFD0E, 0x0); + std::cout << "Start level out of bounds. Starting at level 1" << std::endl; + writeRam(&system, 0xFD0E, 0x0); }else { writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); } @@ -270,8 +270,8 @@ void StreetsOfRage2Settings::startingOperations(RleSystem& system){ //2 player mode.) m_lives = system.settings()->getInt("SOR2_lives"); if((m_lives < 0) || (m_lives > 9)){ - std::cout << "Number of lives must be between 1 and 9. Initializing agent with 3 lives" << std::endl; - writeRam(&system, 0xFD06, 0x2); + std::cout << "Number of lives must be between 1 and 9. Initializing agent with 3 lives" << std::endl; + writeRam(&system, 0xFD06, 0x2); }else { writeRam(&system, 0xFD06, (m_lives-1) * 0x1); } From f0faaf507e5fcc2765274fd027d2f5200474e0f0 Mon Sep 17 00:00:00 2001 From: Jon Michaux Date: Mon, 18 Dec 2017 08:08:41 -0600 Subject: [PATCH 11/29] more changes to sor2 --- setup.py | 2 +- src/environment/Settings.cxx | 1 + src/games/supported/StreetsOfRage2.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 6f791c4..647538e 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ def run_cmake(): new_dir = op.join(op.split(__file__)[0], 'build') dd.mkpath(new_dir) os.chdir(new_dir) - cmake_args = ' -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=ON' + cmake_args = '-DUSE_SDL=ON -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=ON' cores_to_use = max(1, multiprocessing.cpu_count() - 1) try: diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index 598b529..52e0148 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -337,6 +337,7 @@ void Settings::setDefaultSettings() { intSettings.emplace(std::make_pair("MK_opponent_character", 0)); // Streets Of Rage 2 + boolSettings.emplace(std::make_pair("SOR2_test", false)); intSettings.emplace(std::make_pair("SOR2_start_level", 1)); intSettings.emplace(std::make_pair("SOR2_end_level", 1)); intSettings.emplace(std::make_pair("SOR2_difficulty", 1)); diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index 5c0568b..c8c7ee3 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -256,7 +256,7 @@ void StreetsOfRage2Settings::startingOperations(RleSystem& system){ writeRam(&system,0xEFA4,0x0); //set start level - m_start_level = 2; //system.settings()->getInt("SOR2_start_level"); + m_start_level = system.settings()->getInt("SOR2_start_level"); if((m_start_level < 1) || (m_start_level > 7)){ std::cout << "Start level out of bounds. Starting at level 1" << std::endl; writeRam(&system, 0xFD0E, 0x0); From 49652b53cabb1ed34eaff5c54d4ef05df1c87b47 Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Mon, 18 Dec 2017 08:20:47 -0600 Subject: [PATCH 12/29] added conditions to make the game as easy as possible --- src/games/supported/StreetsOfRage2.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index c8c7ee3..f9d7ba7 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -72,7 +72,10 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { // Freeze Time writeRam(&system, 0xFC3C, 0x99); +} +// This setting gives all enemies minimal health and lives + if((system.settings()->getBool("SOR2_test") == true) || system.settings()-getInt("SOR2_difficuly") == 0){ // Fix enemy health and lives writeRam(&system, 0xF180, 0x0); writeRam(&system, 0xF182, 0x0); @@ -238,7 +241,9 @@ ActionVect StreetsOfRage2Settings::getStartingActions(const RleSystem& system){ void StreetsOfRage2Settings::startingOperations(RleSystem& system){ //set difficulty m_difficulty = system.settings()->getInt("SOR2_difficulty"); - if(1 == m_difficulty){ + if(0 == m_difficulty){ + writeRam(&system, 0xFD04, 0x0); + }else if(1 == m_difficulty){ writeRam(&system, 0xFD04, 0x0); }else if(2 == m_difficulty){ writeRam(&system, 0xFD04, 0x2); From bb189ab968a700babc0823ad5a9553e01d73b001 Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Mon, 18 Dec 2017 09:05:42 -0600 Subject: [PATCH 13/29] updated SOR2 starting actions --- src/environment/Settings.cxx | 3 +- src/games/supported/StreetsOfRage2.cpp | 59 +++++++++++++++++--------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index 52e0148..1ccf078 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -342,7 +342,8 @@ void Settings::setDefaultSettings() { intSettings.emplace(std::make_pair("SOR2_end_level", 1)); intSettings.emplace(std::make_pair("SOR2_difficulty", 1)); intSettings.emplace(std::make_pair("SOR2_lives", 3)); - stringSettings.emplace(std::make_pair("SOR2_player_1_character", "axel")); + stringSettings.emplace(std::make_pair("SOR2_player_1_character", "max")); + stringSettings.emplace(std::make_pair("SOR2_game_type", "single")); // Super Mario Kart stringSettings.emplace(std::make_pair("SUPER_MARIO_KART_player1_character", "bowser")); diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index f9d7ba7..7921f56 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -75,7 +75,7 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { } // This setting gives all enemies minimal health and lives - if((system.settings()->getBool("SOR2_test") == true) || system.settings()-getInt("SOR2_difficuly") == 0){ + if((system.settings()->getBool("SOR2_test") == true) || system.settings()-getInt("SOR2_difficulty") == 0){ // Fix enemy health and lives writeRam(&system, 0xF180, 0x0); writeRam(&system, 0xF182, 0x0); @@ -92,7 +92,7 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { // Read out current score, health, lives, kills - // Score set to 0. Will read score from gym wrapper + // Score set to 0. Will read score from rle/gym wrapper reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); m_lives = readRam(&system, 0xEF82); m_health = readRam(&system, 0xEF80); @@ -202,32 +202,48 @@ ActionVect StreetsOfRage2Settings::getStartingActions(const RleSystem& system){ INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(0.4*num_of_nops) INSERT_ACTION_SINGLE_A(JOYPAD_START) - -// select 1 player INSERT_NOPS(0.5*num_of_nops) + +// Select game type + string game_type = system.settings()->getString("SOR2_game_type"); + + if(game_type == "single"){ + writeRam(&system, 0xFC18, 0x0); + }else if(game_type == "coop"){ + writeRam(&system, 0xFC18, 0x1); + }else if(game_type == "duel"){ + writeRame(&system, 0xFC18, 0x2); + } + INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(3*num_of_nops) -// choose character +// Choose Player 1 character string player_1_character = system.settings()->getString("SOR2_player_1_character"); - if("axel" == player_1_character){ - INSERT_ACTION_SINGLE_A(JOYPAD_START) - }else if("max" == player_1_character){ - INSERT_ACTION_SINGLE_A(JOYPAD_LEFT) - INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) - INSERT_ACTION_SINGLE_A(JOYPAD_START) + if("max" == player_1_character){ + writeRam(&system, 0xEF0C, 0x0); + // INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("axel" == player_1_character){ + // INSERT_ACTION_SINGLE_A(JOYPAD_LEFT) + // INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + // INSERT_ACTION_SINGLE_A(JOYPAD_START) + writeRam(&system, 0xEF0C, 0x1); }else if("blaze" == player_1_character){ - INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) - INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) - INSERT_ACTION_SINGLE_A(JOYPAD_START) + writeRam(&system, 0xEF0C, 0x2); + // INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + // INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + // INSERT_ACTION_SINGLE_A(JOYPAD_START) }else if("skate" == player_1_character){ - INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) - INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) - INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) - INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) - INSERT_ACTION_SINGLE_A(JOYPAD_START) - } - + writeRam(&system, 0xEF0C, 0x3); +// INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) +// INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) +// INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) +// INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) +// INSERT_ACTION_SINGLE_A(JOYPAD_START) + } + + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP); + INSERT_ACTION_SINGLE_A(JOPYAD_START); // wait for level to begin INSERT_NOPS(4 * num_of_nops) @@ -242,6 +258,7 @@ void StreetsOfRage2Settings::startingOperations(RleSystem& system){ //set difficulty m_difficulty = system.settings()->getInt("SOR2_difficulty"); if(0 == m_difficulty){ + // Also setting enemy health low (see above). writeRam(&system, 0xFD04, 0x0); }else if(1 == m_difficulty){ writeRam(&system, 0xFD04, 0x0); From 7e8a200f39616a1b49b616f44a03cac3d57631ab Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Mon, 18 Dec 2017 14:18:56 -0600 Subject: [PATCH 14/29] fixed terminal conditions --- src/games/supported/StreetsOfRage2.cpp | 114 ++++++++++++------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index 7921f56..87e17c8 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -30,24 +30,27 @@ StreetsOfRage2Settings::StreetsOfRage2Settings() { minimalActions = {JOYPAD_NOOP, - JOYPAD_DOWN, //Walk down - JOYPAD_UP, // Walk up + // Moving + JOYPAD_DOWN, //Walk down + JOYPAD_UP, // Walk up JOYPAD_LEFT, // Walk left - JOYPAD_RIGHT , // Walk right - - JOYPAD_GENESIS_A, // Special attack - JOYPAD_GENESIS_B, // Regular attack - - JOYPAD_GENESIS_C, // Jump - JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left - JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right - + JOYPAD_RIGHT, // Walk right + JOYPAD_GENESIS_C, // Jump + JOYPAD_LEFT | JOYPAD_GENESIS_C, + JOYPAD_RIGHT | JOYPAD_GENESIS_C, + + // Special attacks + JOYPAD_GENESIS_A, + JOYPAD_LEFT | JOYPAD_GENESIS_A, + JOYPAD_RIGHT |JOYPAD_GENESIS_A, + + // Regular Attacks + JOYPAD_GENESIS_B, JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam - JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or - JOYPAD_GENESIS_B | JOYPAD_RIGHT, - JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack - JOYPAD_GENESIS_A | JOYPAD_GENESIS_B //Directed special attack - + + // Attacks when holding enemy + JOYPAD_GENESIS_B | JOYPAD_LEFT, + JOYPAD_GENESIS_B | JOYPAD_RIGHT, }; } @@ -75,7 +78,7 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { } // This setting gives all enemies minimal health and lives - if((system.settings()->getBool("SOR2_test") == true) || system.settings()-getInt("SOR2_difficulty") == 0){ + if((system.settings()->getBool("SOR2_test") == true) || system.settings()->getInt("SOR2_difficulty") == 0){ // Fix enemy health and lives writeRam(&system, 0xF180, 0x0); writeRam(&system, 0xF182, 0x0); @@ -110,57 +113,57 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { // Get level information m_current_level = (readRam(&system, 0xFC42) / 2) + 1; m_end_level = system.settings()->getInt("SOR2_end_level"); - if((m_end_level < m_current_level) || (m_end_level > 8)){ - m_end_level = m_current_level; + if((m_end_level < syste.settings()->getInt("SOR2_start_level")) || (m_end_level > 8)){ + m_end_level = system.settings()->getInt("SOR2_start_level"); } int m_progress_1 = readRam(&system, 0xFC44); int m_progress_2 = readRam(&system, 0xFCCE); // Level 1 if (m_end_level == 1){ - if ((m_current_level == 1) && (m_progress_1 == 0) && (m_progress_2 == 12)){ + if ((m_current_level == 2) && (m_progress_1 == 0) && (m_progress_2 == 12)){ std::cout << "Beat level 1" << std::endl; m_terminal = true; } }// Level 2 else if (m_end_level == 2){ - if ((m_current_level == 2) && (m_progress_1 == 0) && (m_progress_2 == 12)){ + if ((m_current_level == 3) && (m_progress_1 == 0) && (m_progress_2 == 12)){ std::cout << "Beat level 2" << std::endl; m_terminal = true; } }// Level 3 else if (m_end_level == 3){ - if ((m_current_level == 3) && (m_progress_1 == 0) && (m_progress_2 == 16)){ + if ((m_current_level == 4) && (m_progress_1 == 0) && (m_progress_2 == 16)){ std::cout << "Beat level 3" << std::endl; m_terminal = true; } }// Level 4 else if (m_end_level == 4){ - if ((m_current_level == 4) && (m_progress_1 == 0) && (m_progress_2 == 22)){ + if ((m_current_level == 5) && (m_progress_1 == 0) && (m_progress_2 == 22)){ std::cout << "Beat level 4" << std::endl; m_terminal = true; } }// Level 5 else if (m_end_level == 5){ - if ((m_current_level == 5) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + if ((m_current_level == 6) && (m_progress_1 == 0) && (m_progress_2 == 10)){ std::cout << "Beat level 5" << std::endl; m_terminal = true; } }// Level 6 else if (m_end_level == 6){ - if ((m_current_level == 6) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + if ((m_current_level == 7) && (m_progress_1 == 0) && (m_progress_2 == 10)){ std::cout << "Beat level 6" << std::endl; m_terminal = true; } }// Level 7 else if (m_end_level == 7){ - if ((m_current_level == 7) && (m_progress_1 == 0) && (m_progress_2 == 18)){ + if ((m_current_level == 8) && (m_progress_1 == 0) && (m_progress_2 == 18)){ std::cout << "Beat level 7" << std::endl; m_terminal = true; } }// Level 8 else if (m_end_level == 8){ - if ((m_current_level == 8) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + if ((m_current_level == 9) && (m_progress_1 == 0) && (m_progress_2 == 10)){ std::cout << "Beat level 8" << std::endl; m_terminal = true; } @@ -205,48 +208,44 @@ ActionVect StreetsOfRage2Settings::getStartingActions(const RleSystem& system){ INSERT_NOPS(0.5*num_of_nops) // Select game type - string game_type = system.settings()->getString("SOR2_game_type"); +// string game_type = system.settings()->getString("SOR2_game_type"); - if(game_type == "single"){ - writeRam(&system, 0xFC18, 0x0); - }else if(game_type == "coop"){ - writeRam(&system, 0xFC18, 0x1); - }else if(game_type == "duel"){ - writeRame(&system, 0xFC18, 0x2); - } +// if(game_type == "single"){ +// writeRam(&system, 0xFC18, 0x0); +// }else if(game_type == "coop"){ +// writeRam(&system, 0xFC18, 0x1); +// }else if(game_type == "duel"){ +// writeRam(&system, 0xFC18, 0x2); +// } INSERT_ACTION_SINGLE_A(JOYPAD_START) - INSERT_NOPS(3*num_of_nops) + INSERT_NOPS(3 * num_of_nops) // Choose Player 1 character string player_1_character = system.settings()->getString("SOR2_player_1_character"); - if("max" == player_1_character){ - writeRam(&system, 0xEF0C, 0x0); - // INSERT_ACTION_SINGLE_A(JOYPAD_START) - }else if("axel" == player_1_character){ - // INSERT_ACTION_SINGLE_A(JOYPAD_LEFT) - // INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) - // INSERT_ACTION_SINGLE_A(JOYPAD_START) - writeRam(&system, 0xEF0C, 0x1); + if("axel" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("max" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_LEFT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) }else if("blaze" == player_1_character){ - writeRam(&system, 0xEF0C, 0x2); - // INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) - // INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) - // INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) }else if("skate" == player_1_character){ - writeRam(&system, 0xEF0C, 0x3); -// INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) -// INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) -// INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) -// INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) -// INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) } - + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP); - INSERT_ACTION_SINGLE_A(JOPYAD_START); + INSERT_ACTION_SINGLE_A(JOYPAD_START); // wait for level to begin - INSERT_NOPS(4 * num_of_nops) + INSERT_NOPS(3.5 * num_of_nops) return startingActions; @@ -274,6 +273,7 @@ void StreetsOfRage2Settings::startingOperations(RleSystem& system){ writeRam(&system, 0xFD04, 0x10); } + //set number of continues. By Default continues set to zero. writeRam(&system,0xEFA4,0x0); From eed33e19212a4ce3ba52c8a3a1211701c458960d Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Mon, 18 Dec 2017 14:19:49 -0600 Subject: [PATCH 15/29] added game_type setting. will be used for coop/duel gameplay. --- src/environment/Settings.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index 1ccf078..2b0f163 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -342,7 +342,7 @@ void Settings::setDefaultSettings() { intSettings.emplace(std::make_pair("SOR2_end_level", 1)); intSettings.emplace(std::make_pair("SOR2_difficulty", 1)); intSettings.emplace(std::make_pair("SOR2_lives", 3)); - stringSettings.emplace(std::make_pair("SOR2_player_1_character", "max")); + stringSettings.emplace(std::make_pair("SOR2_player_1_character", "skate")); stringSettings.emplace(std::make_pair("SOR2_game_type", "single")); // Super Mario Kart From e6a5b346ca07c6f0d5e8ef6fb7e6ff192eeed916 Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Mon, 18 Dec 2017 14:22:26 -0600 Subject: [PATCH 16/29] fixed typo --- src/games/supported/StreetsOfRage2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index 87e17c8..0dd0133 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -113,7 +113,7 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { // Get level information m_current_level = (readRam(&system, 0xFC42) / 2) + 1; m_end_level = system.settings()->getInt("SOR2_end_level"); - if((m_end_level < syste.settings()->getInt("SOR2_start_level")) || (m_end_level > 8)){ + if((m_end_level < system.settings()->getInt("SOR2_start_level")) || (m_end_level > 8)){ m_end_level = system.settings()->getInt("SOR2_start_level"); } int m_progress_1 = readRam(&system, 0xFC44); From 32fb45428752e2df45c222d02eaa8525d57d0822 Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Fri, 22 Dec 2017 15:57:27 -0600 Subject: [PATCH 17/29] changing SOR2 terminal conditions to eliminate unnecessary frames --- src/games/supported/StreetsOfRage2.cpp | 64 +++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index 0dd0133..ae70d21 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -118,16 +118,19 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { } int m_progress_1 = readRam(&system, 0xFC44); int m_progress_2 = readRam(&system, 0xFCCE); + +// Get boss information + int boss_health = readRam(&system, 0xF180); + int boss_lives = readRam(&system, 0xF280); // Level 1 - if (m_end_level == 1){ - if ((m_current_level == 2) && (m_progress_1 == 0) && (m_progress_2 == 12)){ + if ((m_end_level == 1) && (m_current_level == 2)) { + if ((m_progress_1 == 12) && (m_progress_2 == 12) && (readRam(&system, 0xF180)){ std::cout << "Beat level 1" << std::endl; m_terminal = true; } - }// Level 2 - else if (m_end_level == 2){ - if ((m_current_level == 3) && (m_progress_1 == 0) && (m_progress_2 == 12)){ + } else if ((m_end_level == 2) && (m_current_level == 2)){ + if ((m_current_level == 3) && (m_progress_1 == 12) && (m_progress_2 == 12)){ std::cout << "Beat level 2" << std::endl; m_terminal = true; } @@ -168,9 +171,58 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { m_terminal = true; } } -}; + // // Level 1 + // if (m_end_level == 1){ + // if ((m_current_level == 2) && (m_progress_1 == 0) && (m_progress_2 == 12)){ + // std::cout << "Beat level 1" << std::endl; + // m_terminal = true; + // } + // }// Level 2 + // else if ((m_end_level == 2) && (m_current_level == 3)){ + // if ((m_current_level == 3) && (m_progress_1 == 12) && (m_progress_2 == 12)){ + // std::cout << "Beat level 2" << std::endl; + // m_terminal = true; + // } + // }// Level 3 + // else if (m_end_level == 3){ + // if ((m_current_level == 4) && (m_progress_1 == 0) && (m_progress_2 == 16)){ + // std::cout << "Beat level 3" << std::endl; + // m_terminal = true; + // } + // }// Level 4 + // else if (m_end_level == 4){ + // if ((m_current_level == 5) && (m_progress_1 == 0) && (m_progress_2 == 22)){ + // std::cout << "Beat level 4" << std::endl; + // m_terminal = true; + // } + // }// Level 5 + // else if (m_end_level == 5){ + // if ((m_current_level == 6) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + // std::cout << "Beat level 5" << std::endl; + // m_terminal = true; + // } + // }// Level 6 + // else if (m_end_level == 6){ + // if ((m_current_level == 7) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + // std::cout << "Beat level 6" << std::endl; + // m_terminal = true; + // } + // }// Level 7 + // else if (m_end_level == 7){ + // if ((m_current_level == 8) && (m_progress_1 == 0) && (m_progress_2 == 18)){ + // std::cout << "Beat level 7" << std::endl; + // m_terminal = true; + // } + // }// Level 8 + // else if (m_end_level == 8){ + // if ((m_current_level == 9) && (m_progress_1 == 0) && (m_progress_2 == 10)){ + // std::cout << "Beat level 8" << std::endl; + // m_terminal = true; + // } + // } + /* reset the state of the game */ void StreetsOfRage2Settings::reset() { From 89293e5c15dedb8d6d1622eb037c9314aad9b27e Mon Sep 17 00:00:00 2001 From: Jon Michaux Date: Sat, 23 Dec 2017 22:56:58 -0600 Subject: [PATCH 18/29] finally finished SOR2 --- src/environment/Settings.cxx | 24 +- src/games/supported/StreetsOfRage2.cpp | 414 ++++++++++--------------- src/games/supported/StreetsOfRage2.hpp | 3 +- 3 files changed, 180 insertions(+), 261 deletions(-) diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index 2b0f163..fb65e88 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -1,8 +1,8 @@ //============================================================================ // -// SSSS tt lll lll -// SS SS tt ll ll -// SS tttttt eeee ll ll aaaa +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa // SSSS tt ee ee ll ll aa // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" // SS SS tt ee ll ll aa aa @@ -330,27 +330,29 @@ void Settings::setDefaultSettings() { // Game-Specific Settings // Mortal Kombat - boolSettings.emplace(std::make_pair("MK_random_position", true)); + boolSettings.emplace(std::make_pair("MK_random_position", false)); stringSettings.emplace(std::make_pair("MK_difficulty", "medium")); stringSettings.emplace(std::make_pair("MK_player1_character", "cage")); stringSettings.emplace(std::make_pair("MK_player2_character", "scorpion")); intSettings.emplace(std::make_pair("MK_opponent_character", 0)); // Streets Of Rage 2 - boolSettings.emplace(std::make_pair("SOR2_test", false)); - intSettings.emplace(std::make_pair("SOR2_start_level", 1)); - intSettings.emplace(std::make_pair("SOR2_end_level", 1)); - intSettings.emplace(std::make_pair("SOR2_difficulty", 1)); + boolSettings.emplace(std::make_pair("SOR2_test", true)); + intSettings.emplace(std::make_pair("SOR2_start_level", 4)); + intSettings.emplace(std::make_pair("SOR2_end_level", 4)); + intSettings.emplace(std::make_pair("SOR2_difficulty", 3)); intSettings.emplace(std::make_pair("SOR2_lives", 3)); - stringSettings.emplace(std::make_pair("SOR2_player_1_character", "skate")); - stringSettings.emplace(std::make_pair("SOR2_game_type", "single")); + stringSettings.emplace(std::make_pair("SOR2_player_1_character", "max")); + stringSettings.emplace(std::make_pair("SOR2_1p_terminal_win", "round_clear")); + stringSettings.emplace(std::make_pair("SOR2_2p_terminal_win", "round_clear")); + stringSettings.emplace(std::make_pair("SOR2_2p_terminal_lose", "one")); //"one" or "both" // Super Mario Kart stringSettings.emplace(std::make_pair("SUPER_MARIO_KART_player1_character", "bowser")); //Super Double Dragon stringSettings.emplace(std::make_pair("DDRAGON_reward_strategy", "score")); - + for (map::iterator it = stringSettings.begin(); it != stringSettings.end(); it++) { this->setString(it->first, it->second); diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRage2.cpp index ae70d21..6349e4b 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRage2.cpp @@ -27,30 +27,28 @@ using namespace rle; StreetsOfRage2Settings::StreetsOfRage2Settings() { reset(); - - minimalActions = {JOYPAD_NOOP, - // Moving - JOYPAD_DOWN, //Walk down - JOYPAD_UP, // Walk up - JOYPAD_LEFT, // Walk left - JOYPAD_RIGHT, // Walk right - JOYPAD_GENESIS_C, // Jump - JOYPAD_LEFT | JOYPAD_GENESIS_C, - JOYPAD_RIGHT | JOYPAD_GENESIS_C, - - // Special attacks - JOYPAD_GENESIS_A, - JOYPAD_LEFT | JOYPAD_GENESIS_A, + // Moving + JOYPAD_DOWN, //Walk down + JOYPAD_UP, // Walk up + // JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + JOYPAD_GENESIS_C, // Jump + JOYPAD_LEFT | JOYPAD_GENESIS_C, + JOYPAD_RIGHT | JOYPAD_GENESIS_C, + // + // // Special attacks + JOYPAD_GENESIS_A, + // JOYPAD_LEFT | JOYPAD_GENESIS_A, JOYPAD_RIGHT |JOYPAD_GENESIS_A, - - // Regular Attacks - JOYPAD_GENESIS_B, - JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam - - // Attacks when holding enemy - JOYPAD_GENESIS_B | JOYPAD_LEFT, - JOYPAD_GENESIS_B | JOYPAD_RIGHT, + // + // // Regular Attacks + JOYPAD_GENESIS_B, + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + // + // // Attacks when holding enemy + //JOYPAD_GENESIS_B | JOYPAD_LEFT, + JOYPAD_GENESIS_B | JOYPAD_RIGHT, }; } @@ -66,163 +64,106 @@ RomSettings* StreetsOfRage2Settings::clone() const { void StreetsOfRage2Settings::step(const RleSystem& system) { // Begin code for testing if(system.settings()->getBool("SOR2_test") == true){ - // Fix Agent health writeRam(&system, 0xEF80, 0x68); - // Make invincible writeRam(&system, 0xEF50, 0x14); - // Freeze Time writeRam(&system, 0xFC3C, 0x99); -} + } -// This setting gives all enemies minimal health and lives +// This setting gives all enemies minimal health if((system.settings()->getBool("SOR2_test") == true) || system.settings()->getInt("SOR2_difficulty") == 0){ - // Fix enemy health and lives + // Fix enemy health writeRam(&system, 0xF180, 0x0); - writeRam(&system, 0xF182, 0x0); writeRam(&system, 0xF280, 0x0); - writeRam(&system, 0xF282, 0x0); writeRam(&system, 0xF380, 0x0); - writeRam(&system, 0xF382, 0x0); writeRam(&system, 0xF480, 0x0); - writeRam(&system, 0xF482, 0x0); writeRam(&system, 0xF580, 0x0); - writeRam(&system, 0xF582, 0x0); } // End code for testing +// Read out current score (Score set to 0. Will read score from RAM in rle/gym wrapper) + reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); + m_lives = readRam(&system, 0xEF82); + m_health = readRam(&system, 0xEF80); -// Read out current score, health, lives, kills - // Score set to 0. Will read score from rle/gym wrapper - reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); - m_lives = readRam(&system, 0xEF82); - m_health = readRam(&system, 0xEF80); - -// update the reward - m_reward = score - m_score; - m_score = score; +// Update the reward + m_reward = score - m_score; + m_score = score; // Update terminal status - if ((m_lives == 0) && (m_health == 0)){ - std::cout << "LOST GAME" << std::endl; - m_terminal = true; + if (m_lives == 255){ + std::cout << "game_over" << std::endl; + m_terminal = true; } - -// Get level information - m_current_level = (readRam(&system, 0xFC42) / 2) + 1; - m_end_level = system.settings()->getInt("SOR2_end_level"); - if((m_end_level < system.settings()->getInt("SOR2_start_level")) || (m_end_level > 8)){ - m_end_level = system.settings()->getInt("SOR2_start_level"); - } - int m_progress_1 = readRam(&system, 0xFC44); - int m_progress_2 = readRam(&system, 0xFCCE); - -// Get boss information - int boss_health = readRam(&system, 0xF180); - int boss_lives = readRam(&system, 0xF280); - - // Level 1 - if ((m_end_level == 1) && (m_current_level == 2)) { - if ((m_progress_1 == 12) && (m_progress_2 == 12) && (readRam(&system, 0xF180)){ + // Get level information + m_current_level = (readRam(&system, 0xFC42) / 2) + 1; + m_end_level = system.settings()->getInt("SOR2_end_level"); + +// int screen = readRam(&system, 0xFC02); + int m_progress_1 = readRam(&system, 0xFC44); + int m_progress_2 = readRam(&system, 0xFCCE); + + // Get boss information + int boss_health = readRam(&system, 0xF180); + int boss_lives = readRam(&system, 0xF182); + + if ((system.settings()->getString("SOR2_1p_terminal_win") == "round_clear")){ + if (((m_current_level - 1) == m_end_level) && (m_progress_1 == 0) && (m_progress_2 > 10)){ + std::cout << "Round "<< m_current_level << " clear!" << std::endl; + m_terminal = true; + } + }// Level 1 + else if ((m_end_level == 1) && (m_current_level == 1)) { + if ((m_progress_1 == 12) && (m_progress_2 == 12) && ((boss_health + boss_lives) == 0)){ std::cout << "Beat level 1" << std::endl; m_terminal = true; } - } else if ((m_end_level == 2) && (m_current_level == 2)){ - if ((m_current_level == 3) && (m_progress_1 == 12) && (m_progress_2 == 12)){ + }// Level 2 + else if ((m_end_level == 2) && (m_current_level == 2) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 12) && (m_progress_2 == 12)){ std::cout << "Beat level 2" << std::endl; m_terminal = true; } - }// Level 3 - else if (m_end_level == 3){ - if ((m_current_level == 4) && (m_progress_1 == 0) && (m_progress_2 == 16)){ + }// Level 3 + else if ((m_end_level == 3) && (m_current_level == 3) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 16) && (m_progress_2 == 16)){ std::cout << "Beat level 3" << std::endl; m_terminal = true; - } - }// Level 4 - else if (m_end_level == 4){ - if ((m_current_level == 5) && (m_progress_1 == 0) && (m_progress_2 == 22)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; - } - }// Level 5 - else if (m_end_level == 5){ - if ((m_current_level == 6) && (m_progress_1 == 0) && (m_progress_2 == 10)){ - std::cout << "Beat level 5" << std::endl; - m_terminal = true; - } - }// Level 6 - else if (m_end_level == 6){ - if ((m_current_level == 7) && (m_progress_1 == 0) && (m_progress_2 == 10)){ - std::cout << "Beat level 6" << std::endl; - m_terminal = true; - } - }// Level 7 - else if (m_end_level == 7){ - if ((m_current_level == 8) && (m_progress_1 == 0) && (m_progress_2 == 18)){ - std::cout << "Beat level 7" << std::endl; - m_terminal = true; } - }// Level 8 - else if (m_end_level == 8){ - if ((m_current_level == 9) && (m_progress_1 == 0) && (m_progress_2 == 10)){ - std::cout << "Beat level 8" << std::endl; + }// Level 4 + else if ((m_end_level == 4) && (m_current_level == 4) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 22) && (m_progress_2 == 22)){ + std::cout << "Beat level 4" << std::endl; + m_terminal = true; + } + }// Level 5 + else if ((m_end_level == 5) && (m_current_level == 5) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 10) && (m_progress_2 == 10)){ + std::cout << "Beat level 4" << std::endl; m_terminal = true; } - } - - - // // Level 1 - // if (m_end_level == 1){ - // if ((m_current_level == 2) && (m_progress_1 == 0) && (m_progress_2 == 12)){ - // std::cout << "Beat level 1" << std::endl; - // m_terminal = true; - // } - // }// Level 2 - // else if ((m_end_level == 2) && (m_current_level == 3)){ - // if ((m_current_level == 3) && (m_progress_1 == 12) && (m_progress_2 == 12)){ - // std::cout << "Beat level 2" << std::endl; - // m_terminal = true; - // } - // }// Level 3 - // else if (m_end_level == 3){ - // if ((m_current_level == 4) && (m_progress_1 == 0) && (m_progress_2 == 16)){ - // std::cout << "Beat level 3" << std::endl; - // m_terminal = true; - // } - // }// Level 4 - // else if (m_end_level == 4){ - // if ((m_current_level == 5) && (m_progress_1 == 0) && (m_progress_2 == 22)){ - // std::cout << "Beat level 4" << std::endl; - // m_terminal = true; - // } - // }// Level 5 - // else if (m_end_level == 5){ - // if ((m_current_level == 6) && (m_progress_1 == 0) && (m_progress_2 == 10)){ - // std::cout << "Beat level 5" << std::endl; - // m_terminal = true; - // } - // }// Level 6 - // else if (m_end_level == 6){ - // if ((m_current_level == 7) && (m_progress_1 == 0) && (m_progress_2 == 10)){ - // std::cout << "Beat level 6" << std::endl; - // m_terminal = true; - // } - // }// Level 7 - // else if (m_end_level == 7){ - // if ((m_current_level == 8) && (m_progress_1 == 0) && (m_progress_2 == 18)){ - // std::cout << "Beat level 7" << std::endl; - // m_terminal = true; - // } - // }// Level 8 - // else if (m_end_level == 8){ - // if ((m_current_level == 9) && (m_progress_1 == 0) && (m_progress_2 == 10)){ - // std::cout << "Beat level 8" << std::endl; - // m_terminal = true; - // } - // } - + }// Level 6 + else if ((m_end_level == 6) && (m_current_level == 6) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 10) && (m_progress_2 == 10)){ + std::cout << "Beat level 4" << std::endl; + m_terminal = true; + } + }// Level 7 + else if ((m_end_level == 7) && (m_current_level == 7) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 18) && (m_progress_2 == 18)){ + std::cout << "Beat level 4" << std::endl; + m_terminal = true; + } + }// Level 8 + else if ((m_end_level == 8) && (m_current_level == 8) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 10) && (m_progress_2 == 10)){ + std::cout << "Beat level 4" << std::endl; + m_terminal = true; + } + } +} /* reset the state of the game */ void StreetsOfRage2Settings::reset() { @@ -234,120 +175,95 @@ void StreetsOfRage2Settings::reset() { /* saves the state of the rom settings */ void StreetsOfRage2Settings::saveState( Serializer & ser ) { - ser.putInt(m_reward); - ser.putInt(m_score); - ser.putBool(m_terminal); + ser.putInt(m_reward); + ser.putInt(m_score); + ser.putBool(m_terminal); } // loads the state of the rom settings void StreetsOfRage2Settings::loadState( Deserializer & des ) { - m_reward = des.getInt(); - m_score = des.getInt(); - m_terminal = des.getBool(); + m_reward = des.getInt(); + m_score = des.getInt(); + m_terminal = des.getBool(); } ActionVect StreetsOfRage2Settings::getStartingActions(const RleSystem& system){ - int num_of_nops(100); - ActionVect startingActions; - -// wait for intro to end - INSERT_NOPS(5*num_of_nops) - INSERT_ACTION_SINGLE_A(JOYPAD_START) - INSERT_NOPS(0.4*num_of_nops) - INSERT_ACTION_SINGLE_A(JOYPAD_START) - INSERT_NOPS(0.5*num_of_nops) - -// Select game type -// string game_type = system.settings()->getString("SOR2_game_type"); - -// if(game_type == "single"){ -// writeRam(&system, 0xFC18, 0x0); -// }else if(game_type == "coop"){ -// writeRam(&system, 0xFC18, 0x1); -// }else if(game_type == "duel"){ -// writeRam(&system, 0xFC18, 0x2); -// } - - INSERT_ACTION_SINGLE_A(JOYPAD_START) - INSERT_NOPS(3 * num_of_nops) - -// Choose Player 1 character - string player_1_character = system.settings()->getString("SOR2_player_1_character"); - if("axel" == player_1_character){ - INSERT_ACTION_SINGLE_A(JOYPAD_START) - }else if("max" == player_1_character){ - INSERT_ACTION_SINGLE_A(JOYPAD_LEFT) - INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) - INSERT_ACTION_SINGLE_A(JOYPAD_START) - }else if("blaze" == player_1_character){ - INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) - INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) - INSERT_ACTION_SINGLE_A(JOYPAD_START) - }else if("skate" == player_1_character){ - INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) - INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) - INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) - INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) - INSERT_ACTION_SINGLE_A(JOYPAD_START) - } - - INSERT_ACTION_SINGLE_A(JOYPAD_NOOP); - INSERT_ACTION_SINGLE_A(JOYPAD_START); - -// wait for level to begin - INSERT_NOPS(3.5 * num_of_nops) - + int num_of_nops(100); + ActionVect startingActions; + + // wait for intro to end + INSERT_NOPS(5 * num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(0.4*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(0.5*num_of_nops) + + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(3 * num_of_nops) + // + string player_1_character = system.settings()->getString("SOR2_player_1_character"); + if("axel" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("max" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_LEFT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("blaze" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("skate" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + } - return startingActions; + return startingActions; } + void StreetsOfRage2Settings::startingOperations(RleSystem& system){ + //set difficulty + m_difficulty = system.settings()->getInt("SOR2_difficulty"); + if(0 == m_difficulty){ + // Also setting enemy health low (see above). + writeRam(&system, 0xFD04, 0x0); + }else if(1 == m_difficulty){ + writeRam(&system, 0xFD04, 0x0); + }else if(2 == m_difficulty){ + writeRam(&system, 0xFD04, 0x2); + }else if(3 == m_difficulty){ + writeRam(&system, 0xFD04, 0x4); + }else if(4 == m_difficulty){ + writeRam(&system, 0xFD04, 0x6); + }else if(5 == m_difficulty){ + writeRam(&system, 0xFD04, 0x8); + }else if(6 == m_difficulty){ + writeRam(&system, 0xFD04, 0x0A); + } + + // Set number of continues. By Default continues set to zero. + writeRam(&system,0xEFA4, 0x0); + + // Set start level + m_start_level = system.settings()->getInt("SOR2_start_level"); + writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); + + // Set number of lives + m_lives = system.settings()->getInt("SOR2_lives"); + writeRam(&system, 0xFD06, (m_lives-1) * 0x1); + } -void StreetsOfRage2Settings::startingOperations(RleSystem& system){ - //set difficulty - m_difficulty = system.settings()->getInt("SOR2_difficulty"); - if(0 == m_difficulty){ - // Also setting enemy health low (see above). - writeRam(&system, 0xFD04, 0x0); - }else if(1 == m_difficulty){ - writeRam(&system, 0xFD04, 0x0); - }else if(2 == m_difficulty){ - writeRam(&system, 0xFD04, 0x2); - }else if(3 == m_difficulty){ - writeRam(&system, 0xFD04, 0x4); - }else if(4 == m_difficulty){ - writeRam(&system, 0xFD04, 0x6); - }else if(5 == m_difficulty){ - writeRam(&system, 0xFD04, 0x8); - }else if(6 == m_difficulty){ - writeRam(&system, 0xFD04, 0x10); - } - - - //set number of continues. By Default continues set to zero. - writeRam(&system,0xEFA4,0x0); - - //set start level - m_start_level = system.settings()->getInt("SOR2_start_level"); - if((m_start_level < 1) || (m_start_level > 7)){ - std::cout << "Start level out of bounds. Starting at level 1" << std::endl; - writeRam(&system, 0xFD0E, 0x0); - }else { - writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); - } +ActionVect StreetsOfRage2Settings::getExtraActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; - //set number of lives - //(This sets the number of lives for the game. Would need to do - //this differently if you wanted to set the number of lives differently in - //2 player mode.) - m_lives = system.settings()->getInt("SOR2_lives"); - if((m_lives < 0) || (m_lives > 9)){ - std::cout << "Number of lives must be between 1 and 9. Initializing agent with 3 lives" << std::endl; - writeRam(&system, 0xFD06, 0x2); - }else { - writeRam(&system, 0xFD06, (m_lives-1) * 0x1); - } -} +// wait for level to begin + INSERT_NOPS(4 * num_of_nops) + return startingActions; +} diff --git a/src/games/supported/StreetsOfRage2.hpp b/src/games/supported/StreetsOfRage2.hpp index 2abaa97..50ccfe1 100644 --- a/src/games/supported/StreetsOfRage2.hpp +++ b/src/games/supported/StreetsOfRage2.hpp @@ -60,11 +60,12 @@ class StreetsOfRage2Settings : public GenesisSettings { // loads the state of the rom settings void loadState( Deserializer & des ); - virtual const int lives() { return 0; } virtual ActionVect getStartingActions(const RleSystem& system); + virtual ActionVect getExtraActions(const RleSystem& system); + void startingOperations(RleSystem& system); private: reward_t m_score; From a3c619f27c25b91f4149eb5d2010fc2f278479b2 Mon Sep 17 00:00:00 2001 From: Jon Michaux Date: Sat, 23 Dec 2017 23:00:14 -0600 Subject: [PATCH 19/29] added getExtraActions --- src/environment/retro_environment.cpp | 19 +++++++++++++++---- src/games/RomSettings.cpp | 8 +++++--- src/games/RomSettings.hpp | 8 ++++++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/environment/retro_environment.cpp b/src/environment/retro_environment.cpp index 2c0c926..63c6f86 100644 --- a/src/environment/retro_environment.cpp +++ b/src/environment/retro_environment.cpp @@ -1,8 +1,8 @@ /* ***************************************************************************** * A.L.E (Arcade Learning Environment) - * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and * the Reinforcement Learning and Artificial Intelligence Laboratory - * Released under the GNU General Public License; see License.txt for details. + * Released under the GNU General Public License; see License.txt for details. * * Based on: Stella -- "An Atari 2600 VCS Emulator" * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team @@ -12,7 +12,7 @@ * * A class that wraps around the Stella core to provide users with a typical * reinforcement learning environment interface. - * + * **************************************************************************** */ #include "retro_environment.hpp" @@ -117,9 +117,21 @@ void RetroEnvironment::reset() { // m_rlesystem->p_display_screen->display_screen(); } m_settings->startingOperations(*m_rlesystem); + + startingActions = m_settings->getExtraActions(*m_rlesystem); + for (size_t i = 0; i < startingActions.size(); i++){ + if((startingActions[i] & PLAYER_B) > 0){ + emulateStart(JOYPAD_NOOP, startingActions[i]); + }else{ + emulateStart(startingActions[i], PLAYER_B | JOYPAD_NOOP); + } + + m_rlesystem->getRetroAgent()->audioEnable(audio); } +} + /** Save/restore the environment state. */ void RetroEnvironment::save() { // Store the current state into a new object @@ -275,4 +287,3 @@ void RetroEnvironment::processScreen() { memcpy((uint8_t*)m_screen.getArray() + i*width *Bpp , buffer + i*pitch, width * Bpp); } } - diff --git a/src/games/RomSettings.cpp b/src/games/RomSettings.cpp index 3462ee3..a8e021e 100644 --- a/src/games/RomSettings.cpp +++ b/src/games/RomSettings.cpp @@ -1,8 +1,8 @@ /* ***************************************************************************** * A.L.E (Arcade Learning Environment) - * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and * the Reinforcement Learning and Artificial Intelligence Laboratory - * Released under the GNU General Public License; see License.txt for details. + * Released under the GNU General Public License; see License.txt for details. * * Based on: Stella -- "An Atari 2600 VCS Emulator" * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team @@ -29,7 +29,9 @@ ActionVect RomSettings::getStartingActions() { return ActionVect(); } - +ActionVect RomSettings::getExtraActions() { + return ActionVect(); +} ActionVect RomSettings::getMinimalActionSet() { ActionVect actions; for (unsigned a = 0; a < AllActionsVector.size(); a++) { diff --git a/src/games/RomSettings.hpp b/src/games/RomSettings.hpp index b033259..5c36a33 100644 --- a/src/games/RomSettings.hpp +++ b/src/games/RomSettings.hpp @@ -15,9 +15,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************** * A.L.E (Arcade Learning Environment) - * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and * the Reinforcement Learning and Artificial Intelligence Laboratory - * Released under the GNU General Public License; see License.txt for details. + * Released under the GNU General Public License; see License.txt for details. * * Based on: Stella -- "An Atari 2600 VCS Emulator" * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team @@ -107,6 +107,10 @@ struct RomSettings { // Optionally perform starting operations such as modifying the game's RAM virtual void startingOperations(RleSystem& system){}; + // Optionall get extra starting actions AFTER modifying the game's RAM + virtual ActionVect getExtraActions(); + virtual ActionVect getExtraActions(const RleSystem& system){ return getExtraActions();} + // below functions used to belong to RomUtils // reads a byte at a memory location virtual int readRam(const RleSystem* system, int offset); From edbe32cd81a5a3f0ad35885101ea01bba5c343d7 Mon Sep 17 00:00:00 2001 From: Jon Michaux Date: Sat, 23 Dec 2017 23:17:10 -0600 Subject: [PATCH 20/29] renamed SOR2 files --- ...StreetsOfRage2.cpp => StreetsOfRageII.cpp} | 22 +++++++++---------- ...StreetsOfRage2.hpp => StreetsOfRageII.hpp} | 12 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-) rename src/games/supported/{StreetsOfRage2.cpp => StreetsOfRageII.cpp} (92%) rename src/games/supported/{StreetsOfRage2.hpp => StreetsOfRageII.hpp} (89%) diff --git a/src/games/supported/StreetsOfRage2.cpp b/src/games/supported/StreetsOfRageII.cpp similarity index 92% rename from src/games/supported/StreetsOfRage2.cpp rename to src/games/supported/StreetsOfRageII.cpp index 6349e4b..0b614cf 100644 --- a/src/games/supported/StreetsOfRage2.cpp +++ b/src/games/supported/StreetsOfRageII.cpp @@ -17,14 +17,14 @@ #include "RleSystem.hxx" #include "RleException.h" -#include "StreetsOfRage2.hpp" +#include "StreetsOfRageII.hpp" #include using namespace rle; -StreetsOfRage2Settings::StreetsOfRage2Settings() { +StreetsOfRageIISettings::StreetsOfRageIISettings() { reset(); minimalActions = {JOYPAD_NOOP, @@ -54,14 +54,14 @@ StreetsOfRage2Settings::StreetsOfRage2Settings() { /* create a new instance of the rom */ -RomSettings* StreetsOfRage2Settings::clone() const { - RomSettings* rval = new StreetsOfRage2Settings(); +RomSettings* StreetsOfRageIISettings::clone() const { + RomSettings* rval = new StreetsOfRageIISettings(); *rval = *this; return rval; } -void StreetsOfRage2Settings::step(const RleSystem& system) { +void StreetsOfRageIISettings::step(const RleSystem& system) { // Begin code for testing if(system.settings()->getBool("SOR2_test") == true){ // Fix Agent health @@ -166,7 +166,7 @@ void StreetsOfRage2Settings::step(const RleSystem& system) { } /* reset the state of the game */ -void StreetsOfRage2Settings::reset() { +void StreetsOfRageIISettings::reset() { m_reward = 0; m_score = 0; m_terminal = false; @@ -174,7 +174,7 @@ void StreetsOfRage2Settings::reset() { /* saves the state of the rom settings */ -void StreetsOfRage2Settings::saveState( Serializer & ser ) { +void StreetsOfRageIISettings::saveState( Serializer & ser ) { ser.putInt(m_reward); ser.putInt(m_score); ser.putBool(m_terminal); @@ -182,14 +182,14 @@ void StreetsOfRage2Settings::saveState( Serializer & ser ) { // loads the state of the rom settings -void StreetsOfRage2Settings::loadState( Deserializer & des ) { +void StreetsOfRageIISettings::loadState( Deserializer & des ) { m_reward = des.getInt(); m_score = des.getInt(); m_terminal = des.getBool(); } -ActionVect StreetsOfRage2Settings::getStartingActions(const RleSystem& system){ +ActionVect StreetsOfRageIISettings::getStartingActions(const RleSystem& system){ int num_of_nops(100); ActionVect startingActions; @@ -225,7 +225,7 @@ ActionVect StreetsOfRage2Settings::getStartingActions(const RleSystem& system){ return startingActions; } - void StreetsOfRage2Settings::startingOperations(RleSystem& system){ + void StreetsOfRageIISettings::startingOperations(RleSystem& system){ //set difficulty m_difficulty = system.settings()->getInt("SOR2_difficulty"); if(0 == m_difficulty){ @@ -258,7 +258,7 @@ ActionVect StreetsOfRage2Settings::getStartingActions(const RleSystem& system){ } -ActionVect StreetsOfRage2Settings::getExtraActions(const RleSystem& system){ +ActionVect StreetsOfRageIISettings::getExtraActions(const RleSystem& system){ int num_of_nops(100); ActionVect startingActions; diff --git a/src/games/supported/StreetsOfRage2.hpp b/src/games/supported/StreetsOfRageII.hpp similarity index 89% rename from src/games/supported/StreetsOfRage2.hpp rename to src/games/supported/StreetsOfRageII.hpp index 50ccfe1..c77748d 100644 --- a/src/games/supported/StreetsOfRage2.hpp +++ b/src/games/supported/StreetsOfRageII.hpp @@ -25,8 +25,8 @@ * ***************************************************************************** */ -#ifndef __STREETS_OF_RAGE_2_SETTINGS_HPP__ -#define __STREETS_OF_RAGE_2_SETTINGS_HPP__ +#ifndef __STREETS_OF_RAGE_II_SETTINGS_HPP__ +#define __STREETS_OF_RAGE_II_SETTINGS_HPP__ /* RL wrapper for AtariCollection settings */ #include "../GenesisSettings.hpp" @@ -34,17 +34,17 @@ namespace rle { -class StreetsOfRage2Settings : public GenesisSettings { +class StreetsOfRageIISettings : public GenesisSettings { public: - StreetsOfRage2Settings(); + StreetsOfRageIISettings(); // reset void reset(); // the rom-name - const char* rom() const { return "streets_of_rage_2"; } + const char* rom() const { return "streets_of_rage_ii"; } // create a new instance of the rom RomSettings* clone() const; @@ -69,7 +69,7 @@ class StreetsOfRage2Settings : public GenesisSettings { void startingOperations(RleSystem& system); private: reward_t m_score; - int m_start_level; + int m_start_level; int m_end_level; int m_current_level; int m_lives; From 7c66d1dd3550adbcea12b4302eef990f1d37ac84 Mon Sep 17 00:00:00 2001 From: Jon Michaux Date: Sun, 24 Dec 2017 00:02:13 -0600 Subject: [PATCH 21/29] added SOR2 2 players --- src/environment/Settings.cxx | 1 + src/games/Roms.cpp | 6 +- .../supported/StreetsOfRageII2Players.cpp | 337 ++++++++++++++++++ .../supported/StreetsOfRageII2Players.hpp | 82 +++++ 4 files changed, 424 insertions(+), 2 deletions(-) create mode 100644 src/games/supported/StreetsOfRageII2Players.cpp create mode 100644 src/games/supported/StreetsOfRageII2Players.hpp diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index fb65e88..af32db3 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -343,6 +343,7 @@ void Settings::setDefaultSettings() { intSettings.emplace(std::make_pair("SOR2_difficulty", 3)); intSettings.emplace(std::make_pair("SOR2_lives", 3)); stringSettings.emplace(std::make_pair("SOR2_player_1_character", "max")); + stringSettings.emplace(std::make_pair("SOR2_player_2_character", "axel")); stringSettings.emplace(std::make_pair("SOR2_1p_terminal_win", "round_clear")); stringSettings.emplace(std::make_pair("SOR2_2p_terminal_win", "round_clear")); stringSettings.emplace(std::make_pair("SOR2_2p_terminal_lose", "one")); //"one" or "both" diff --git a/src/games/Roms.cpp b/src/games/Roms.cpp index 94787d0..074b337 100644 --- a/src/games/Roms.cpp +++ b/src/games/Roms.cpp @@ -40,7 +40,8 @@ // genesis games #include "supported/SonicTheHedgehog.hpp" -#include "supported/StreetsOfRage2.hpp" +#include "supported/StreetsOfRageII.hpp" +#include "supported/StreetsOfRageII2Players.hpp" // Atari Games //#include "supported/Breakout.hpp" @@ -186,7 +187,8 @@ static const RomSettings *roms[] = { //Genesis games new SonicTheHedgehogSettings(), - new StreetsOfRage2Settings(), + new StreetsOfRageIISettings(), + new StreetsOfRageII2PlayersSettings(), }; diff --git a/src/games/supported/StreetsOfRageII2Players.cpp b/src/games/supported/StreetsOfRageII2Players.cpp new file mode 100644 index 0000000..950fd1f --- /dev/null +++ b/src/games/supported/StreetsOfRageII2Players.cpp @@ -0,0 +1,337 @@ +/* ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ +#include "../RomUtils.hpp" +#include + +#include "../RomUtils.hpp" + +#include "RleSystem.hxx" +#include "RleException.h" + +#include "StreetsOfRageII2Players.hpp" +#include + + +using namespace rle; + + +StreetsOfRageII2PlayersSettings::StreetsOfRageII2PlayersSettings() { + reset(); + + minimalActions = {JOYPAD_NOOP, + // Moving + JOYPAD_DOWN, //Walk down + JOYPAD_UP, // Walk up + // JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + JOYPAD_GENESIS_C, // Jump + JOYPAD_LEFT | JOYPAD_GENESIS_C, + JOYPAD_RIGHT | JOYPAD_GENESIS_C, + // + // // Special attacks + JOYPAD_GENESIS_A, + // JOYPAD_LEFT | JOYPAD_GENESIS_A, + JOYPAD_RIGHT |JOYPAD_GENESIS_A, + // + // // Regular Attacks + JOYPAD_GENESIS_B, + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + // + // // Attacks when holding enemy + //JOYPAD_GENESIS_B | JOYPAD_LEFT, + JOYPAD_GENESIS_B | JOYPAD_RIGHT, + }; +} + + +/* create a new instance of the rom */ +RomSettings* StreetsOfRageII2PlayersSettings::clone() const { + RomSettings* rval = new StreetsOfRageII2PlayersSettings(); + *rval = *this; + return rval; +} + + +void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { +// Begin code for testing + if(system.settings()->getBool("SOR2_test") == true){ + // Fix Agent health + writeRam(&system, 0xEF80, 0x68); + // Make invincible + writeRam(&system, 0xEF50, 0x14); + // Freeze Time + writeRam(&system, 0xFC3C, 0x99); + } + +// This setting gives all enemies minimal health + if((system.settings()->getBool("SOR2_test") == true) || system.settings()->getInt("SOR2_difficulty") == 0){ + // Fix enemy health + writeRam(&system, 0xF180, 0x0); + writeRam(&system, 0xF280, 0x0); + writeRam(&system, 0xF380, 0x0); + writeRam(&system, 0xF480, 0x0); + writeRam(&system, 0xF580, 0x0); +} +// End code for testing + +// Read out current score (Score set to 0. Will read score from RAM in rle/gym wrapper) + reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); + m_lives = readRam(&system, 0xEF82); + m_health = readRam(&system, 0xEF80); + +// Update the reward + m_reward = score - m_score; + m_score = score; + +// Update terminal status + if (m_lives == 255){ + std::cout << "game_over" << std::endl; + m_terminal = true; + } + // Get level information + m_current_level = (readRam(&system, 0xFC42) / 2) + 1; + m_end_level = system.settings()->getInt("SOR2_end_level"); + +// int screen = readRam(&system, 0xFC02); + int m_progress_1 = readRam(&system, 0xFC44); + int m_progress_2 = readRam(&system, 0xFCCE); + + // Get boss information + int boss_health = readRam(&system, 0xF180); + int boss_lives = readRam(&system, 0xF182); + + if ((system.settings()->getString("SOR2_1p_terminal_win") == "round_clear")){ + if (((m_current_level - 1) == m_end_level) && (m_progress_1 == 0) && (m_progress_2 > 10)){ + std::cout << "Round "<< m_current_level << " clear!" << std::endl; + m_terminal = true; + } + }// Level 1 + else if ((m_end_level == 1) && (m_current_level == 1)) { + if ((m_progress_1 == 12) && (m_progress_2 == 12) && ((boss_health + boss_lives) == 0)){ + std::cout << "Beat level 1" << std::endl; + m_terminal = true; + } + }// Level 2 + else if ((m_end_level == 2) && (m_current_level == 2) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 12) && (m_progress_2 == 12)){ + std::cout << "Beat level 2" << std::endl; + m_terminal = true; + } + }// Level 3 + else if ((m_end_level == 3) && (m_current_level == 3) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 16) && (m_progress_2 == 16)){ + std::cout << "Beat level 3" << std::endl; + m_terminal = true; + } + }// Level 4 + else if ((m_end_level == 4) && (m_current_level == 4) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 22) && (m_progress_2 == 22)){ + std::cout << "Beat level 4" << std::endl; + m_terminal = true; + } + }// Level 5 + else if ((m_end_level == 5) && (m_current_level == 5) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 10) && (m_progress_2 == 10)){ + std::cout << "Beat level 4" << std::endl; + m_terminal = true; + } + }// Level 6 + else if ((m_end_level == 6) && (m_current_level == 6) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 10) && (m_progress_2 == 10)){ + std::cout << "Beat level 4" << std::endl; + m_terminal = true; + } + }// Level 7 + else if ((m_end_level == 7) && (m_current_level == 7) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 18) && (m_progress_2 == 18)){ + std::cout << "Beat level 4" << std::endl; + m_terminal = true; + } + }// Level 8 + else if ((m_end_level == 8) && (m_current_level == 8) && ((boss_health + boss_lives) == 0) ){ + if ((m_progress_1 == 10) && (m_progress_2 == 10)){ + std::cout << "Beat level 4" << std::endl; + m_terminal = true; + } + } +} + +/* reset the state of the game */ +void StreetsOfRageII2PlayersSettings::reset() { + m_reward = 0; + m_score = 0; + m_terminal = false; +} + + +/* saves the state of the rom settings */ +void StreetsOfRageII2PlayersSettings::saveState( Serializer & ser ) { + ser.putInt(m_reward); + ser.putInt(m_score); + ser.putBool(m_terminal); +} + + +// loads the state of the rom settings +void StreetsOfRageII2PlayersSettings::loadState( Deserializer & des ) { + m_reward = des.getInt(); + m_score = des.getInt(); + m_terminal = des.getBool(); +} + + +ActionVect StreetsOfRageII2PlayersSettings::getStartingActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + + // wait for intro to end + INSERT_NOPS(5 * num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(0.4*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(0.5*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_DOWN) + INSERT_NOPS(0.5*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(3 * num_of_nops) + // + string player_1 = system.settings()->getString("SOR2_player_1_character"); + string player_2 = system.settings()->getString("SOR2_player_2_character"); + + if(("axel" == player_1) && ("blaze" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if(("axel" == player_1) && ("skate" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if(("axel" == player_1) && ("max" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_LEFT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if(("blaze" == player_1) && ("skate" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + }else if(("blaze" == player_1) && ("max" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_LEFT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + }else if(("blaze" == player_1) && ("axel" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_LEFT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if(("max" == player_1) && ("blaze" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_LEFT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if(("max" == player_1) && ("axel" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_LEFT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_LEFT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if(("max" == player_1) && ("skate" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_LEFT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if(("skate" == player_1) && ("blaze" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if(("skate" == player_1) && ("axel" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_LEFT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if(("skate" == player_1) && ("max" == player_2)){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + } + return startingActions; +} + + void StreetsOfRageII2PlayersSettings::startingOperations(RleSystem& system){ + //set difficulty + m_difficulty = system.settings()->getInt("SOR2_difficulty"); + if(0 == m_difficulty){ + // Also setting enemy health low (see above). + writeRam(&system, 0xFD04, 0x0); + }else if(1 == m_difficulty){ + writeRam(&system, 0xFD04, 0x0); + }else if(2 == m_difficulty){ + writeRam(&system, 0xFD04, 0x2); + }else if(3 == m_difficulty){ + writeRam(&system, 0xFD04, 0x4); + }else if(4 == m_difficulty){ + writeRam(&system, 0xFD04, 0x6); + }else if(5 == m_difficulty){ + writeRam(&system, 0xFD04, 0x8); + }else if(6 == m_difficulty){ + writeRam(&system, 0xFD04, 0x0A); + } + + // Set number of continues. By Default continues set to zero. + writeRam(&system,0xEFA4, 0x0); + + // Set start level + m_start_level = system.settings()->getInt("SOR2_start_level"); + writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); + + // Set number of lives + m_lives = system.settings()->getInt("SOR2_lives"); + writeRam(&system, 0xFD06, (m_lives-1) * 0x1); + } + + +ActionVect StreetsOfRageII2PlayersSettings::getExtraActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + +// wait for level to begin + INSERT_NOPS(4 * num_of_nops) + + return startingActions; +} diff --git a/src/games/supported/StreetsOfRageII2Players.hpp b/src/games/supported/StreetsOfRageII2Players.hpp new file mode 100644 index 0000000..d9c4989 --- /dev/null +++ b/src/games/supported/StreetsOfRageII2Players.hpp @@ -0,0 +1,82 @@ +/* ***************************************************************************** + * The line 67 is based on Xitari's code, from Google Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ + +#ifndef __STREETS_OF_RAGE_II_TWO_PLAYERS_SETTINGS_HPP__ +#define __STREETS_OF_RAGE_II_TWO_PLAYERS_SETTINGS_HPP__ +/* RL wrapper for AtariCollection settings */ + +#include "../GenesisSettings.hpp" +#include + +namespace rle { + +class StreetsOfRageII2PlayersSettings : public GenesisSettings { + + public: + + StreetsOfRageII2PlayersSettings(); + + // reset + void reset(); + + // the rom-name + const char* rom() const { return "streets_of_rage_ii_2_players"; } + + // create a new instance of the rom + RomSettings* clone() const; + + // process the latest information from ALE + void step(const RleSystem& system); + + + // saves the state of the rom settings + void saveState( Serializer & ser ); + + + // loads the state of the rom settings + void loadState( Deserializer & des ); + + virtual const int lives() { return 0; } + + virtual ActionVect getStartingActions(const RleSystem& system); + + virtual ActionVect getExtraActions(const RleSystem& system); + + void startingOperations(RleSystem& system); + private: + reward_t m_score; + int m_start_level; + int m_end_level; + int m_current_level; + int m_lives; + int m_health; + int m_difficulty; +}; + +} // namespace rle + +#endif // __STREETS_OF_RAGE_II_TWO_PLAYERS_SETTINGS_HPP__ From 0d5f890ff72542acbc81a95619797bc9bdfeeff6 Mon Sep 17 00:00:00 2001 From: Jon Michaux Date: Sun, 24 Dec 2017 08:55:07 -0600 Subject: [PATCH 22/29] updated SOR settings --- src/environment/Settings.cxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index af32db3..2d8ff41 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -342,12 +342,24 @@ void Settings::setDefaultSettings() { intSettings.emplace(std::make_pair("SOR2_end_level", 4)); intSettings.emplace(std::make_pair("SOR2_difficulty", 3)); intSettings.emplace(std::make_pair("SOR2_lives", 3)); - stringSettings.emplace(std::make_pair("SOR2_player_1_character", "max")); - stringSettings.emplace(std::make_pair("SOR2_player_2_character", "axel")); + stringSettings.emplace(std::make_pair("SOR2_player_1_character", "skate")); + stringSettings.emplace(std::make_pair("SOR2_player_2_character", "blaze")); stringSettings.emplace(std::make_pair("SOR2_1p_terminal_win", "round_clear")); stringSettings.emplace(std::make_pair("SOR2_2p_terminal_win", "round_clear")); stringSettings.emplace(std::make_pair("SOR2_2p_terminal_lose", "one")); //"one" or "both" +// Streets of Rage, Streets of Rage II, and Streets of Rage III + boolSettings.emplace(std::make_pair("SOR_test", true)); + intSettings.emplace(std::make_pair("SOR_start_level", 4)); + intSettings.emplace(std::make_pair("SOR_end_level", 4)); + intSettings.emplace(std::make_pair("SOR_difficulty", 3)); + intSettings.emplace(std::make_pair("SOR_lives", 3)); + stringSettings.emplace(std::make_pair("SOR_player_1_character", "skate")); + stringSettings.emplace(std::make_pair("SOR_player_2_character", "blaze")); + stringSettings.emplace(std::make_pair("SOR_1p_terminal_win", "round_clear")); + stringSettings.emplace(std::make_pair("SOR_2p_terminal_win", "round_clear")); + stringSettings.emplace(std::make_pair("SOR_2p_terminal_lose", "one")); //"one" or "both" + // Super Mario Kart stringSettings.emplace(std::make_pair("SUPER_MARIO_KART_player1_character", "bowser")); From da6a69d4762c573eadf8848d1dc33559b70ca45a Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Sun, 24 Dec 2017 11:03:17 -0600 Subject: [PATCH 23/29] added SOR2 multiplayer. updated settings to work for SOR1-3. --- src/environment/Settings.cxx | 19 +--- src/games/supported/StreetsOfRageII.cpp | 84 +++++++++------- .../supported/StreetsOfRageII2Players.cpp | 99 ++++++++++++------- .../supported/StreetsOfRageII2Players.hpp | 7 +- 4 files changed, 119 insertions(+), 90 deletions(-) diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index 2d8ff41..f4cc0c0 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -336,29 +336,18 @@ void Settings::setDefaultSettings() { stringSettings.emplace(std::make_pair("MK_player2_character", "scorpion")); intSettings.emplace(std::make_pair("MK_opponent_character", 0)); - // Streets Of Rage 2 - boolSettings.emplace(std::make_pair("SOR2_test", true)); - intSettings.emplace(std::make_pair("SOR2_start_level", 4)); - intSettings.emplace(std::make_pair("SOR2_end_level", 4)); - intSettings.emplace(std::make_pair("SOR2_difficulty", 3)); - intSettings.emplace(std::make_pair("SOR2_lives", 3)); - stringSettings.emplace(std::make_pair("SOR2_player_1_character", "skate")); - stringSettings.emplace(std::make_pair("SOR2_player_2_character", "blaze")); - stringSettings.emplace(std::make_pair("SOR2_1p_terminal_win", "round_clear")); - stringSettings.emplace(std::make_pair("SOR2_2p_terminal_win", "round_clear")); - stringSettings.emplace(std::make_pair("SOR2_2p_terminal_lose", "one")); //"one" or "both" // Streets of Rage, Streets of Rage II, and Streets of Rage III - boolSettings.emplace(std::make_pair("SOR_test", true)); + boolSettings.emplace(std::make_pair("SOR_verbose", false)); + boolSettings.emplace(std::make_pair("SOR_test", false)); intSettings.emplace(std::make_pair("SOR_start_level", 4)); intSettings.emplace(std::make_pair("SOR_end_level", 4)); intSettings.emplace(std::make_pair("SOR_difficulty", 3)); intSettings.emplace(std::make_pair("SOR_lives", 3)); stringSettings.emplace(std::make_pair("SOR_player_1_character", "skate")); stringSettings.emplace(std::make_pair("SOR_player_2_character", "blaze")); - stringSettings.emplace(std::make_pair("SOR_1p_terminal_win", "round_clear")); - stringSettings.emplace(std::make_pair("SOR_2p_terminal_win", "round_clear")); - stringSettings.emplace(std::make_pair("SOR_2p_terminal_lose", "one")); //"one" or "both" + boolSettings.emplace(std::make_pair("SOR_round_clear", true)); + boolSettings.emplace(std::make_pair("SOR_2p_terminal_both_win", true)); // Super Mario Kart stringSettings.emplace(std::make_pair("SUPER_MARIO_KART_player1_character", "bowser")); diff --git a/src/games/supported/StreetsOfRageII.cpp b/src/games/supported/StreetsOfRageII.cpp index 0b614cf..dbbaf9d 100644 --- a/src/games/supported/StreetsOfRageII.cpp +++ b/src/games/supported/StreetsOfRageII.cpp @@ -63,24 +63,26 @@ RomSettings* StreetsOfRageIISettings::clone() const { void StreetsOfRageIISettings::step(const RleSystem& system) { // Begin code for testing - if(system.settings()->getBool("SOR2_test") == true){ + if(system.settings()->getBool("SOR_test") == true){ // Fix Agent health writeRam(&system, 0xEF80, 0x68); // Make invincible writeRam(&system, 0xEF50, 0x14); // Freeze Time - writeRam(&system, 0xFC3C, 0x99); + //writeRam(&system, 0xFC3C, 0x99); } // This setting gives all enemies minimal health - if((system.settings()->getBool("SOR2_test") == true) || system.settings()->getInt("SOR2_difficulty") == 0){ + if((system.settings()->getBool("SOR_test") == true) || system.settings()->getInt("SOR_difficulty") == 0){ // Fix enemy health writeRam(&system, 0xF180, 0x0); writeRam(&system, 0xF280, 0x0); writeRam(&system, 0xF380, 0x0); writeRam(&system, 0xF480, 0x0); writeRam(&system, 0xF580, 0x0); + writeRam(&system, 0xF680, 0x0); } + // End code for testing // Read out current score (Score set to 0. Will read score from RAM in rle/gym wrapper) @@ -94,12 +96,14 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { // Update terminal status if (m_lives == 255){ - std::cout << "game_over" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Game over! Restarting." << std::endl; + } + m_terminal = true; } // Get level information m_current_level = (readRam(&system, 0xFC42) / 2) + 1; - m_end_level = system.settings()->getInt("SOR2_end_level"); + m_end_level = system.settings()->getInt("SOR_end_level"); // int screen = readRam(&system, 0xFC02); int m_progress_1 = readRam(&system, 0xFC44); @@ -109,60 +113,70 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { int boss_health = readRam(&system, 0xF180); int boss_lives = readRam(&system, 0xF182); - if ((system.settings()->getString("SOR2_1p_terminal_win") == "round_clear")){ + if ((system.settings()->getBool("SOR_round") == true) || (m_end_level == 8)){ if (((m_current_level - 1) == m_end_level) && (m_progress_1 == 0) && (m_progress_2 > 10)){ - std::cout << "Round "<< m_current_level << " clear!" << std::endl; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Round "<< m_endlevel << " clear!" << std::endl; + } m_terminal = true; } }// Level 1 else if ((m_end_level == 1) && (m_current_level == 1)) { if ((m_progress_1 == 12) && (m_progress_2 == 12) && ((boss_health + boss_lives) == 0)){ - std::cout << "Beat level 1" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; } }// Level 2 else if ((m_end_level == 2) && (m_current_level == 2) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 12) && (m_progress_2 == 12)){ - std::cout << "Beat level 2" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; } }// Level 3 else if ((m_end_level == 3) && (m_current_level == 3) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 16) && (m_progress_2 == 16)){ - std::cout << "Beat level 3" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; } }// Level 4 else if ((m_end_level == 4) && (m_current_level == 4) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 22) && (m_progress_2 == 22)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; - } + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; + } }// Level 5 else if ((m_end_level == 5) && (m_current_level == 5) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; } }// Level 6 else if ((m_end_level == 6) && (m_current_level == 6) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; } + m_terminal = true; + } }// Level 7 else if ((m_end_level == 7) && (m_current_level == 7) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 18) && (m_progress_2 == 18)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; - } - }// Level 8 - else if ((m_end_level == 8) && (m_current_level == 8) && ((boss_health + boss_lives) == 0) ){ - if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; - } - } + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; + } + } // Level 8 (see above) } /* reset the state of the game */ @@ -203,7 +217,7 @@ ActionVect StreetsOfRageIISettings::getStartingActions(const RleSystem& system){ INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(3 * num_of_nops) // - string player_1_character = system.settings()->getString("SOR2_player_1_character"); + string player_1_character = system.settings()->getString("SOR_player_1_character"); if("axel" == player_1_character){ INSERT_ACTION_SINGLE_A(JOYPAD_START) }else if("max" == player_1_character){ @@ -227,7 +241,7 @@ ActionVect StreetsOfRageIISettings::getStartingActions(const RleSystem& system){ void StreetsOfRageIISettings::startingOperations(RleSystem& system){ //set difficulty - m_difficulty = system.settings()->getInt("SOR2_difficulty"); + m_difficulty = system.settings()->getInt("SOR_difficulty"); if(0 == m_difficulty){ // Also setting enemy health low (see above). writeRam(&system, 0xFD04, 0x0); @@ -249,11 +263,11 @@ ActionVect StreetsOfRageIISettings::getStartingActions(const RleSystem& system){ writeRam(&system,0xEFA4, 0x0); // Set start level - m_start_level = system.settings()->getInt("SOR2_start_level"); + m_start_level = system.settings()->getInt("SOR_start_level"); writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); // Set number of lives - m_lives = system.settings()->getInt("SOR2_lives"); + m_lives = system.settings()->getInt("SOR_lives"); writeRam(&system, 0xFD06, (m_lives-1) * 0x1); } diff --git a/src/games/supported/StreetsOfRageII2Players.cpp b/src/games/supported/StreetsOfRageII2Players.cpp index 950fd1f..acd65b8 100644 --- a/src/games/supported/StreetsOfRageII2Players.cpp +++ b/src/games/supported/StreetsOfRageII2Players.cpp @@ -63,43 +63,57 @@ RomSettings* StreetsOfRageII2PlayersSettings::clone() const { void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { // Begin code for testing - if(system.settings()->getBool("SOR2_test") == true){ + if(system.settings()->getBool("SOR_test") == true){ // Fix Agent health writeRam(&system, 0xEF80, 0x68); // Make invincible writeRam(&system, 0xEF50, 0x14); + writeRam(&system, 0xF050, 0x14); // Freeze Time writeRam(&system, 0xFC3C, 0x99); } // This setting gives all enemies minimal health - if((system.settings()->getBool("SOR2_test") == true) || system.settings()->getInt("SOR2_difficulty") == 0){ + if((system.settings()->getBool("SOR_test") == true) || system.settings()->getInt("SOR_difficulty") == 0){ // Fix enemy health writeRam(&system, 0xF180, 0x0); writeRam(&system, 0xF280, 0x0); writeRam(&system, 0xF380, 0x0); writeRam(&system, 0xF480, 0x0); writeRam(&system, 0xF580, 0x0); + writeRam(&system, 0xF680, 0x0); } // End code for testing // Read out current score (Score set to 0. Will read score from RAM in rle/gym wrapper) reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); - m_lives = readRam(&system, 0xEF82); - m_health = readRam(&system, 0xEF80); + player_1_lives = readRam(&system, 0xEF82); + player_2_lives = readRam(&system, 0xF082); // Update the reward m_reward = score - m_score; m_score = score; // Update terminal status - if (m_lives == 255){ - std::cout << "game_over" << std::endl; + if (sytem.settings()->getBool("SOR_2p_terminal_both_win") == true){ + if((player_1_lives == 255) || (player_2_lives == 255)){ + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Game over! Restarting." << std::endl; + } + m_terminal = true; + } + }else{ + if((player_1_lives == 255) && (player_2_lives == 255)){ + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Game over! Restarting." << std::endl; + } m_terminal = true; + } } + // Get level information m_current_level = (readRam(&system, 0xFC42) / 2) + 1; - m_end_level = system.settings()->getInt("SOR2_end_level"); + m_end_level = system.settings()->getInt("SOR_end_level"); // int screen = readRam(&system, 0xFC02); int m_progress_1 = readRam(&system, 0xFC44); @@ -109,60 +123,70 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { int boss_health = readRam(&system, 0xF180); int boss_lives = readRam(&system, 0xF182); - if ((system.settings()->getString("SOR2_1p_terminal_win") == "round_clear")){ + if ((system.settings()->getBool("SOR_round_clear") == true) || (m_end_level == 8)){ if (((m_current_level - 1) == m_end_level) && (m_progress_1 == 0) && (m_progress_2 > 10)){ - std::cout << "Round "<< m_current_level << " clear!" << std::endl; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Round "<< m_end_level << " clear!" << std::endl; + } m_terminal = true; } }// Level 1 else if ((m_end_level == 1) && (m_current_level == 1)) { if ((m_progress_1 == 12) && (m_progress_2 == 12) && ((boss_health + boss_lives) == 0)){ - std::cout << "Beat level 1" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; } }// Level 2 else if ((m_end_level == 2) && (m_current_level == 2) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 12) && (m_progress_2 == 12)){ - std::cout << "Beat level 2" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; } }// Level 3 else if ((m_end_level == 3) && (m_current_level == 3) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 16) && (m_progress_2 == 16)){ - std::cout << "Beat level 3" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; } }// Level 4 else if ((m_end_level == 4) && (m_current_level == 4) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 22) && (m_progress_2 == 22)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; - } + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; + } }// Level 5 else if ((m_end_level == 5) && (m_current_level == 5) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; } }// Level 6 else if ((m_end_level == 6) && (m_current_level == 6) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; } + m_terminal = true; + } }// Level 7 else if ((m_end_level == 7) && (m_current_level == 7) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 18) && (m_progress_2 == 18)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; - } - }// Level 8 - else if ((m_end_level == 8) && (m_current_level == 8) && ((boss_health + boss_lives) == 0) ){ - if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - std::cout << "Beat level 4" << std::endl; - m_terminal = true; - } - } + if (system.settings()->getBool("SOR_verbose") == true){ + std::cout << "Beat level " << m_current_level << std::endl; + } + m_terminal = true; + } + }// Level 8 (see above) } /* reset the state of the game */ @@ -204,8 +228,8 @@ ActionVect StreetsOfRageII2PlayersSettings::getStartingActions(const RleSystem& INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(3 * num_of_nops) // - string player_1 = system.settings()->getString("SOR2_player_1_character"); - string player_2 = system.settings()->getString("SOR2_player_2_character"); + string player_1 = system.settings()->getString("SOR_player_1_character"); + string player_2 = system.settings()->getString("SOR_player_2_character"); if(("axel" == player_1) && ("blaze" == player_2)){ INSERT_ACTION_SINGLE(JOYPAD_START, A) @@ -295,7 +319,7 @@ ActionVect StreetsOfRageII2PlayersSettings::getStartingActions(const RleSystem& void StreetsOfRageII2PlayersSettings::startingOperations(RleSystem& system){ //set difficulty - m_difficulty = system.settings()->getInt("SOR2_difficulty"); + m_difficulty = system.settings()->getInt("SOR_difficulty"); if(0 == m_difficulty){ // Also setting enemy health low (see above). writeRam(&system, 0xFD04, 0x0); @@ -315,13 +339,14 @@ ActionVect StreetsOfRageII2PlayersSettings::getStartingActions(const RleSystem& // Set number of continues. By Default continues set to zero. writeRam(&system,0xEFA4, 0x0); + writeRam(&system, 0xF0A4, 0x0); // Set start level - m_start_level = system.settings()->getInt("SOR2_start_level"); + m_start_level = system.settings()->getInt("SOR_start_level"); writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); // Set number of lives - m_lives = system.settings()->getInt("SOR2_lives"); + m_lives = system.settings()->getInt("SOR_lives"); writeRam(&system, 0xFD06, (m_lives-1) * 0x1); } diff --git a/src/games/supported/StreetsOfRageII2Players.hpp b/src/games/supported/StreetsOfRageII2Players.hpp index d9c4989..ab4d259 100644 --- a/src/games/supported/StreetsOfRageII2Players.hpp +++ b/src/games/supported/StreetsOfRageII2Players.hpp @@ -69,12 +69,13 @@ class StreetsOfRageII2PlayersSettings : public GenesisSettings { void startingOperations(RleSystem& system); private: reward_t m_score; + int m_difficulty; int m_start_level; int m_end_level; int m_current_level; - int m_lives; - int m_health; - int m_difficulty; + int player_1_lives; + int player_2_lives; + }; } // namespace rle From 603023059567d1336508bdf8fb3eca6c5bc1021a Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Sun, 24 Dec 2017 15:42:45 -0600 Subject: [PATCH 24/29] adding more SOR stuff --- src/environment/Settings.cxx | 36 +++++++++---- src/games/Roms.cpp | 2 + src/games/supported/StreetsOfRageII.cpp | 50 +++++++++---------- .../supported/StreetsOfRageII2Players.cpp | 16 +++--- .../supported/StreetsOfRageII2Players.hpp | 1 + 5 files changed, 61 insertions(+), 44 deletions(-) diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index f4cc0c0..843f99b 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -337,17 +337,31 @@ void Settings::setDefaultSettings() { intSettings.emplace(std::make_pair("MK_opponent_character", 0)); -// Streets of Rage, Streets of Rage II, and Streets of Rage III - boolSettings.emplace(std::make_pair("SOR_verbose", false)); - boolSettings.emplace(std::make_pair("SOR_test", false)); - intSettings.emplace(std::make_pair("SOR_start_level", 4)); - intSettings.emplace(std::make_pair("SOR_end_level", 4)); - intSettings.emplace(std::make_pair("SOR_difficulty", 3)); - intSettings.emplace(std::make_pair("SOR_lives", 3)); - stringSettings.emplace(std::make_pair("SOR_player_1_character", "skate")); - stringSettings.emplace(std::make_pair("SOR_player_2_character", "blaze")); - boolSettings.emplace(std::make_pair("SOR_round_clear", true)); - boolSettings.emplace(std::make_pair("SOR_2p_terminal_both_win", true)); +// Streets of Rage II + boolSettings.emplace(std::make_pair("SOR2_verbose", false)); + boolSettings.emplace(std::make_pair("SOR2_test", false)); + intSettings.emplace(std::make_pair("SOR2_start_level", 8)); + intSettings.emplace(std::make_pair("SOR2_end_level", 8)); + intSettings.emplace(std::make_pair("SOR2_difficulty", 5)); + intSettings.emplace(std::make_pair("SOR2_lives", 1)); + stringSettings.emplace(std::make_pair("SOR2_player_1_character", "skate")); + stringSettings.emplace(std::make_pair("SOR2_player_2_character", "blaze")); + boolSettings.emplace(std::make_pair("SOR2_round_clear", true)); + boolSettings.emplace(std::make_pair("SOR2_2p_terminal_both_win", true)); + + +// Streets of Rage III + boolSettings.emplace(std::make_pair("SOR3_verbose", false)); + boolSettings.emplace(std::make_pair("SOR3_test", true)); + intSettings.emplace(std::make_pair("SOR3_start_level", 5)); + intSettings.emplace(std::make_pair("SOR3_end_level", 5)); + intSettings.emplace(std::make_pair("SOR3_difficulty", 5)); + intSettings.emplace(std::make_pair("SOR3_lives", 1)); + stringSettings.emplace(std::make_pair("SOR3_player_1_character", "skate")); + stringSettings.emplace(std::make_pair("SOR3_player_2_character", "blaze")); + boolSettings.emplace(std::make_pair("SOR3_round_clear", false)); + boolSettings.emplace(std::make_pair("SOR3_2p_terminal_both_win", true)); + // Super Mario Kart stringSettings.emplace(std::make_pair("SUPER_MARIO_KART_player1_character", "bowser")); diff --git a/src/games/Roms.cpp b/src/games/Roms.cpp index 074b337..0a6bc09 100644 --- a/src/games/Roms.cpp +++ b/src/games/Roms.cpp @@ -42,6 +42,7 @@ #include "supported/SonicTheHedgehog.hpp" #include "supported/StreetsOfRageII.hpp" #include "supported/StreetsOfRageII2Players.hpp" +#include "supported/StreetsOfRageIII.hpp" // Atari Games //#include "supported/Breakout.hpp" @@ -189,6 +190,7 @@ static const RomSettings *roms[] = { new SonicTheHedgehogSettings(), new StreetsOfRageIISettings(), new StreetsOfRageII2PlayersSettings(), + new StreetsOfRageIIISettings(), }; diff --git a/src/games/supported/StreetsOfRageII.cpp b/src/games/supported/StreetsOfRageII.cpp index dbbaf9d..76b3123 100644 --- a/src/games/supported/StreetsOfRageII.cpp +++ b/src/games/supported/StreetsOfRageII.cpp @@ -63,7 +63,7 @@ RomSettings* StreetsOfRageIISettings::clone() const { void StreetsOfRageIISettings::step(const RleSystem& system) { // Begin code for testing - if(system.settings()->getBool("SOR_test") == true){ + if(system.settings()->getBool("SOR2_test") == true){ // Fix Agent health writeRam(&system, 0xEF80, 0x68); // Make invincible @@ -73,7 +73,7 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { } // This setting gives all enemies minimal health - if((system.settings()->getBool("SOR_test") == true) || system.settings()->getInt("SOR_difficulty") == 0){ + if((system.settings()->getBool("SOR2_test") == true) || system.settings()->getInt("SOR2_difficulty") == 0){ // Fix enemy health writeRam(&system, 0xF180, 0x0); writeRam(&system, 0xF280, 0x0); @@ -96,14 +96,14 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { // Update terminal status if (m_lives == 255){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Game over! Restarting." << std::endl; } m_terminal = true; } // Get level information m_current_level = (readRam(&system, 0xFC42) / 2) + 1; - m_end_level = system.settings()->getInt("SOR_end_level"); + m_end_level = system.settings()->getInt("SOR2_end_level"); // int screen = readRam(&system, 0xFC02); int m_progress_1 = readRam(&system, 0xFC44); @@ -113,66 +113,66 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { int boss_health = readRam(&system, 0xF180); int boss_lives = readRam(&system, 0xF182); - if ((system.settings()->getBool("SOR_round") == true) || (m_end_level == 8)){ + if ((system.settings()->getBool("SOR2_round") == true) || (m_end_level == 8)){ if (((m_current_level - 1) == m_end_level) && (m_progress_1 == 0) && (m_progress_2 > 10)){ - if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Round "<< m_endlevel << " clear!" << std::endl; + if (system.settings()->getBool("SOR2_verbose") == true){ + std::cout << "Round "<< m_end_level << " clear!" << std::endl; } m_terminal = true; } }// Level 1 else if ((m_end_level == 1) && (m_current_level == 1)) { if ((m_progress_1 == 12) && (m_progress_2 == 12) && ((boss_health + boss_lives) == 0)){ - if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + if (system.settings()->getBool("SOR2_verbose") == true){ + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } }// Level 2 else if ((m_end_level == 2) && (m_current_level == 2) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 12) && (m_progress_2 == 12)){ - if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + if (system.settings()->getBool("SOR2_verbose") == true){ + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } }// Level 3 else if ((m_end_level == 3) && (m_current_level == 3) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 16) && (m_progress_2 == 16)){ - if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + if (system.settings()->getBool("SOR2_verbose") == true){ + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } }// Level 4 else if ((m_end_level == 4) && (m_current_level == 4) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 22) && (m_progress_2 == 22)){ - if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + if (system.settings()->getBool("SOR2_verbose") == true){ + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } }// Level 5 else if ((m_end_level == 5) && (m_current_level == 5) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + if (system.settings()->getBool("SOR2_verbose") == true){ + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } }// Level 6 else if ((m_end_level == 6) && (m_current_level == 6) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + if (system.settings()->getBool("SOR2_verbose") == true){ + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } }// Level 7 else if ((m_end_level == 7) && (m_current_level == 7) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 18) && (m_progress_2 == 18)){ - if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + if (system.settings()->getBool("SOR2_verbose") == true){ + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } @@ -217,7 +217,7 @@ ActionVect StreetsOfRageIISettings::getStartingActions(const RleSystem& system){ INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(3 * num_of_nops) // - string player_1_character = system.settings()->getString("SOR_player_1_character"); + string player_1_character = system.settings()->getString("SOR2_player_1_character"); if("axel" == player_1_character){ INSERT_ACTION_SINGLE_A(JOYPAD_START) }else if("max" == player_1_character){ @@ -241,7 +241,7 @@ ActionVect StreetsOfRageIISettings::getStartingActions(const RleSystem& system){ void StreetsOfRageIISettings::startingOperations(RleSystem& system){ //set difficulty - m_difficulty = system.settings()->getInt("SOR_difficulty"); + m_difficulty = system.settings()->getInt("SOR2_difficulty"); if(0 == m_difficulty){ // Also setting enemy health low (see above). writeRam(&system, 0xFD04, 0x0); @@ -263,11 +263,11 @@ ActionVect StreetsOfRageIISettings::getStartingActions(const RleSystem& system){ writeRam(&system,0xEFA4, 0x0); // Set start level - m_start_level = system.settings()->getInt("SOR_start_level"); + m_start_level = system.settings()->getInt("SOR2_start_level"); writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); // Set number of lives - m_lives = system.settings()->getInt("SOR_lives"); + m_lives = system.settings()->getInt("SOR2_lives"); writeRam(&system, 0xFD06, (m_lives-1) * 0x1); } diff --git a/src/games/supported/StreetsOfRageII2Players.cpp b/src/games/supported/StreetsOfRageII2Players.cpp index acd65b8..84e9e0d 100644 --- a/src/games/supported/StreetsOfRageII2Players.cpp +++ b/src/games/supported/StreetsOfRageII2Players.cpp @@ -95,7 +95,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { m_score = score; // Update terminal status - if (sytem.settings()->getBool("SOR_2p_terminal_both_win") == true){ + if (system.settings()->getBool("SOR_2p_terminal_both_win") == true){ if((player_1_lives == 255) || (player_2_lives == 255)){ if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Game over! Restarting." << std::endl; @@ -134,7 +134,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { else if ((m_end_level == 1) && (m_current_level == 1)) { if ((m_progress_1 == 12) && (m_progress_2 == 12) && ((boss_health + boss_lives) == 0)){ if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } @@ -142,7 +142,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { else if ((m_end_level == 2) && (m_current_level == 2) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 12) && (m_progress_2 == 12)){ if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } @@ -150,7 +150,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { else if ((m_end_level == 3) && (m_current_level == 3) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 16) && (m_progress_2 == 16)){ if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } @@ -158,7 +158,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { else if ((m_end_level == 4) && (m_current_level == 4) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 22) && (m_progress_2 == 22)){ if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } @@ -166,7 +166,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { else if ((m_end_level == 5) && (m_current_level == 5) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } @@ -174,7 +174,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { else if ((m_end_level == 6) && (m_current_level == 6) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } @@ -182,7 +182,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { else if ((m_end_level == 7) && (m_current_level == 7) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 18) && (m_progress_2 == 18)){ if (system.settings()->getBool("SOR_verbose") == true){ - std::cout << "Beat level " << m_current_level << std::endl; + std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } diff --git a/src/games/supported/StreetsOfRageII2Players.hpp b/src/games/supported/StreetsOfRageII2Players.hpp index ab4d259..0ac53f5 100644 --- a/src/games/supported/StreetsOfRageII2Players.hpp +++ b/src/games/supported/StreetsOfRageII2Players.hpp @@ -70,6 +70,7 @@ class StreetsOfRageII2PlayersSettings : public GenesisSettings { private: reward_t m_score; int m_difficulty; + int m_lives; int m_start_level; int m_end_level; int m_current_level; From 3c0c545c3bb94478fb419e54107accfbee129689 Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Sun, 24 Dec 2017 19:57:29 -0600 Subject: [PATCH 25/29] adding SOR3 --- src/games/supported/StreetsOfRageIII.cpp | 364 +++++++++++++++++++++++ src/games/supported/StreetsOfRageIII.hpp | 84 ++++++ 2 files changed, 448 insertions(+) create mode 100644 src/games/supported/StreetsOfRageIII.cpp create mode 100644 src/games/supported/StreetsOfRageIII.hpp diff --git a/src/games/supported/StreetsOfRageIII.cpp b/src/games/supported/StreetsOfRageIII.cpp new file mode 100644 index 0000000..ac1872f --- /dev/null +++ b/src/games/supported/StreetsOfRageIII.cpp @@ -0,0 +1,364 @@ +/* ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ +#include "../RomUtils.hpp" +#include + +#include "../RomUtils.hpp" + +#include "RleSystem.hxx" +#include "RleException.h" + +#include "StreetsOfRageIII.hpp" +#include + + +using namespace rle; + + +StreetsOfRageIIISettings::StreetsOfRageIIISettings() { + reset(); + +// Actions can also be set in a RLE gym wrapper + minimalActions = {JOYPAD_NOOP, + // Moving + // JOYPAD_DOWN, //Walk down + // JOYPAD_UP, // Walk up + // JOYPAD_LEFT, // Walk left + // JOYPAD_RIGHT, // Walk right + // JOYPAD_GENESIS_C, // Jump + // JOYPAD_LEFT | JOYPAD_GENESIS_C, + // JOYPAD_RIGHT | JOYPAD_GENESIS_C, + + // // Special attacks + // JOYPAD_GENESIS_A, + // JOYPAD_LEFT | JOYPAD_GENESIS_A, + JOYPAD_RIGHT |JOYPAD_GENESIS_A, + + // // Regular Attacks + // JOYPAD_GENESIS_B, + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + + // // Attacks when holding enemy + // JOYPAD_GENESIS_B | JOYPAD_LEFT, + // JOYPAD_GENESIS_B | JOYPAD_RIGHT, + }; +} + + +/* create a new instance of the rom */ +RomSettings* StreetsOfRageIIISettings::clone() const { + RomSettings* rval = new StreetsOfRageIIISettings(); + *rval = *this; + return rval; +} + + +void StreetsOfRageIIISettings::step(const RleSystem& system) { +// Begin code for testing + if(system.settings()->getBool("SOR3_test") == true){ + + // Fix Agent health + writeRam(&system, 0xDF6D, 0x34); + + // Make invincible + writeRam(&system, 0xDF5D, 0xFF); + + // Freeze Time + // writeRam(&system, 0xFC3C, 0x99); +} + +// This setting gives all enemies minimal health and lives + if((system.settings()->getBool("SOR3_test") == true) || system.settings()->getInt("SOR3_difficulty") == 0){ + // Fix enemy health and lives + + writeRam(&system, 0xE16D, 0x0); + writeRam(&system, 0xE26D, 0x0); + writeRam(&system, 0xE36D, 0x0); + writeRam(&system, 0xE46D, 0x0); + writeRam(&system, 0xE56D, 0x0); + // writeRam(&system, 0xE18B, 0x0); + // writeRam(&system, 0xE28B, 0x0); + // writeRam(&system, 0xE38B, 0x0); + // writeRam(&system, 0xE48B, 0x0); + // writeRam(&system, 0xE58B, 0x0); + + } +// End code for testing + +// Read out current score, health, lives, kills +// Score set to 0. Will read score from rle/gym wrapper + reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); + +// update the reward + m_reward = score - m_score; + m_score = score; + + m_screen = 0; + + if ((readRam(&system, 0xDFA1) == 255) && readRam(&system, 0xFB00) == 14){ + m_screen = 2; + std::cout << "LOST GAME" << std::endl; + m_terminal = true; + } + + // Get level information + m_current_level = readRam(&system, 0xFB04) + 1; + m_end_level = system.settings()->getInt("SOR3_end_level"); + + // Get information on agent position + int m_position = 256 * readRam(&system, 0xDF41) + readRam(&system, 0xDF40); + int scene = readRam(&system, 0xFB02); + m_screen = readRam(&system, 0xFB00); + + std::cout << m_position << std::endl; + + // Get boss information + int boss_1_ID = readRam(&system, 0xE10C); + int boss_present = readRam(&system, 0xE10C) + readRam(&system, 0xE20C) + readRam(&system, 0xE30C); + int boss_1_health = readRam(&system, 0xE16D); + int boss_2_health = readRam(&system, 0xE26D); + int boss_3_health = readRam(&system, 0xE36D); + int boss_health = boss_1_health + boss_2_health + boss_3_health; + int boss_1_lives = readRam(&system, 0xE18A); + int boss_lives = readRam(&system, 0xE18A) + readRam(&system, 0xE28A) + readRam(&system, 0xE38A); + + // Win if we accidentily go past the end level + if(m_end_level < m_current_level){ + std::cout << "ADVANCED TO NEXT LEVEL" << std::endl; + m_terminal = true; + } + // Win if round clear + if ((system.settings()->getBool("SOR3_round_clear") == true) && ((m_current_level != 7) || (m_current_level != 8))){ + if ((m_end_level == m_current_level) && (readRam(&system, 0xFB00) == 46)){ + std::cout << "ROUND CLEAR!" << std::endl; + m_terminal = true; + } + }else{ + // Win if agent is in right place, with bosses present, and bosses dead + if((m_end_level == 1) && (m_current_level == 1)){ + if ((scene == 2) && (m_position > 456) && (boss_present > 0) && ((boss_1_health + boss_1_lives == 0))){ + m_terminal = true; + } + }else if ((m_end_level == 2) && (m_current_level == 2)){ + if ((scene == 2) && (m_position > 100) && (boss_present > 0) && ((boss_health + boss_lives) == 0) ){ + std::cout << " won game!" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 3) && (m_current_level == 3)){ + if ((scene == 2) && (m_position > 400) && (boss_present > 0) && ((boss_1_health + boss_1_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 4) && (m_current_level == 4)){ + if ((scene == 2) && (m_position> 300) && (boss_present > 0) && ((boss_1_health + boss_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 5) && (m_current_level == 5)){ + if ((scene == 7) && (m_position > 30) && (boss_1_ID == 56) && ((boss_1_health + boss_1_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 6) && (m_current_level == 6)){ + if ((scene == 7) && (m_position > 50) && (boss_present > 0) && ((boss_1_health + boss_1_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 7) && (m_current_level == 7)){ + if ((scene == 4) && (m_position > 30) && (boss_present > 0) && ((boss_1_health + boss_1_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 8) && (m_current_level == 8)){ + if ((scene == 3) && (m_position > 30) && (boss_present > 0) && ((boss_1_health + boss_1_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + } + + } +} + + +/* reset the state of the game */ +void StreetsOfRageIIISettings::reset() { + m_reward = 0; + m_score = 0; + m_terminal = false; +} + + +/* saves the state of the rom settings */ +void StreetsOfRageIIISettings::saveState( Serializer & ser ) { + ser.putInt(m_reward); + ser.putInt(m_score); + ser.putBool(m_terminal); +} + + +// loads the state of the rom settings +void StreetsOfRageIIISettings::loadState( Deserializer & des ) { + m_reward = des.getInt(); + m_score = des.getInt(); + m_terminal = des.getBool(); +} + + +ActionVect StreetsOfRageIIISettings::getStartingActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + +// // Wait for intro to end + if (m_screen > 0){ + INSERT_NOPS(7 * num_of_nops) + }else{ + INSERT_NOPS(9 * num_of_nops) + if (system.settings()->getBool("SOR3_test") == true){ + INSERT_NOPS(2 * num_of_nops) + } + } + + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(1.8 * num_of_nops) + + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(2 * num_of_nops) + +// // // // Choose Player 1 character + string player_1_character = system.settings()->getString("SOR3_player_1_character"); + if("axel" == player_1_character){ + //INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("zan" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_LEFT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + // INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("blaze" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + // INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("skate" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + // INSERT_ACTION_SINGLE_A(JOYPAD_START) + } + INSERT_NOPS(1 * num_of_nops) + +return startingActions; +} + + +void StreetsOfRageIIISettings::startingOperations(RleSystem& system){ + /*This function sets the difficulty, number of continues, starting level, + and number of lives by writing directly to RAM*/ + + //set difficulty + m_difficulty = system.settings()->getInt("SOR3_difficulty"); + // Also setting enemy health low (see above). + if(0 == m_difficulty){ + writeRam(&system, 0xFF08, 0x2); + }else if(1 == m_difficulty){ + writeRam(&system, 0xFF08, 0x2); + }else if(2 == m_difficulty){ + writeRam(&system, 0xFF08, 0x4); + }else if(3 == m_difficulty){ + writeRam(&system, 0xFF08, 0x6); + }else if(4 == m_difficulty){ + writeRam(&system, 0xFF08, 0x8); + }else if(5 == m_difficulty){ + writeRam(&system, 0xFF08, 0x0A); + } + + //set number of continues. By Default continues set to zero. + writeRam(&system, 0xDFA0, 0x1); + + // //set start level for testing or to access Levels 7 and 8 + m_start_level = system.settings()->getInt("SOR3_start_level"); + if(m_start_level == 1){ + writeRam(&system, 0xFB04, 0x0); + }else if(m_start_level == 2){ + writeRam(&system, 0xFB04, 0x1); + }else if(m_start_level == 3){ + writeRam(&system, 0xFB04, 0x2); + }else if(m_start_level == 4){ + writeRam(&system, 0xFB04, 0x3); + }else if (m_start_level == 5){ + writeRam(&system, 0xFB04, 0x4); + }else if (m_start_level == 6){ + writeRam(&system, 0xFB04, 0x5); + }else if(m_start_level == 7){ + writeRam(&system, 0xFB04, 0x6); + writeRam(&system, 0xFB02, 0x1); + }else if (m_start_level == 8){ + writeRam(&system, 0xFB04, 0x7); + writeRam(&system, 0xFB02, 0x1); + } + + if(system.settings()->getBool("SOR3_test") == true){ + // Max out the difficulty + writeRam(&system, 0xFF08, 0x0A); + // Go to the last scene of the chosen level + if(m_start_level == 1){ + writeRam(&system, 0xFB02, 0x2); + }else if(m_start_level == 2){ + writeRam(&system, 0xFB02, 0x2); + }else if(m_start_level == 3){ + writeRam(&system, 0xFB02, 0x2); + }else if(m_start_level == 4){ + writeRam(&system, 0xFB02, 0x2); + }else if (m_start_level == 5){ + writeRam(&system, 0xFB02, 0x7); + }else if (m_start_level == 6){ + writeRam(&system, 0xFB02, 0x7); + }else if(m_start_level == 7){ + writeRam(&system, 0xFB02, 0x4); + }else if (m_start_level == 8){ + writeRam(&system, 0xFB02, 0x3); + } + } + + // // Set number of lives + m_lives = system.settings()->getInt("SOR3_lives"); + writeRam(&system, 0xDF8A, (m_lives - 1) * 0x1); +} + +ActionVect StreetsOfRageIIISettings::getExtraActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + + INSERT_ACTION_SINGLE_A(JOYPAD_START) + +// wait for level to begin + int start_level = system.settings()->getInt("SOR3_start_level"); + if (start_level == 1){ + INSERT_NOPS(3 * num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(4 * num_of_nops) + }else if (start_level == 2){ + INSERT_NOPS(3.5 * num_of_nops) + }else if (start_level == 3){ + INSERT_NOPS(4.6 * num_of_nops) + }else if (start_level ==4){ + INSERT_NOPS(3.7 * num_of_nops) + }else if (start_level == 5){ + INSERT_NOPS(3.7 * num_of_nops) + }else if (start_level == 6){ + INSERT_NOPS(3.7 * num_of_nops) + }else if (start_level == 7){ + INSERT_NOPS(1 * num_of_nops) + }else if (start_level == 8){ + INSERT_NOPS(4 * num_of_nops) + } + + return startingActions; +} \ No newline at end of file diff --git a/src/games/supported/StreetsOfRageIII.hpp b/src/games/supported/StreetsOfRageIII.hpp new file mode 100644 index 0000000..95734a2 --- /dev/null +++ b/src/games/supported/StreetsOfRageIII.hpp @@ -0,0 +1,84 @@ +/* ***************************************************************************** + * The line 67 is based on Xitari's code, from Google Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ + +#ifndef __STREETS_OF_RAGE_III_SETTINGS_HPP__ +#define __STREETS_OF_RAGE_III_SETTINGS_HPP__ +/* RL wrapper for AtariCollection settings */ + +#include "../GenesisSettings.hpp" +#include + +namespace rle { + +class StreetsOfRageIIISettings : public GenesisSettings { + + public: + + StreetsOfRageIIISettings(); + + // reset + void reset(); + + // the rom-name + const char* rom() const { return "streets_of_rage_iii"; } + + // create a new instance of the rom + RomSettings* clone() const; + + // process the latest information from ALE + void step(const RleSystem& system); + + + // saves the state of the rom settings + void saveState( Serializer & ser ); + + + // loads the state of the rom settings + void loadState( Deserializer & des ); + + + virtual const int lives() { return 0; } + + virtual ActionVect getStartingActions(const RleSystem& system); + virtual ActionVect getExtraActions(const RleSystem& system); + + void startingOperations(RleSystem& system); + private: + reward_t m_score; + int m_start_level; + int m_end_level; + int m_current_level; + int m_lives; + int m_health; + int m_difficulty; + int m_screen; + +}; + +} // namespace rle + +#endif // __STREETS_OF_RAGE_III_SETTINGS_HPP__ From 9d0aa9b27ea11b6206979065e9feb19830361220 Mon Sep 17 00:00:00 2001 From: Jon Michaux Date: Tue, 26 Dec 2017 10:19:56 -0600 Subject: [PATCH 26/29] updated SOR2 2 players and fixed SOR3 reset problem --- src/environment/Settings.cxx | 24 ++++---- .../supported/StreetsOfRageII2Players.cpp | 42 ++++++------- src/games/supported/StreetsOfRageIII.cpp | 60 ++++++++++++------- 3 files changed, 71 insertions(+), 55 deletions(-) diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index 843f99b..d2d68c7 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -344,23 +344,23 @@ void Settings::setDefaultSettings() { intSettings.emplace(std::make_pair("SOR2_end_level", 8)); intSettings.emplace(std::make_pair("SOR2_difficulty", 5)); intSettings.emplace(std::make_pair("SOR2_lives", 1)); - stringSettings.emplace(std::make_pair("SOR2_player_1_character", "skate")); + stringSettings.emplace(std::make_pair("SOR2_player_1_character", "axel")); stringSettings.emplace(std::make_pair("SOR2_player_2_character", "blaze")); boolSettings.emplace(std::make_pair("SOR2_round_clear", true)); - boolSettings.emplace(std::make_pair("SOR2_2p_terminal_both_win", true)); + boolSettings.emplace(std::make_pair("SOR2_2p_terminal_both_win", true)); // Streets of Rage III - boolSettings.emplace(std::make_pair("SOR3_verbose", false)); - boolSettings.emplace(std::make_pair("SOR3_test", true)); - intSettings.emplace(std::make_pair("SOR3_start_level", 5)); - intSettings.emplace(std::make_pair("SOR3_end_level", 5)); - intSettings.emplace(std::make_pair("SOR3_difficulty", 5)); - intSettings.emplace(std::make_pair("SOR3_lives", 1)); - stringSettings.emplace(std::make_pair("SOR3_player_1_character", "skate")); - stringSettings.emplace(std::make_pair("SOR3_player_2_character", "blaze")); - boolSettings.emplace(std::make_pair("SOR3_round_clear", false)); - boolSettings.emplace(std::make_pair("SOR3_2p_terminal_both_win", true)); + boolSettings.emplace(std::make_pair("SOR3_verbose", false)); + boolSettings.emplace(std::make_pair("SOR3_test", false)); + intSettings.emplace(std::make_pair("SOR3_start_level", 1)); + intSettings.emplace(std::make_pair("SOR3_end_level", 1)); + intSettings.emplace(std::make_pair("SOR3_difficulty", 5)); + intSettings.emplace(std::make_pair("SOR3_lives", 1)); + stringSettings.emplace(std::make_pair("SOR3_player_1_character", "zan")); + stringSettings.emplace(std::make_pair("SOR3_player_2_character", "blaze")); + boolSettings.emplace(std::make_pair("SOR3_round_clear", false)); + boolSettings.emplace(std::make_pair("SOR3_2p_terminal_both_win", true)); // Super Mario Kart diff --git a/src/games/supported/StreetsOfRageII2Players.cpp b/src/games/supported/StreetsOfRageII2Players.cpp index 84e9e0d..73154cb 100644 --- a/src/games/supported/StreetsOfRageII2Players.cpp +++ b/src/games/supported/StreetsOfRageII2Players.cpp @@ -63,7 +63,7 @@ RomSettings* StreetsOfRageII2PlayersSettings::clone() const { void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { // Begin code for testing - if(system.settings()->getBool("SOR_test") == true){ + if(system.settings()->getBool("SOR2_test") == true){ // Fix Agent health writeRam(&system, 0xEF80, 0x68); // Make invincible @@ -74,7 +74,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { } // This setting gives all enemies minimal health - if((system.settings()->getBool("SOR_test") == true) || system.settings()->getInt("SOR_difficulty") == 0){ + if((system.settings()->getBool("SOR2_test") == true) || system.settings()->getInt("SOR2_difficulty") == 0){ // Fix enemy health writeRam(&system, 0xF180, 0x0); writeRam(&system, 0xF280, 0x0); @@ -95,16 +95,16 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { m_score = score; // Update terminal status - if (system.settings()->getBool("SOR_2p_terminal_both_win") == true){ + if (system.settings()->getBool("SOR2_2p_terminal_both_win") == true){ if((player_1_lives == 255) || (player_2_lives == 255)){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Game over! Restarting." << std::endl; } m_terminal = true; } }else{ if((player_1_lives == 255) && (player_2_lives == 255)){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Game over! Restarting." << std::endl; } m_terminal = true; @@ -113,7 +113,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { // Get level information m_current_level = (readRam(&system, 0xFC42) / 2) + 1; - m_end_level = system.settings()->getInt("SOR_end_level"); + m_end_level = system.settings()->getInt("SOR2_end_level"); // int screen = readRam(&system, 0xFC02); int m_progress_1 = readRam(&system, 0xFC44); @@ -123,9 +123,9 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { int boss_health = readRam(&system, 0xF180); int boss_lives = readRam(&system, 0xF182); - if ((system.settings()->getBool("SOR_round_clear") == true) || (m_end_level == 8)){ + if ((system.settings()->getBool("SOR2_round_clear") == true) || (m_end_level == 8)){ if (((m_current_level - 1) == m_end_level) && (m_progress_1 == 0) && (m_progress_2 > 10)){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Round "<< m_end_level << " clear!" << std::endl; } m_terminal = true; @@ -133,7 +133,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 1 else if ((m_end_level == 1) && (m_current_level == 1)) { if ((m_progress_1 == 12) && (m_progress_2 == 12) && ((boss_health + boss_lives) == 0)){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -141,7 +141,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 2 else if ((m_end_level == 2) && (m_current_level == 2) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 12) && (m_progress_2 == 12)){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -149,7 +149,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 3 else if ((m_end_level == 3) && (m_current_level == 3) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 16) && (m_progress_2 == 16)){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -157,7 +157,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 4 else if ((m_end_level == 4) && (m_current_level == 4) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 22) && (m_progress_2 == 22)){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -165,7 +165,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 5 else if ((m_end_level == 5) && (m_current_level == 5) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -173,7 +173,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 6 else if ((m_end_level == 6) && (m_current_level == 6) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -181,12 +181,12 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 7 else if ((m_end_level == 7) && (m_current_level == 7) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 18) && (m_progress_2 == 18)){ - if (system.settings()->getBool("SOR_verbose") == true){ + if (system.settings()->getBool("SOR2_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; } - }// Level 8 (see above) + }// Level 8 (see above) } /* reset the state of the game */ @@ -228,8 +228,8 @@ ActionVect StreetsOfRageII2PlayersSettings::getStartingActions(const RleSystem& INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(3 * num_of_nops) // - string player_1 = system.settings()->getString("SOR_player_1_character"); - string player_2 = system.settings()->getString("SOR_player_2_character"); + string player_1 = system.settings()->getString("SOR2_player_1_character"); + string player_2 = system.settings()->getString("SOR2_player_2_character"); if(("axel" == player_1) && ("blaze" == player_2)){ INSERT_ACTION_SINGLE(JOYPAD_START, A) @@ -319,7 +319,7 @@ ActionVect StreetsOfRageII2PlayersSettings::getStartingActions(const RleSystem& void StreetsOfRageII2PlayersSettings::startingOperations(RleSystem& system){ //set difficulty - m_difficulty = system.settings()->getInt("SOR_difficulty"); + m_difficulty = system.settings()->getInt("SOR2_difficulty"); if(0 == m_difficulty){ // Also setting enemy health low (see above). writeRam(&system, 0xFD04, 0x0); @@ -342,11 +342,11 @@ ActionVect StreetsOfRageII2PlayersSettings::getStartingActions(const RleSystem& writeRam(&system, 0xF0A4, 0x0); // Set start level - m_start_level = system.settings()->getInt("SOR_start_level"); + m_start_level = system.settings()->getInt("SOR2_start_level"); writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); // Set number of lives - m_lives = system.settings()->getInt("SOR_lives"); + m_lives = system.settings()->getInt("SOR2_lives"); writeRam(&system, 0xFD06, (m_lives-1) * 0x1); } diff --git a/src/games/supported/StreetsOfRageIII.cpp b/src/games/supported/StreetsOfRageIII.cpp index ac1872f..1ca6221 100644 --- a/src/games/supported/StreetsOfRageIII.cpp +++ b/src/games/supported/StreetsOfRageIII.cpp @@ -41,7 +41,7 @@ StreetsOfRageIIISettings::StreetsOfRageIIISettings() { // // Special attacks // JOYPAD_GENESIS_A, // JOYPAD_LEFT | JOYPAD_GENESIS_A, - JOYPAD_RIGHT |JOYPAD_GENESIS_A, + JOYPAD_RIGHT |JOYPAD_GENESIS_A, // // Regular Attacks // JOYPAD_GENESIS_B, @@ -63,6 +63,10 @@ RomSettings* StreetsOfRageIIISettings::clone() const { void StreetsOfRageIIISettings::step(const RleSystem& system) { +// if (readRam(&system, 0xFB00) != 14){ +// m_terminal = true; +// } + // Begin code for testing if(system.settings()->getBool("SOR3_test") == true){ @@ -79,12 +83,14 @@ void StreetsOfRageIIISettings::step(const RleSystem& system) { // This setting gives all enemies minimal health and lives if((system.settings()->getBool("SOR3_test") == true) || system.settings()->getInt("SOR3_difficulty") == 0){ // Fix enemy health and lives - + writeRam(&system, 0xE16D, 0x0); writeRam(&system, 0xE26D, 0x0); writeRam(&system, 0xE36D, 0x0); writeRam(&system, 0xE46D, 0x0); writeRam(&system, 0xE56D, 0x0); + writeRam(&system, 0xE66D, 0x0); + // writeRam(&system, 0xE18B, 0x0); // writeRam(&system, 0xE28B, 0x0); // writeRam(&system, 0xE38B, 0x0); @@ -102,10 +108,9 @@ void StreetsOfRageIIISettings::step(const RleSystem& system) { m_reward = score - m_score; m_score = score; - m_screen = 0; if ((readRam(&system, 0xDFA1) == 255) && readRam(&system, 0xFB00) == 14){ - m_screen = 2; + // m_screen = 2; std::cout << "LOST GAME" << std::endl; m_terminal = true; } @@ -115,12 +120,10 @@ void StreetsOfRageIIISettings::step(const RleSystem& system) { m_end_level = system.settings()->getInt("SOR3_end_level"); // Get information on agent position - int m_position = 256 * readRam(&system, 0xDF41) + readRam(&system, 0xDF40); - int scene = readRam(&system, 0xFB02); + int m_position = 256 * readRam(&system, 0xDF41) + readRam(&system, 0xDF40); + int scene = readRam(&system, 0xFB02); m_screen = readRam(&system, 0xFB00); - std::cout << m_position << std::endl; - // Get boss information int boss_1_ID = readRam(&system, 0xE10C); int boss_present = readRam(&system, 0xE10C) + readRam(&system, 0xE20C) + readRam(&system, 0xE30C); @@ -218,17 +221,28 @@ ActionVect StreetsOfRageIIISettings::getStartingActions(const RleSystem& system) ActionVect startingActions; // // Wait for intro to end - if (m_screen > 0){ - INSERT_NOPS(7 * num_of_nops) - }else{ - INSERT_NOPS(9 * num_of_nops) - if (system.settings()->getBool("SOR3_test") == true){ - INSERT_NOPS(2 * num_of_nops) - } - } - + // if (m_screen > 0){ + // INSERT_NOPS(7 * num_of_nops) + // }else{ + // INSERT_NOPS(9 * num_of_nops) + // // if (system.settings()->getBool("SOR3_test") == true){ + // // INSERT_NOPS(2 * num_of_nops) + // // } + // } + + std::cout << readRam(&system, 0xFB00) << std::endl; + + INSERT_NOPS((3 - readRam(&system, 0xFB00)) * num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) - INSERT_NOPS(1.8 * num_of_nops) + + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(2 * num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(2 * num_of_nops) + + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(2 * num_of_nops) INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(2 * num_of_nops) @@ -253,7 +267,7 @@ ActionVect StreetsOfRageIIISettings::getStartingActions(const RleSystem& system) // INSERT_ACTION_SINGLE_A(JOYPAD_START) } INSERT_NOPS(1 * num_of_nops) - + return startingActions; } @@ -336,9 +350,11 @@ ActionVect StreetsOfRageIIISettings::getExtraActions(const RleSystem& system){ int num_of_nops(100); ActionVect startingActions; - INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(1 * num_of_nops) -// wait for level to begin + INSERT_ACTION_SINGLE_A(JOYPAD_START) +// +// // wait for level to begin int start_level = system.settings()->getInt("SOR3_start_level"); if (start_level == 1){ INSERT_NOPS(3 * num_of_nops) @@ -361,4 +377,4 @@ ActionVect StreetsOfRageIIISettings::getExtraActions(const RleSystem& system){ } return startingActions; -} \ No newline at end of file +} From 9c845ca307e1e67b986302f3c5bd8f24567f206b Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Tue, 26 Dec 2017 14:03:05 -0600 Subject: [PATCH 27/29] added SOR single and two players --- src/environment/Settings.cxx | 13 + src/games/supported/StreetsOfRage.cpp | 184 ++++++++++++++ src/games/supported/StreetsOfRage.hpp | 80 +++++++ src/games/supported/StreetsOfRage2Players.cpp | 225 ++++++++++++++++++ src/games/supported/StreetsOfRage2Players.hpp | 83 +++++++ 5 files changed, 585 insertions(+) create mode 100644 src/games/supported/StreetsOfRage.cpp create mode 100644 src/games/supported/StreetsOfRage.hpp create mode 100644 src/games/supported/StreetsOfRage2Players.cpp create mode 100644 src/games/supported/StreetsOfRage2Players.hpp diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index d2d68c7..e135f01 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -337,6 +337,19 @@ void Settings::setDefaultSettings() { intSettings.emplace(std::make_pair("MK_opponent_character", 0)); +// Streets of Rage + boolSettings.emplace(std::make_pair("SOR_verbose", false)); + boolSettings.emplace(std::make_pair("SOR_test", false)); + intSettings.emplace(std::make_pair("SOR_start_level", 3)); + intSettings.emplace(std::make_pair("SOR_end_level", 3)); + intSettings.emplace(std::make_pair("SOR_difficulty", 4)); + intSettings.emplace(std::make_pair("SOR_lives", 5)); + stringSettings.emplace(std::make_pair("SOR_player_1_character", "blaze")); + stringSettings.emplace(std::make_pair("SOR_player_2_character", "axel")); + boolSettings.emplace(std::make_pair("SOR_round_clear", true)); + boolSettings.emplace(std::make_pair("SOR_2p_terminal_both_win", true)); + + // Streets of Rage II boolSettings.emplace(std::make_pair("SOR2_verbose", false)); boolSettings.emplace(std::make_pair("SOR2_test", false)); diff --git a/src/games/supported/StreetsOfRage.cpp b/src/games/supported/StreetsOfRage.cpp new file mode 100644 index 0000000..436dbca --- /dev/null +++ b/src/games/supported/StreetsOfRage.cpp @@ -0,0 +1,184 @@ +/* ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ +#include "../RomUtils.hpp" +#include + +#include "../RomUtils.hpp" + +#include "RleSystem.hxx" +#include "RleException.h" + +#include "StreetsOfRage.hpp" +#include + + +using namespace rle; + + +StreetsOfRageSettings::StreetsOfRageSettings() { + reset(); + + + + minimalActions = {JOYPAD_NOOP, + // JOYPAD_DOWN, //Walk down + // JOYPAD_UP, // Walk up + // JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + +// JOYPAD_GENESIS_A, // Special attack + // JOYPAD_GENESIS_B, // Regular attack + + // JOYPAD_GENESIS_C, // Jump + + // JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right + + // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + // JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + // JOYPAD_GENESIS_B | JOYPAD_RIGHT, + // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack + + }; +} + + +/* create a new instance of the rom */ +RomSettings* StreetsOfRageSettings::clone() const { + RomSettings* rval = new StreetsOfRageSettings(); + *rval = *this; + return rval; +} + + +void StreetsOfRageSettings::step(const RleSystem& system) { +// Read out current score, health, lives, stage progress + reward_t score = 0; + reward_t health = readRam(&system, 0xB832); + reward_t screen = readRam(&system, 0xFF00); + reward_t distance = getDecimalScore(0xB810, &system); + m_lives = readRam(&system, 0xFF21); + +// update the reward + m_reward = score; + +// Update terminal status + if ((m_lives == 0) && (health == 0) && (screen == 22)){ + std::cout << "fail" << std::endl; + m_terminal = true; + } + + // Get level information + m_current_level = readRam(&system, 0xFF02) + 1; + int m_end_level = system.settings()->getInt("SOR_end_level"); + + // Update terminal status + if ((m_current_level == m_end_level) && (screen == 24)){ + m_terminal=true; + } +} +/* reset the state of the game */ +void StreetsOfRageSettings::reset(){ + m_reward = 0; +// m_score = 0; + m_terminal = false; + m_distance = 0; +} + + +/* saves the state of the rom settings */ +void StreetsOfRageSettings::saveState( Serializer & ser ) { + ser.putInt(m_reward); + ser.putInt(m_score); + ser.putBool(m_terminal); +} + + +// loads the state of the rom settings +void StreetsOfRageSettings::loadState( Deserializer & des ) { + m_reward = des.getInt(); + m_score = des.getInt(); + m_terminal = des.getBool(); +} + + +ActionVect StreetsOfRageSettings::getStartingActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + +// wait for intro to end + INSERT_NOPS(5*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(0.4*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + + + // select 1 player + INSERT_NOPS(1*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(4*num_of_nops) + + +// choose character + string player_1_character = system.settings()->getString("SOR_player_1_character"); + if("adam" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("axel" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_RIGHT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if("blaze" == player_1_character){ + INSERT_ACTION_SINGLE_A(JOYPAD_LEFT) + INSERT_ACTION_SINGLE_A(JOYPAD_NOOP) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + } + + INSERT_NOPS(0.5 * num_of_nops) + + return startingActions; +} + + + +void StreetsOfRageSettings::startingOperations(RleSystem& system){ + //set number of lives (Can be 1, 3, 5, or 7) + int num_lives = system.settings()->getInt("SOR_lives"); + writeRam(&system, 0xFFCA, ((num_lives - 1) / 2 ) * 0x1); + + //set difficulty + int difficulty = system.settings()->getInt("SOR_difficulty"); + if(1 == difficulty){ + writeRam(&system, 0xFFC6, 0x0); + }else if(2 == difficulty){ + writeRam(&system, 0xFFC6, 0x1); + }else if(3 == difficulty){ + writeRam(&system, 0xFFC6, 0x2); + }else if(4 == difficulty){ + writeRam(&system, 0xFFC6, 0x3); + } + + //set start level + int start_level = system.settings()->getInt("SOR_start_level"); + writeRam(&system, 0xFF02, (start_level-1)* 0x1); + +} + +ActionVect StreetsOfRageSettings::getExtraActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + +// wait for level to begin + INSERT_NOPS(4.5 * num_of_nops) + + + return startingActions; +} \ No newline at end of file diff --git a/src/games/supported/StreetsOfRage.hpp b/src/games/supported/StreetsOfRage.hpp new file mode 100644 index 0000000..873c597 --- /dev/null +++ b/src/games/supported/StreetsOfRage.hpp @@ -0,0 +1,80 @@ +/* ***************************************************************************** + * The line 67 is based on Xitari's code, from Google Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ + +#ifndef __STREETS_OF_RAGE_SETTINGS_HPP__ +#define __STREETS_OF_RAGE_SETTINGS_HPP__ +/* RL wrapper for AtariCollection settings */ + +#include "../GenesisSettings.hpp" +#include + +namespace rle { + +class StreetsOfRageSettings : public GenesisSettings { + + public: + + StreetsOfRageSettings(); + + // reset + void reset(); + + // the rom-name + const char* rom() const { return "streets_of_rage"; } + + // create a new instance of the rom + RomSettings* clone() const; + + // process the latest information from ALE + void step(const RleSystem& system); + + + // saves the state of the rom settings + void saveState( Serializer & ser ); + + + // loads the state of the rom settings + void loadState( Deserializer & des ); + + + virtual const int lives() { return 0; } + + virtual ActionVect getStartingActions(const RleSystem& system); + + virtual ActionVect getExtraActions(const RleSystem& system); + + void startingOperations(RleSystem& system); + private: + int m_lives; + int m_current_level; + int m_distance; + int delta_distance; +}; + +} // namespace rle + +#endif // __STREETS_OF_RAGE_SETTINGS_HPP__ diff --git a/src/games/supported/StreetsOfRage2Players.cpp b/src/games/supported/StreetsOfRage2Players.cpp new file mode 100644 index 0000000..daa6a63 --- /dev/null +++ b/src/games/supported/StreetsOfRage2Players.cpp @@ -0,0 +1,225 @@ +/* ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ +#include "../RomUtils.hpp" +#include + +#include "../RomUtils.hpp" + +#include "RleSystem.hxx" +#include "RleException.h" + +#include "StreetsOfRage2Players.hpp" +#include + + +using namespace rle; + + +StreetsOfRage2PlayersSettings::StreetsOfRage2PlayersSettings() { + reset(); + + + + minimalActions = {JOYPAD_NOOP, + // JOYPAD_DOWN, //Walk down + // JOYPAD_UP, // Walk up + // JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + +// JOYPAD_GENESIS_A, // Special attack + // JOYPAD_GENESIS_B, // Regular attack + + // JOYPAD_GENESIS_C, // Jump + + // JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right + + // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + // JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + // JOYPAD_GENESIS_B | JOYPAD_RIGHT, + // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack + + }; +} + + +/* create a new instance of the rom */ +RomSettings* StreetsOfRage2PlayersSettings::clone() const { + RomSettings* rval = new StreetsOfRage2PlayersSettings(); + *rval = *this; + return rval; +} + + +void StreetsOfRage2PlayersSettings::step(const RleSystem& system) { +// Read out current score, health, lives, stage progress + reward_t score = 0; + player_1_health = readRam(&system, 0xB832); + player_2_health = readRam(&system, 0xB8B2); + player_1_lives = readRam(&system, 0xFF21); + player_2_lives = readRam(&system, 0xFF22); + screen = readRam(&system, 0xFF00); + distance = getDecimalScore(0xB810, &system); + + + // Update terminal status + if (system.settings()->getBool("SOR_2p_terminal_both_win") == true){ + if( ((player_1_health == 0) && (player_1_lives == 0))|| ((player_2_health == 0) && (player_2_lives == 0))){ + m_terminal = true; + } + }else{ + if((player_1_health == 0) && (player_1_lives == 0) && (player_2_health == 0) && (player_2_lives == 0)){ + m_terminal = true; + } + } + + // Get level information + m_current_level = readRam(&system, 0xFF02) + 1; + int m_end_level = system.settings()->getInt("SOR_end_level"); + + // Update terminal status + if ((m_current_level == m_end_level) && (screen == 24)){ + m_terminal=true; + } +} + +/* reset the state of the game */ +void StreetsOfRage2PlayersSettings::reset(){ + +// m_score = 0; + m_terminal = false; + distance = 0; +} + + +/* saves the state of the rom settings */ +void StreetsOfRage2PlayersSettings::saveState( Serializer & ser ) { + + ser.putInt(m_score); + ser.putBool(m_terminal); +} + + +// loads the state of the rom settings +void StreetsOfRage2PlayersSettings::loadState( Deserializer & des ) { + + m_score = des.getInt(); + m_terminal = des.getBool(); +} + + +ActionVect StreetsOfRage2PlayersSettings::getStartingActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + +// wait for intro to end + INSERT_NOPS(5*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(0.4*num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + + + // select 1 player + INSERT_NOPS(1 * num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_DOWN) + INSERT_NOPS(1 * num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(4*num_of_nops) + + +// choose character + string player_1 = system.settings()->getString("SOR_player_1_character"); + string player_2 = system.settings()->getString("SOR_player_2_character"); + + if((player_1 == "adam") && (player_2 == "blaze")){ + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if((player_1 == "adam") && (player_2 == "axel")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_LEFT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if((player_1 == "axel") && (player_2 == "adam")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if ((player_1 == "axel") && (player_2 == "blaze")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + }else if ((player_1 == "blaze") && (player_2 == "adam")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + } else if ((player_1 == "blaze") && (player_2 == "axel")){ + INSERT_ACTION_SINGLE(JOYPAD_LEFT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_START, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_LEFT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, A) + } + + INSERT_NOPS(0.5 * num_of_nops) + + return startingActions; +} + + + +void StreetsOfRage2PlayersSettings::startingOperations(RleSystem& system){ + //set number of lives (Can be 1, 3, 5, or 7) + int num_lives = system.settings()->getInt("SOR_lives"); + writeRam(&system, 0xFFCA, ((num_lives - 1) / 2 ) * 0x1); + + //set difficulty + int difficulty = system.settings()->getInt("SOR_difficulty"); + if(1 == difficulty){ + writeRam(&system, 0xFFC6, 0x0); + }else if(2 == difficulty){ + writeRam(&system, 0xFFC6, 0x1); + }else if(3 == difficulty){ + writeRam(&system, 0xFFC6, 0x2); + }else if(4 == difficulty){ + writeRam(&system, 0xFFC6, 0x3); + } + + //set start level + int start_level = system.settings()->getInt("SOR_start_level"); + writeRam(&system, 0xFF02, (start_level-1)* 0x1); + +} + +ActionVect StreetsOfRage2PlayersSettings::getExtraActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + +// wait for level to begin + INSERT_NOPS(4.5 * num_of_nops) + + + return startingActions; +} \ No newline at end of file diff --git a/src/games/supported/StreetsOfRage2Players.hpp b/src/games/supported/StreetsOfRage2Players.hpp new file mode 100644 index 0000000..6d33ba2 --- /dev/null +++ b/src/games/supported/StreetsOfRage2Players.hpp @@ -0,0 +1,83 @@ +/* ***************************************************************************** + * The line 67 is based on Xitari's code, from Google Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ + +#ifndef __STREETS_OF_RAGE_TWO_PLAYERS_SETTINGS_HPP__ +#define __STREETS_OF_RAGE_TWO_PLAYERS_SETTINGS_HPP__ +/* RL wrapper for AtariCollection settings */ + +#include "../GenesisSettings.hpp" +#include + +namespace rle { + +class StreetsOfRage2PlayersSettings : public GenesisSettings { + + public: + + StreetsOfRage2PlayersSettings(); + + // reset + void reset(); + + // the rom-name + const char* rom() const { return "streets_of_rage_2_players"; } + + // create a new instance of the rom + RomSettings* clone() const; + + // process the latest information from ALE + void step(const RleSystem& system); + + + // saves the state of the rom settings + void saveState( Serializer & ser ); + + + // loads the state of the rom settings + void loadState( Deserializer & des ); + + + virtual const int lives() { return 0; } + + virtual ActionVect getStartingActions(const RleSystem& system); + + virtual ActionVect getExtraActions(const RleSystem& system); + + void startingOperations(RleSystem& system); + private: + reward_t player_1_health; + reward_t player_2_health; + int player_1_lives; + int player_2_lives; + int m_current_level; + int distance; + int screen; +}; + +} // namespace rle + +#endif // __STREETS_OF_RAGE_TWO_PLAYERS_SETTINGS_HPP__ From 5250cba14df1f4418d13cb7213198a1b113d5d41 Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Tue, 26 Dec 2017 15:13:43 -0600 Subject: [PATCH 28/29] finished adding SOR3 two players --- src/environment/Settings.cxx | 40 +- src/games/Roms.cpp | 6 + src/games/supported/StreetsOfRageII.cpp | 34 +- .../supported/StreetsOfRageII2Players.cpp | 40 +- src/games/supported/StreetsOfRageIII.cpp | 39 +- .../supported/StreetsOfRageIII2Players.cpp | 426 ++++++++++++++++++ .../supported/StreetsOfRageIII2Players.hpp | 86 ++++ 7 files changed, 574 insertions(+), 97 deletions(-) create mode 100644 src/games/supported/StreetsOfRageIII2Players.cpp create mode 100644 src/games/supported/StreetsOfRageIII2Players.hpp diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index e135f01..3f77dd8 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -340,42 +340,16 @@ void Settings::setDefaultSettings() { // Streets of Rage boolSettings.emplace(std::make_pair("SOR_verbose", false)); boolSettings.emplace(std::make_pair("SOR_test", false)); - intSettings.emplace(std::make_pair("SOR_start_level", 3)); - intSettings.emplace(std::make_pair("SOR_end_level", 3)); - intSettings.emplace(std::make_pair("SOR_difficulty", 4)); - intSettings.emplace(std::make_pair("SOR_lives", 5)); - stringSettings.emplace(std::make_pair("SOR_player_1_character", "blaze")); - stringSettings.emplace(std::make_pair("SOR_player_2_character", "axel")); - boolSettings.emplace(std::make_pair("SOR_round_clear", true)); + intSettings.emplace(std::make_pair("SOR_start_level", 2)); + intSettings.emplace(std::make_pair("SOR_end_level", 2)); + intSettings.emplace(std::make_pair("SOR_difficulty", 1)); + intSettings.emplace(std::make_pair("SOR_lives", 3)); + stringSettings.emplace(std::make_pair("SOR_player_1_character", "axel")); + stringSettings.emplace(std::make_pair("SOR_player_2_character", "blaze")); + boolSettings.emplace(std::make_pair("SOR_round_clear", false)); boolSettings.emplace(std::make_pair("SOR_2p_terminal_both_win", true)); -// Streets of Rage II - boolSettings.emplace(std::make_pair("SOR2_verbose", false)); - boolSettings.emplace(std::make_pair("SOR2_test", false)); - intSettings.emplace(std::make_pair("SOR2_start_level", 8)); - intSettings.emplace(std::make_pair("SOR2_end_level", 8)); - intSettings.emplace(std::make_pair("SOR2_difficulty", 5)); - intSettings.emplace(std::make_pair("SOR2_lives", 1)); - stringSettings.emplace(std::make_pair("SOR2_player_1_character", "axel")); - stringSettings.emplace(std::make_pair("SOR2_player_2_character", "blaze")); - boolSettings.emplace(std::make_pair("SOR2_round_clear", true)); - boolSettings.emplace(std::make_pair("SOR2_2p_terminal_both_win", true)); - - -// Streets of Rage III - boolSettings.emplace(std::make_pair("SOR3_verbose", false)); - boolSettings.emplace(std::make_pair("SOR3_test", false)); - intSettings.emplace(std::make_pair("SOR3_start_level", 1)); - intSettings.emplace(std::make_pair("SOR3_end_level", 1)); - intSettings.emplace(std::make_pair("SOR3_difficulty", 5)); - intSettings.emplace(std::make_pair("SOR3_lives", 1)); - stringSettings.emplace(std::make_pair("SOR3_player_1_character", "zan")); - stringSettings.emplace(std::make_pair("SOR3_player_2_character", "blaze")); - boolSettings.emplace(std::make_pair("SOR3_round_clear", false)); - boolSettings.emplace(std::make_pair("SOR3_2p_terminal_both_win", true)); - - // Super Mario Kart stringSettings.emplace(std::make_pair("SUPER_MARIO_KART_player1_character", "bowser")); diff --git a/src/games/Roms.cpp b/src/games/Roms.cpp index 0a6bc09..910e353 100644 --- a/src/games/Roms.cpp +++ b/src/games/Roms.cpp @@ -40,9 +40,12 @@ // genesis games #include "supported/SonicTheHedgehog.hpp" +#include "supported/StreetsOfRage.hpp" +#include "supported/StreetsOfRage2Players.hpp" #include "supported/StreetsOfRageII.hpp" #include "supported/StreetsOfRageII2Players.hpp" #include "supported/StreetsOfRageIII.hpp" +#include "supported/StreetsOfRageIII2Players.hpp" // Atari Games //#include "supported/Breakout.hpp" @@ -188,9 +191,12 @@ static const RomSettings *roms[] = { //Genesis games new SonicTheHedgehogSettings(), + new StreetsOfRageSettings(), + new StreetsOfRage2PlayersSettings(), new StreetsOfRageIISettings(), new StreetsOfRageII2PlayersSettings(), new StreetsOfRageIIISettings(), + new StreetsOfRageIII2PlayersSettings(), }; diff --git a/src/games/supported/StreetsOfRageII.cpp b/src/games/supported/StreetsOfRageII.cpp index 76b3123..00e5fd1 100644 --- a/src/games/supported/StreetsOfRageII.cpp +++ b/src/games/supported/StreetsOfRageII.cpp @@ -63,7 +63,7 @@ RomSettings* StreetsOfRageIISettings::clone() const { void StreetsOfRageIISettings::step(const RleSystem& system) { // Begin code for testing - if(system.settings()->getBool("SOR2_test") == true){ + if(system.settings()->getBool("SOR_test") == true){ // Fix Agent health writeRam(&system, 0xEF80, 0x68); // Make invincible @@ -73,7 +73,7 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { } // This setting gives all enemies minimal health - if((system.settings()->getBool("SOR2_test") == true) || system.settings()->getInt("SOR2_difficulty") == 0){ + if((system.settings()->getBool("SOR_test") == true) || system.settings()->getInt("SOR_difficulty") == 0){ // Fix enemy health writeRam(&system, 0xF180, 0x0); writeRam(&system, 0xF280, 0x0); @@ -96,14 +96,14 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { // Update terminal status if (m_lives == 255){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Game over! Restarting." << std::endl; } m_terminal = true; } // Get level information m_current_level = (readRam(&system, 0xFC42) / 2) + 1; - m_end_level = system.settings()->getInt("SOR2_end_level"); + m_end_level = system.settings()->getInt("SOR_end_level"); // int screen = readRam(&system, 0xFC02); int m_progress_1 = readRam(&system, 0xFC44); @@ -113,9 +113,9 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { int boss_health = readRam(&system, 0xF180); int boss_lives = readRam(&system, 0xF182); - if ((system.settings()->getBool("SOR2_round") == true) || (m_end_level == 8)){ + if ((system.settings()->getBool("SOR_round") == true) || (m_end_level == 8)){ if (((m_current_level - 1) == m_end_level) && (m_progress_1 == 0) && (m_progress_2 > 10)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Round "<< m_end_level << " clear!" << std::endl; } m_terminal = true; @@ -123,7 +123,7 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { }// Level 1 else if ((m_end_level == 1) && (m_current_level == 1)) { if ((m_progress_1 == 12) && (m_progress_2 == 12) && ((boss_health + boss_lives) == 0)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -131,7 +131,7 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { }// Level 2 else if ((m_end_level == 2) && (m_current_level == 2) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 12) && (m_progress_2 == 12)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -139,7 +139,7 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { }// Level 3 else if ((m_end_level == 3) && (m_current_level == 3) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 16) && (m_progress_2 == 16)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -147,7 +147,7 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { }// Level 4 else if ((m_end_level == 4) && (m_current_level == 4) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 22) && (m_progress_2 == 22)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -155,7 +155,7 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { }// Level 5 else if ((m_end_level == 5) && (m_current_level == 5) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -163,7 +163,7 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { }// Level 6 else if ((m_end_level == 6) && (m_current_level == 6) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -171,7 +171,7 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { }// Level 7 else if ((m_end_level == 7) && (m_current_level == 7) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 18) && (m_progress_2 == 18)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -217,7 +217,7 @@ ActionVect StreetsOfRageIISettings::getStartingActions(const RleSystem& system){ INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(3 * num_of_nops) // - string player_1_character = system.settings()->getString("SOR2_player_1_character"); + string player_1_character = system.settings()->getString("SOR_player_1_character"); if("axel" == player_1_character){ INSERT_ACTION_SINGLE_A(JOYPAD_START) }else if("max" == player_1_character){ @@ -241,7 +241,7 @@ ActionVect StreetsOfRageIISettings::getStartingActions(const RleSystem& system){ void StreetsOfRageIISettings::startingOperations(RleSystem& system){ //set difficulty - m_difficulty = system.settings()->getInt("SOR2_difficulty"); + m_difficulty = system.settings()->getInt("SOR_difficulty"); if(0 == m_difficulty){ // Also setting enemy health low (see above). writeRam(&system, 0xFD04, 0x0); @@ -263,11 +263,11 @@ ActionVect StreetsOfRageIISettings::getStartingActions(const RleSystem& system){ writeRam(&system,0xEFA4, 0x0); // Set start level - m_start_level = system.settings()->getInt("SOR2_start_level"); + m_start_level = system.settings()->getInt("SOR_start_level"); writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); // Set number of lives - m_lives = system.settings()->getInt("SOR2_lives"); + m_lives = system.settings()->getInt("SOR_lives"); writeRam(&system, 0xFD06, (m_lives-1) * 0x1); } diff --git a/src/games/supported/StreetsOfRageII2Players.cpp b/src/games/supported/StreetsOfRageII2Players.cpp index 73154cb..e3f4da8 100644 --- a/src/games/supported/StreetsOfRageII2Players.cpp +++ b/src/games/supported/StreetsOfRageII2Players.cpp @@ -63,7 +63,7 @@ RomSettings* StreetsOfRageII2PlayersSettings::clone() const { void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { // Begin code for testing - if(system.settings()->getBool("SOR2_test") == true){ + if(system.settings()->getBool("SOR_test") == true){ // Fix Agent health writeRam(&system, 0xEF80, 0x68); // Make invincible @@ -74,7 +74,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { } // This setting gives all enemies minimal health - if((system.settings()->getBool("SOR2_test") == true) || system.settings()->getInt("SOR2_difficulty") == 0){ + if((system.settings()->getBool("SOR_test") == true) || system.settings()->getInt("SOR_difficulty") == 0){ // Fix enemy health writeRam(&system, 0xF180, 0x0); writeRam(&system, 0xF280, 0x0); @@ -95,16 +95,16 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { m_score = score; // Update terminal status - if (system.settings()->getBool("SOR2_2p_terminal_both_win") == true){ + if (system.settings()->getBool("SOR_2p_terminal_both_win") == true){ if((player_1_lives == 255) || (player_2_lives == 255)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Game over! Restarting." << std::endl; } m_terminal = true; } }else{ if((player_1_lives == 255) && (player_2_lives == 255)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Game over! Restarting." << std::endl; } m_terminal = true; @@ -113,7 +113,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { // Get level information m_current_level = (readRam(&system, 0xFC42) / 2) + 1; - m_end_level = system.settings()->getInt("SOR2_end_level"); + m_end_level = system.settings()->getInt("SOR_end_level"); // int screen = readRam(&system, 0xFC02); int m_progress_1 = readRam(&system, 0xFC44); @@ -123,9 +123,9 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { int boss_health = readRam(&system, 0xF180); int boss_lives = readRam(&system, 0xF182); - if ((system.settings()->getBool("SOR2_round_clear") == true) || (m_end_level == 8)){ + if ((system.settings()->getBool("SOR_round_clear") == true) || (m_end_level == 8)){ if (((m_current_level - 1) == m_end_level) && (m_progress_1 == 0) && (m_progress_2 > 10)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Round "<< m_end_level << " clear!" << std::endl; } m_terminal = true; @@ -133,7 +133,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 1 else if ((m_end_level == 1) && (m_current_level == 1)) { if ((m_progress_1 == 12) && (m_progress_2 == 12) && ((boss_health + boss_lives) == 0)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -141,7 +141,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 2 else if ((m_end_level == 2) && (m_current_level == 2) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 12) && (m_progress_2 == 12)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -149,7 +149,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 3 else if ((m_end_level == 3) && (m_current_level == 3) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 16) && (m_progress_2 == 16)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -157,7 +157,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 4 else if ((m_end_level == 4) && (m_current_level == 4) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 22) && (m_progress_2 == 22)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -165,7 +165,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 5 else if ((m_end_level == 5) && (m_current_level == 5) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -173,7 +173,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 6 else if ((m_end_level == 6) && (m_current_level == 6) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 10) && (m_progress_2 == 10)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -181,7 +181,7 @@ void StreetsOfRageII2PlayersSettings::step(const RleSystem& system) { }// Level 7 else if ((m_end_level == 7) && (m_current_level == 7) && ((boss_health + boss_lives) == 0) ){ if ((m_progress_1 == 18) && (m_progress_2 == 18)){ - if (system.settings()->getBool("SOR2_verbose") == true){ + if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Beat level " << m_end_level << std::endl; } m_terminal = true; @@ -228,8 +228,8 @@ ActionVect StreetsOfRageII2PlayersSettings::getStartingActions(const RleSystem& INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(3 * num_of_nops) // - string player_1 = system.settings()->getString("SOR2_player_1_character"); - string player_2 = system.settings()->getString("SOR2_player_2_character"); + string player_1 = system.settings()->getString("SOR_player_1_character"); + string player_2 = system.settings()->getString("SOR_player_2_character"); if(("axel" == player_1) && ("blaze" == player_2)){ INSERT_ACTION_SINGLE(JOYPAD_START, A) @@ -319,7 +319,7 @@ ActionVect StreetsOfRageII2PlayersSettings::getStartingActions(const RleSystem& void StreetsOfRageII2PlayersSettings::startingOperations(RleSystem& system){ //set difficulty - m_difficulty = system.settings()->getInt("SOR2_difficulty"); + m_difficulty = system.settings()->getInt("SOR_difficulty"); if(0 == m_difficulty){ // Also setting enemy health low (see above). writeRam(&system, 0xFD04, 0x0); @@ -342,11 +342,11 @@ ActionVect StreetsOfRageII2PlayersSettings::getStartingActions(const RleSystem& writeRam(&system, 0xF0A4, 0x0); // Set start level - m_start_level = system.settings()->getInt("SOR2_start_level"); + m_start_level = system.settings()->getInt("SOR_start_level"); writeRam(&system, 0xFD0E, (m_start_level-1) * 0x1); // Set number of lives - m_lives = system.settings()->getInt("SOR2_lives"); + m_lives = system.settings()->getInt("SOR_lives"); writeRam(&system, 0xFD06, (m_lives-1) * 0x1); } diff --git a/src/games/supported/StreetsOfRageIII.cpp b/src/games/supported/StreetsOfRageIII.cpp index 1ca6221..038928c 100644 --- a/src/games/supported/StreetsOfRageIII.cpp +++ b/src/games/supported/StreetsOfRageIII.cpp @@ -68,7 +68,7 @@ void StreetsOfRageIIISettings::step(const RleSystem& system) { // } // Begin code for testing - if(system.settings()->getBool("SOR3_test") == true){ + if(system.settings()->getBool("SOR_test") == true){ // Fix Agent health writeRam(&system, 0xDF6D, 0x34); @@ -81,7 +81,7 @@ void StreetsOfRageIIISettings::step(const RleSystem& system) { } // This setting gives all enemies minimal health and lives - if((system.settings()->getBool("SOR3_test") == true) || system.settings()->getInt("SOR3_difficulty") == 0){ + if((system.settings()->getBool("SOR_test") == true) || system.settings()->getInt("SOR_difficulty") == 0){ // Fix enemy health and lives writeRam(&system, 0xE16D, 0x0); @@ -117,7 +117,7 @@ void StreetsOfRageIIISettings::step(const RleSystem& system) { // Get level information m_current_level = readRam(&system, 0xFB04) + 1; - m_end_level = system.settings()->getInt("SOR3_end_level"); + m_end_level = system.settings()->getInt("SOR_end_level"); // Get information on agent position int m_position = 256 * readRam(&system, 0xDF41) + readRam(&system, 0xDF40); @@ -140,7 +140,7 @@ void StreetsOfRageIIISettings::step(const RleSystem& system) { m_terminal = true; } // Win if round clear - if ((system.settings()->getBool("SOR3_round_clear") == true) && ((m_current_level != 7) || (m_current_level != 8))){ + if ((system.settings()->getBool("SOR_round_clear") == true) && ((m_current_level != 7) || (m_current_level != 8))){ if ((m_end_level == m_current_level) && (readRam(&system, 0xFB00) == 46)){ std::cout << "ROUND CLEAR!" << std::endl; m_terminal = true; @@ -220,35 +220,20 @@ ActionVect StreetsOfRageIIISettings::getStartingActions(const RleSystem& system) int num_of_nops(100); ActionVect startingActions; -// // Wait for intro to end - // if (m_screen > 0){ - // INSERT_NOPS(7 * num_of_nops) - // }else{ - // INSERT_NOPS(9 * num_of_nops) - // // if (system.settings()->getBool("SOR3_test") == true){ - // // INSERT_NOPS(2 * num_of_nops) - // // } - // } - - std::cout << readRam(&system, 0xFB00) << std::endl; - +// Wait for intro to end INSERT_NOPS((3 - readRam(&system, 0xFB00)) * num_of_nops) - INSERT_ACTION_SINGLE_A(JOYPAD_START) - INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(2 * num_of_nops) INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(2 * num_of_nops) - INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(2 * num_of_nops) - INSERT_ACTION_SINGLE_A(JOYPAD_START) INSERT_NOPS(2 * num_of_nops) // // // // Choose Player 1 character - string player_1_character = system.settings()->getString("SOR3_player_1_character"); + string player_1_character = system.settings()->getString("SOR_player_1_character"); if("axel" == player_1_character){ //INSERT_ACTION_SINGLE_A(JOYPAD_START) }else if("zan" == player_1_character){ @@ -277,7 +262,7 @@ void StreetsOfRageIIISettings::startingOperations(RleSystem& system){ and number of lives by writing directly to RAM*/ //set difficulty - m_difficulty = system.settings()->getInt("SOR3_difficulty"); + m_difficulty = system.settings()->getInt("SOR_difficulty"); // Also setting enemy health low (see above). if(0 == m_difficulty){ writeRam(&system, 0xFF08, 0x2); @@ -297,7 +282,7 @@ void StreetsOfRageIIISettings::startingOperations(RleSystem& system){ writeRam(&system, 0xDFA0, 0x1); // //set start level for testing or to access Levels 7 and 8 - m_start_level = system.settings()->getInt("SOR3_start_level"); + m_start_level = system.settings()->getInt("SOR_start_level"); if(m_start_level == 1){ writeRam(&system, 0xFB04, 0x0); }else if(m_start_level == 2){ @@ -318,7 +303,7 @@ void StreetsOfRageIIISettings::startingOperations(RleSystem& system){ writeRam(&system, 0xFB02, 0x1); } - if(system.settings()->getBool("SOR3_test") == true){ + if(system.settings()->getBool("SOR_test") == true){ // Max out the difficulty writeRam(&system, 0xFF08, 0x0A); // Go to the last scene of the chosen level @@ -342,8 +327,8 @@ void StreetsOfRageIIISettings::startingOperations(RleSystem& system){ } // // Set number of lives - m_lives = system.settings()->getInt("SOR3_lives"); - writeRam(&system, 0xDF8A, (m_lives - 1) * 0x1); + m_lives = system.settings()->getInt("SOR_lives"); + writeRam(&system, 0xDF8A, m_lives * 0x1); } ActionVect StreetsOfRageIIISettings::getExtraActions(const RleSystem& system){ @@ -355,7 +340,7 @@ ActionVect StreetsOfRageIIISettings::getExtraActions(const RleSystem& system){ INSERT_ACTION_SINGLE_A(JOYPAD_START) // // // wait for level to begin - int start_level = system.settings()->getInt("SOR3_start_level"); + int start_level = system.settings()->getInt("SOR_start_level"); if (start_level == 1){ INSERT_NOPS(3 * num_of_nops) INSERT_ACTION_SINGLE_A(JOYPAD_START) diff --git a/src/games/supported/StreetsOfRageIII2Players.cpp b/src/games/supported/StreetsOfRageIII2Players.cpp new file mode 100644 index 0000000..f471136 --- /dev/null +++ b/src/games/supported/StreetsOfRageIII2Players.cpp @@ -0,0 +1,426 @@ +/* ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ +#include "../RomUtils.hpp" +#include + +#include "../RomUtils.hpp" + +#include "RleSystem.hxx" +#include "RleException.h" + +#include "StreetsOfRageIII2Players.hpp" +#include + + +using namespace rle; + + +StreetsOfRageIII2PlayersSettings::StreetsOfRageIII2PlayersSettings() { + reset(); + +// Actions can also be set in a RLE gym wrapper + minimalActions = {JOYPAD_NOOP, + // Moving + // JOYPAD_DOWN, //Walk down + // JOYPAD_UP, // Walk up + // JOYPAD_LEFT, // Walk left + // JOYPAD_RIGHT, // Walk right + // JOYPAD_GENESIS_C, // Jump + // JOYPAD_LEFT | JOYPAD_GENESIS_C, + // JOYPAD_RIGHT | JOYPAD_GENESIS_C, + + // // Special attacks + // JOYPAD_GENESIS_A, + // JOYPAD_LEFT | JOYPAD_GENESIS_A, + // JOYPAD_RIGHT |JOYPAD_GENESIS_A, + + // // Regular Attacks + // JOYPAD_GENESIS_B, + // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + + // // Attacks when holding enemy + // JOYPAD_GENESIS_B | JOYPAD_LEFT, + // JOYPAD_GENESIS_B | JOYPAD_RIGHT, + }; +} + + +/* create a new instance of the rom */ +RomSettings* StreetsOfRageIII2PlayersSettings::clone() const { + RomSettings* rval = new StreetsOfRageIII2PlayersSettings(); + *rval = *this; + return rval; +} + + +void StreetsOfRageIII2PlayersSettings::step(const RleSystem& system) { +// if (readRam(&system, 0xFB00) != 14){ +// m_terminal = true; +// } + +// Begin code for testing + if(system.settings()->getBool("SOR_test") == true){ + + // Fix Agent health + writeRam(&system, 0xDF6D, 0x34); + + // Make invincible + writeRam(&system, 0xDF5D, 0xFF); + + // Freeze Time + // writeRam(&system, 0xFC3C, 0x99); +} + +// This setting gives all enemies minimal health and lives + if((system.settings()->getBool("SOR_test") == true) || system.settings()->getInt("SOR_difficulty") == 0){ + // Fix enemy health + writeRam(&system, 0xE16D, 0x0); + writeRam(&system, 0xE26D, 0x0); + writeRam(&system, 0xE36D, 0x0); + writeRam(&system, 0xE46D, 0x0); + writeRam(&system, 0xE56D, 0x0); + writeRam(&system, 0xE66D, 0x0); + // Fix enemy lives + // writeRam(&system, 0xE18B, 0x0); + // writeRam(&system, 0xE28B, 0x0); + // writeRam(&system, 0xE38B, 0x0); + // writeRam(&system, 0xE48B, 0x0); + // writeRam(&system, 0xE58B, 0x0); + + } +// End code for testing + +// Read out current score, health, lives, kills +// Score set to 0. Will read score from rle/gym wrapper + reward_t score = 0; //getDecimalScore(0xEF99, 0xEF96, &system); + player_1_lives = readRam(&system, 0xDFA1); + player_2_lives = readRam(&system, 0xE0A1); +// update the reward + m_reward = score - m_score; + m_score = score; + + + if (system.settings()->getBool("SOR_2p_terminal_both_win") == true){ + if (((player_1_lives == 255) || (player_2_lives == 255)) && (readRam(&system, 0xFB00) == 14)){ + m_terminal = true; + } + }else{ + if ((player_1_lives == 255) && (player_2_lives == 255) && ((readRam(&system, 0xFB00) == 14))) + m_terminal = true; + } + + + + + + // Get level information + m_current_level = readRam(&system, 0xFB04) + 1; + m_end_level = system.settings()->getInt("SOR_end_level"); + + // Get information on agent position + int m_position = 256 * readRam(&system, 0xDF41) + readRam(&system, 0xDF40); + int scene = readRam(&system, 0xFB02); + m_screen = readRam(&system, 0xFB00); + + // Get boss information + int boss_1_ID = readRam(&system, 0xE10C); + int boss_present = readRam(&system, 0xE10C) + readRam(&system, 0xE20C) + readRam(&system, 0xE30C); + int boss_1_health = readRam(&system, 0xE16D); + int boss_2_health = readRam(&system, 0xE26D); + int boss_3_health = readRam(&system, 0xE36D); + int boss_health = boss_1_health + boss_2_health + boss_3_health; + int boss_1_lives = readRam(&system, 0xE18A); + int boss_lives = readRam(&system, 0xE18A) + readRam(&system, 0xE28A) + readRam(&system, 0xE38A); + + // Win if we accidentily go past the end level + if(m_end_level < m_current_level){ + std::cout << "ADVANCED TO NEXT LEVEL" << std::endl; + m_terminal = true; + } + // Win if round clear + if ((system.settings()->getBool("SOR_round_clear") == true) && ((m_current_level != 7) || (m_current_level != 8))){ + if ((m_end_level == m_current_level) && (readRam(&system, 0xFB00) == 46)){ + std::cout << "ROUND CLEAR!" << std::endl; + m_terminal = true; + } + }else{ + // Win if agent is in right place, with bosses present, and bosses dead + if((m_end_level == 1) && (m_current_level == 1)){ + if ((scene == 2) && (m_position > 456) && (boss_present > 0) && ((boss_1_health + boss_1_lives == 0))){ + m_terminal = true; + } + }else if ((m_end_level == 2) && (m_current_level == 2)){ + if ((scene == 2) && (m_position > 100) && (boss_present > 0) && ((boss_health + boss_lives) == 0) ){ + std::cout << " won game!" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 3) && (m_current_level == 3)){ + if ((scene == 2) && (m_position > 400) && (boss_present > 0) && ((boss_1_health + boss_1_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 4) && (m_current_level == 4)){ + if ((scene == 2) && (m_position> 300) && (boss_present > 0) && ((boss_1_health + boss_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 5) && (m_current_level == 5)){ + if ((scene == 7) && (m_position > 30) && (boss_1_ID == 56) && ((boss_1_health + boss_1_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 6) && (m_current_level == 6)){ + if ((scene == 7) && (m_position > 50) && (boss_present > 0) && ((boss_1_health + boss_1_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 7) && (m_current_level == 7)){ + if ((scene == 4) && (m_position > 30) && (boss_present > 0) && ((boss_1_health + boss_1_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + }else if ((m_end_level == 8) && (m_current_level == 8)){ + if ((scene == 3) && (m_position > 30) && (boss_present > 0) && ((boss_1_health + boss_1_lives) == 0)){ + std::cout << "won game" << std::endl; + m_terminal = true; + } + } + + } +} + + +/* reset the state of the game */ +void StreetsOfRageIII2PlayersSettings::reset() { + m_reward = 0; + m_score = 0; + m_terminal = false; +} + + +/* saves the state of the rom settings */ +void StreetsOfRageIII2PlayersSettings::saveState( Serializer & ser ) { + ser.putInt(m_reward); + ser.putInt(m_score); + ser.putBool(m_terminal); +} + + +// loads the state of the rom settings +void StreetsOfRageIII2PlayersSettings::loadState( Deserializer & des ) { + m_reward = des.getInt(); + m_score = des.getInt(); + m_terminal = des.getBool(); +} + + +ActionVect StreetsOfRageIII2PlayersSettings::getStartingActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + +// // Wait for intro to end + INSERT_NOPS((3 - readRam(&system, 0xFB00)) * num_of_nops) + + INSERT_ACTION_SINGLE_A(JOYPAD_START) + + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(2 * num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(2 * num_of_nops) + + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(2 * num_of_nops) + + INSERT_ACTION_SINGLE_A(JOYPAD_DOWN) + INSERT_NOPS(0.5 * num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(2 * num_of_nops) + +// // // // Choose Player 1 character + string player_1 = system.settings()->getString("SOR_player_1_character"); + string player_2 = system.settings()->getString("SOR_player_2_character"); + + if((player_1 == "axel") && (player_2 == "blaze")){ + //INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if((player_1 == "axel") && (player_2 == "skate")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + // INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if((player_1 == "axel") && (player_2 == "zan")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + // INSERT_ACTION_SINGLE_A(JOYPAD_START) + }else if((player_1 == "zan") && (player_2 == "blaze")){ + INSERT_ACTION_SINGLE(JOYPAD_LEFT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + }else if ((player_1 == "zan") && (player_2 == "skate")){ + INSERT_ACTION_SINGLE(JOYPAD_LEFT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + }else if ((player_1 == "zan") && (player_2 == "axel")){ + INSERT_ACTION_SINGLE(JOYPAD_LEFT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_LEFT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + }else if((player_1 == "skate") && (player_2 == "blaze")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + }else if((player_1 == "skate") && (player_2 == "axel")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_LEFT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + }else if((player_1 == "skate") && (player_2 == "zan")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + }else if((player_1 == "blaze") && (player_2 == "skate")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + }else if ((player_1 == "blaze") && (player_2 == "zan")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + }else if ((player_1 == "blaze") && (player_2 == "axel")){ + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + INSERT_ACTION_SINGLE(JOYPAD_RIGHT, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_LEFT, B) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, B) + } + + INSERT_NOPS(1 * num_of_nops) + +return startingActions; +} + + +void StreetsOfRageIII2PlayersSettings::startingOperations(RleSystem& system){ + /*This function sets the difficulty, number of continues, starting level, + and number of lives by writing directly to RAM*/ + + //set difficulty + m_difficulty = system.settings()->getInt("SOR_difficulty"); + // Also setting enemy health low (see above). + if(0 == m_difficulty){ + writeRam(&system, 0xFF08, 0x2); + }else if(1 == m_difficulty){ + writeRam(&system, 0xFF08, 0x2); + }else if(2 == m_difficulty){ + writeRam(&system, 0xFF08, 0x4); + }else if(3 == m_difficulty){ + writeRam(&system, 0xFF08, 0x6); + }else if(4 == m_difficulty){ + writeRam(&system, 0xFF08, 0x8); + }else if(5 == m_difficulty){ + writeRam(&system, 0xFF08, 0x0A); + } + + //set number of continues. By Default continues set to zero. + writeRam(&system, 0xDFA0, 0x1); + writeRam(&system, 0xE0A0, 0x1); + + // //set start level for testing or to access Levels 7 and 8 + m_start_level = system.settings()->getInt("SOR_start_level"); + if(m_start_level == 1){ + writeRam(&system, 0xFB04, 0x0); + }else if(m_start_level == 2){ + writeRam(&system, 0xFB04, 0x1); + }else if(m_start_level == 3){ + writeRam(&system, 0xFB04, 0x2); + }else if(m_start_level == 4){ + writeRam(&system, 0xFB04, 0x3); + }else if (m_start_level == 5){ + writeRam(&system, 0xFB04, 0x4); + }else if (m_start_level == 6){ + writeRam(&system, 0xFB04, 0x5); + }else if(m_start_level == 7){ + writeRam(&system, 0xFB04, 0x6); + writeRam(&system, 0xFB02, 0x1); + }else if (m_start_level == 8){ + writeRam(&system, 0xFB04, 0x7); + writeRam(&system, 0xFB02, 0x1); + } + + if(system.settings()->getBool("SOR_test") == true){ + // Max out the difficulty + writeRam(&system, 0xFF08, 0x0A); + // Go to the last scene of the chosen level + if(m_start_level == 1){ + writeRam(&system, 0xFB02, 0x2); + }else if(m_start_level == 2){ + writeRam(&system, 0xFB02, 0x2); + }else if(m_start_level == 3){ + writeRam(&system, 0xFB02, 0x2); + }else if(m_start_level == 4){ + writeRam(&system, 0xFB02, 0x2); + }else if (m_start_level == 5){ + writeRam(&system, 0xFB02, 0x7); + }else if (m_start_level == 6){ + writeRam(&system, 0xFB02, 0x7); + }else if(m_start_level == 7){ + writeRam(&system, 0xFB02, 0x4); + }else if (m_start_level == 8){ + writeRam(&system, 0xFB02, 0x3); + } + } + + // // Set number of lives + int m_lives = system.settings()->getInt("SOR_lives"); + writeRam(&system, 0xDF8A, m_lives * 0x1); + writeRam(&system, 0xE08A, m_lives * 0x1); +} + +ActionVect StreetsOfRageIII2PlayersSettings::getExtraActions(const RleSystem& system){ + int num_of_nops(100); + ActionVect startingActions; + + INSERT_NOPS(1 * num_of_nops) + + INSERT_ACTION_SINGLE(JOYPAD_START, A) + INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) + INSERT_ACTION_SINGLE(JOYPAD_START, B) +// +// // wait for level to begin + int start_level = system.settings()->getInt("SOR_start_level"); + if (start_level == 1){ + INSERT_NOPS(3 * num_of_nops) + INSERT_ACTION_SINGLE_A(JOYPAD_START) + INSERT_NOPS(4 * num_of_nops) + }else if (start_level == 2){ + INSERT_NOPS(3.5 * num_of_nops) + }else if (start_level == 3){ + INSERT_NOPS(4.6 * num_of_nops) + }else if (start_level ==4){ + INSERT_NOPS(3.7 * num_of_nops) + }else if (start_level == 5){ + INSERT_NOPS(3.7 * num_of_nops) + }else if (start_level == 6){ + INSERT_NOPS(3.7 * num_of_nops) + }else if (start_level == 7){ + INSERT_NOPS(1 * num_of_nops) + }else if (start_level == 8){ + INSERT_NOPS(4 * num_of_nops) + } + + return startingActions; +} diff --git a/src/games/supported/StreetsOfRageIII2Players.hpp b/src/games/supported/StreetsOfRageIII2Players.hpp new file mode 100644 index 0000000..8304132 --- /dev/null +++ b/src/games/supported/StreetsOfRageIII2Players.hpp @@ -0,0 +1,86 @@ +/* ***************************************************************************** + * The line 67 is based on Xitari's code, from Google Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * ***************************************************************************** + * A.L.E (Arcade Learning Environment) + * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and + * the Reinforcement Learning and Artificial Intelligence Laboratory + * Released under the GNU General Public License; see License.txt for details. + * + * Based on: Stella -- "An Atari 2600 VCS Emulator" + * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team + * + * ***************************************************************************** + */ + +#ifndef __STREETS_OF_RAGE_III_TWO_PLAYERS_SETTINGS_HPP__ +#define __STREETS_OF_RAGE_III_TWO_PLAYERS_SETTINGS_HPP__ +/* RL wrapper for AtariCollection settings */ + +#include "../GenesisSettings.hpp" +#include + +namespace rle { + +class StreetsOfRageIII2PlayersSettings : public GenesisSettings { + + public: + + StreetsOfRageIII2PlayersSettings(); + + // reset + void reset(); + + // the rom-name + const char* rom() const { return "streets_of_rage_iii_2_players"; } + + // create a new instance of the rom + RomSettings* clone() const; + + // process the latest information from ALE + void step(const RleSystem& system); + + + // saves the state of the rom settings + void saveState( Serializer & ser ); + + + // loads the state of the rom settings + void loadState( Deserializer & des ); + + + virtual const int lives() { return 0; } + + virtual ActionVect getStartingActions(const RleSystem& system); + virtual ActionVect getExtraActions(const RleSystem& system); + + void startingOperations(RleSystem& system); + private: + reward_t m_score; + int m_start_level; + int m_end_level; + int m_current_level; + int player_1_lives; + int player_2_lives; + int player_1_health; + int player_2_health; + int m_difficulty; + int m_screen; + +}; + +} // namespace rle + +#endif // __STREETS_OF_RAGE_III_TWO_PLAYERS_SETTINGS_HPP__ From c942b675bd76c59aa1ade8ab3fdd3cd96e872f4f Mon Sep 17 00:00:00 2001 From: Jonathan Michaux Date: Wed, 27 Dec 2017 17:16:55 -0600 Subject: [PATCH 29/29] fixed minimal actions --- src/games/supported/StreetsOfRage.cpp | 38 +++++++------- src/games/supported/StreetsOfRage2Players.cpp | 38 +++++++------- src/games/supported/StreetsOfRageII.cpp | 43 +++++++-------- .../supported/StreetsOfRageII2Players.cpp | 41 +++++++-------- src/games/supported/StreetsOfRageIII.cpp | 42 +++++++-------- .../supported/StreetsOfRageIII2Players.cpp | 52 +++++++------------ 6 files changed, 113 insertions(+), 141 deletions(-) diff --git a/src/games/supported/StreetsOfRage.cpp b/src/games/supported/StreetsOfRage.cpp index 436dbca..ecba617 100644 --- a/src/games/supported/StreetsOfRage.cpp +++ b/src/games/supported/StreetsOfRage.cpp @@ -27,26 +27,24 @@ using namespace rle; StreetsOfRageSettings::StreetsOfRageSettings() { reset(); - - - minimalActions = {JOYPAD_NOOP, - // JOYPAD_DOWN, //Walk down - // JOYPAD_UP, // Walk up - // JOYPAD_LEFT, // Walk left - JOYPAD_RIGHT, // Walk right - -// JOYPAD_GENESIS_A, // Special attack - // JOYPAD_GENESIS_B, // Regular attack - - // JOYPAD_GENESIS_C, // Jump - - // JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left - JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right - - // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam - // JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or - // JOYPAD_GENESIS_B | JOYPAD_RIGHT, - // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack + minimalActions = {JOYPAD_NOOP, + JOYPAD_DOWN, //Walk down + JOYPAD_UP, // Walk up + JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + + JOYPAD_GENESIS_C, // Jump + JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right + + JOYPAD_GENESIS_A, // Special attack + JOYPAD_LEFT | JOYPAD_GENESIS_A, + JOYPAD_RIGHT |JOYPAD_GENESIS_A, + + JOYPAD_GENESIS_B, // Regular attack + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + JOYPAD_GENESIS_B | JOYPAD_RIGHT, }; } diff --git a/src/games/supported/StreetsOfRage2Players.cpp b/src/games/supported/StreetsOfRage2Players.cpp index daa6a63..70b4c6f 100644 --- a/src/games/supported/StreetsOfRage2Players.cpp +++ b/src/games/supported/StreetsOfRage2Players.cpp @@ -27,26 +27,24 @@ using namespace rle; StreetsOfRage2PlayersSettings::StreetsOfRage2PlayersSettings() { reset(); - - - minimalActions = {JOYPAD_NOOP, - // JOYPAD_DOWN, //Walk down - // JOYPAD_UP, // Walk up - // JOYPAD_LEFT, // Walk left - JOYPAD_RIGHT, // Walk right - -// JOYPAD_GENESIS_A, // Special attack - // JOYPAD_GENESIS_B, // Regular attack - - // JOYPAD_GENESIS_C, // Jump - - // JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left - JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right - - // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam - // JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or - // JOYPAD_GENESIS_B | JOYPAD_RIGHT, - // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C | JOYPAD_DOWN,//Drop attack + minimalActions = {JOYPAD_NOOP, + JOYPAD_DOWN, //Walk down + JOYPAD_UP, // Walk up + JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + + JOYPAD_GENESIS_C, // Jump + JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right + + JOYPAD_GENESIS_A, // Special attack + JOYPAD_LEFT | JOYPAD_GENESIS_A, + JOYPAD_RIGHT |JOYPAD_GENESIS_A, + + JOYPAD_GENESIS_B, // Regular attack + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + JOYPAD_GENESIS_B | JOYPAD_RIGHT, }; } diff --git a/src/games/supported/StreetsOfRageII.cpp b/src/games/supported/StreetsOfRageII.cpp index 00e5fd1..a7df733 100644 --- a/src/games/supported/StreetsOfRageII.cpp +++ b/src/games/supported/StreetsOfRageII.cpp @@ -27,28 +27,25 @@ using namespace rle; StreetsOfRageIISettings::StreetsOfRageIISettings() { reset(); - minimalActions = {JOYPAD_NOOP, - // Moving - JOYPAD_DOWN, //Walk down - JOYPAD_UP, // Walk up - // JOYPAD_LEFT, // Walk left - JOYPAD_RIGHT, // Walk right - JOYPAD_GENESIS_C, // Jump - JOYPAD_LEFT | JOYPAD_GENESIS_C, - JOYPAD_RIGHT | JOYPAD_GENESIS_C, - // - // // Special attacks - JOYPAD_GENESIS_A, - // JOYPAD_LEFT | JOYPAD_GENESIS_A, - JOYPAD_RIGHT |JOYPAD_GENESIS_A, - // - // // Regular Attacks - JOYPAD_GENESIS_B, - JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam - // - // // Attacks when holding enemy - //JOYPAD_GENESIS_B | JOYPAD_LEFT, - JOYPAD_GENESIS_B | JOYPAD_RIGHT, + minimalActions = {JOYPAD_NOOP, + JOYPAD_DOWN, //Walk down + JOYPAD_UP, // Walk up + JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + + JOYPAD_GENESIS_C, // Jump + JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right + + JOYPAD_GENESIS_A, // Special attack + JOYPAD_LEFT | JOYPAD_GENESIS_A, + JOYPAD_RIGHT |JOYPAD_GENESIS_A, + + JOYPAD_GENESIS_B, // Regular attack + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + JOYPAD_GENESIS_B | JOYPAD_RIGHT, + }; } @@ -113,7 +110,7 @@ void StreetsOfRageIISettings::step(const RleSystem& system) { int boss_health = readRam(&system, 0xF180); int boss_lives = readRam(&system, 0xF182); - if ((system.settings()->getBool("SOR_round") == true) || (m_end_level == 8)){ + if ((system.settings()->getBool("SOR_round_clear") == true) || (m_end_level == 8)){ if (((m_current_level - 1) == m_end_level) && (m_progress_1 == 0) && (m_progress_2 > 10)){ if (system.settings()->getBool("SOR_verbose") == true){ std::cout << "Round "<< m_end_level << " clear!" << std::endl; diff --git a/src/games/supported/StreetsOfRageII2Players.cpp b/src/games/supported/StreetsOfRageII2Players.cpp index e3f4da8..04ea9af 100644 --- a/src/games/supported/StreetsOfRageII2Players.cpp +++ b/src/games/supported/StreetsOfRageII2Players.cpp @@ -27,28 +27,25 @@ using namespace rle; StreetsOfRageII2PlayersSettings::StreetsOfRageII2PlayersSettings() { reset(); - minimalActions = {JOYPAD_NOOP, - // Moving - JOYPAD_DOWN, //Walk down - JOYPAD_UP, // Walk up - // JOYPAD_LEFT, // Walk left - JOYPAD_RIGHT, // Walk right - JOYPAD_GENESIS_C, // Jump - JOYPAD_LEFT | JOYPAD_GENESIS_C, - JOYPAD_RIGHT | JOYPAD_GENESIS_C, - // - // // Special attacks - JOYPAD_GENESIS_A, - // JOYPAD_LEFT | JOYPAD_GENESIS_A, - JOYPAD_RIGHT |JOYPAD_GENESIS_A, - // - // // Regular Attacks - JOYPAD_GENESIS_B, - JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam - // - // // Attacks when holding enemy - //JOYPAD_GENESIS_B | JOYPAD_LEFT, - JOYPAD_GENESIS_B | JOYPAD_RIGHT, + minimalActions = {JOYPAD_NOOP, + JOYPAD_DOWN, //Walk down + JOYPAD_UP, // Walk up + JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + + JOYPAD_GENESIS_C, // Jump + JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right + + JOYPAD_GENESIS_A, // Special attack + JOYPAD_LEFT | JOYPAD_GENESIS_A, + JOYPAD_RIGHT |JOYPAD_GENESIS_A, + + JOYPAD_GENESIS_B, // Regular attack + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + JOYPAD_GENESIS_B | JOYPAD_RIGHT, + }; } diff --git a/src/games/supported/StreetsOfRageIII.cpp b/src/games/supported/StreetsOfRageIII.cpp index 038928c..9c41ceb 100644 --- a/src/games/supported/StreetsOfRageIII.cpp +++ b/src/games/supported/StreetsOfRageIII.cpp @@ -27,29 +27,25 @@ using namespace rle; StreetsOfRageIIISettings::StreetsOfRageIIISettings() { reset(); -// Actions can also be set in a RLE gym wrapper - minimalActions = {JOYPAD_NOOP, - // Moving - // JOYPAD_DOWN, //Walk down - // JOYPAD_UP, // Walk up - // JOYPAD_LEFT, // Walk left - // JOYPAD_RIGHT, // Walk right - // JOYPAD_GENESIS_C, // Jump - // JOYPAD_LEFT | JOYPAD_GENESIS_C, - // JOYPAD_RIGHT | JOYPAD_GENESIS_C, - - // // Special attacks - // JOYPAD_GENESIS_A, - // JOYPAD_LEFT | JOYPAD_GENESIS_A, - JOYPAD_RIGHT |JOYPAD_GENESIS_A, - - // // Regular Attacks - // JOYPAD_GENESIS_B, - JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam - - // // Attacks when holding enemy - // JOYPAD_GENESIS_B | JOYPAD_LEFT, - // JOYPAD_GENESIS_B | JOYPAD_RIGHT, + minimalActions = {JOYPAD_NOOP, + JOYPAD_DOWN, //Walk down + JOYPAD_UP, // Walk up + JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + + JOYPAD_GENESIS_C, // Jump + JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right + + JOYPAD_GENESIS_A, // Special attack + JOYPAD_LEFT | JOYPAD_GENESIS_A, + JOYPAD_RIGHT |JOYPAD_GENESIS_A, + + JOYPAD_GENESIS_B, // Regular attack + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + JOYPAD_GENESIS_B | JOYPAD_RIGHT, + }; } diff --git a/src/games/supported/StreetsOfRageIII2Players.cpp b/src/games/supported/StreetsOfRageIII2Players.cpp index f471136..84d5bc5 100644 --- a/src/games/supported/StreetsOfRageIII2Players.cpp +++ b/src/games/supported/StreetsOfRageIII2Players.cpp @@ -27,29 +27,25 @@ using namespace rle; StreetsOfRageIII2PlayersSettings::StreetsOfRageIII2PlayersSettings() { reset(); -// Actions can also be set in a RLE gym wrapper - minimalActions = {JOYPAD_NOOP, - // Moving - // JOYPAD_DOWN, //Walk down - // JOYPAD_UP, // Walk up - // JOYPAD_LEFT, // Walk left - // JOYPAD_RIGHT, // Walk right - // JOYPAD_GENESIS_C, // Jump - // JOYPAD_LEFT | JOYPAD_GENESIS_C, - // JOYPAD_RIGHT | JOYPAD_GENESIS_C, - - // // Special attacks - // JOYPAD_GENESIS_A, - // JOYPAD_LEFT | JOYPAD_GENESIS_A, - // JOYPAD_RIGHT |JOYPAD_GENESIS_A, - - // // Regular Attacks - // JOYPAD_GENESIS_B, - // JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam - - // // Attacks when holding enemy - // JOYPAD_GENESIS_B | JOYPAD_LEFT, - // JOYPAD_GENESIS_B | JOYPAD_RIGHT, + minimalActions = {JOYPAD_NOOP, + JOYPAD_DOWN, //Walk down + JOYPAD_UP, // Walk up + JOYPAD_LEFT, // Walk left + JOYPAD_RIGHT, // Walk right + + JOYPAD_GENESIS_C, // Jump + JOYPAD_GENESIS_C | JOYPAD_LEFT, // Jump left + JOYPAD_GENESIS_C | JOYPAD_RIGHT, // Jump right + + JOYPAD_GENESIS_A, // Special attack + JOYPAD_LEFT | JOYPAD_GENESIS_A, + JOYPAD_RIGHT |JOYPAD_GENESIS_A, + + JOYPAD_GENESIS_B, // Regular attack + JOYPAD_GENESIS_B | JOYPAD_GENESIS_C, // Rear attack or Super slam + JOYPAD_GENESIS_B | JOYPAD_LEFT,//Blitz attack or + JOYPAD_GENESIS_B | JOYPAD_RIGHT, + }; } @@ -63,10 +59,6 @@ RomSettings* StreetsOfRageIII2PlayersSettings::clone() const { void StreetsOfRageIII2PlayersSettings::step(const RleSystem& system) { -// if (readRam(&system, 0xFB00) != 14){ -// m_terminal = true; -// } - // Begin code for testing if(system.settings()->getBool("SOR_test") == true){ @@ -89,12 +81,6 @@ void StreetsOfRageIII2PlayersSettings::step(const RleSystem& system) { writeRam(&system, 0xE46D, 0x0); writeRam(&system, 0xE56D, 0x0); writeRam(&system, 0xE66D, 0x0); - // Fix enemy lives - // writeRam(&system, 0xE18B, 0x0); - // writeRam(&system, 0xE28B, 0x0); - // writeRam(&system, 0xE38B, 0x0); - // writeRam(&system, 0xE48B, 0x0); - // writeRam(&system, 0xE58B, 0x0); } // End code for testing