diff --git a/src/games/Roms.cpp b/src/games/Roms.cpp index cdc86df..42195cf 100644 --- a/src/games/Roms.cpp +++ b/src/games/Roms.cpp @@ -30,6 +30,9 @@ #include "supported/TetrisAndDrMario.hpp" #include "supported/Boxing.hpp" #include "supported/Wolfenstein.hpp" +#include "supported/Aladdin.hpp" +#include "supported/StreetFighterII.hpp" +#include "supported/BustAMove.hpp" // genesis games #include "supported/SonicTheHedgehog.hpp" @@ -168,12 +171,15 @@ static const RomSettings *roms[] = { new SuperMarioWorldSettings(), new TetrisAndDrMarioSettings(), new WolfensteinSettings(), - + new AladdinSettings(), + new StreetFighterIISettings(), + new BustAMoveSettings(), // Genesis games new SonicTheHedgehogSettings() }; + /* looks for the RL wrapper corresponding to a particular rom title */ RomSettings *rle::buildRomRLWrapper(const std::string &rom, bool twoPlayers) { diff --git a/src/games/supported/Aladdin.cpp b/src/games/supported/Aladdin.cpp new file mode 100644 index 0000000..78408d7 --- /dev/null +++ b/src/games/supported/Aladdin.cpp @@ -0,0 +1,132 @@ +/* ***************************************************************************** + * 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 "Aladdin.hpp" + +using namespace rle; + + +AladdinSettings::AladdinSettings() { + reset(); + + minimalActions = { JOYPAD_NOOP, + JOYPAD_UP, // only relavent when hanging + JOYPAD_DOWN, //duck + JOYPAD_LEFT, + JOYPAD_RIGHT, + JOYPAD_B, // Jump + JOYPAD_B | JOYPAD_RIGHT, // jump right + JOYPAD_B | JOYPAD_LEFT, // jump left + JOYPAD_Y | JOYPAD_RIGHT, // Run right + JOYPAD_Y | JOYPAD_LEFT, // Run left + JOYPAD_A, //throw apple + JOYPAD_A | JOYPAD_B, // Jump + JOYPAD_A | JOYPAD_B | JOYPAD_RIGHT, // jump right + JOYPAD_A | JOYPAD_B | JOYPAD_LEFT, // jump left, // jump & Shoot + }; +} + + +/* create a new instance of the rom */ +RomSettings* AladdinSettings::clone() const { + RomSettings* rval = new AladdinSettings(); + *rval = *this; + return rval; +} + + +/* process the latest information from ALE */ +void AladdinSettings::step(const RleSystem& system) { + // update the reward + reward_t playerScore = 256*readRam(&system, 0xF411) + readRam(&system, 0xF410); //based solely on moving right + reward_t healthBonus = m_health - readRam(&system, 0x366); // adding health bonus to discourage getting hit + int apples = readRam(&system, 0x368); + int dimonds = readRam(&system, 0x36a); + playerScore += healthBonus; + int current_lives = readRam(&system, 0x363)-1; + m_reward = playerScore - m_score; + m_score = playerScore; + if( current_lives != m_lives) { //adding "previous lives" since lives=0 until game starts + m_prev_lives = m_lives; + } + m_lives = current_lives; + m_health = readRam(&system, 0x366); + +// cout <<"Score is: " << playerScore << " Health is: " << m_health << " lives are: " << m_lives << " m_prev_lives " << m_prev_lives< + +namespace rle { + +class AladdinSettings : public SnesSettings { + + public: + + AladdinSettings(); + + // reset + void reset(); + + // the rom-name + const char* rom() const { return "aladdin"; } + + // 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(); + + private: + int m_lives; + int m_prev_lives; + int m_health; +}; + +} // namespace rle + +#endif // __ALADDIN_SETTINGS_HPP__ diff --git a/src/games/supported/BustAMove.cpp b/src/games/supported/BustAMove.cpp new file mode 100644 index 0000000..34ad7dd --- /dev/null +++ b/src/games/supported/BustAMove.cpp @@ -0,0 +1,113 @@ +/* ***************************************************************************** + * 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 "BustAMove.hpp" + +using namespace rle; + + +BustAMoveSettings::BustAMoveSettings() { + reset(); + + minimalActions = { JOYPAD_NOOP, + JOYPAD_LEFT, + JOYPAD_RIGHT, + JOYPAD_A, //shoot + }; +} + + +/* create a new instance of the rom */ +RomSettings* BustAMoveSettings::clone() const { + RomSettings* rval = new BustAMoveSettings(); + *rval = *this; + return rval; +} + + +/* process the latest information from ALE */ +void BustAMoveSettings::step(const RleSystem& system) { + // update the reward + reward_t playerScore = getDecimalScore(0x954,0x955,0x956, &system); + + m_reward = playerScore - m_score; + m_score = playerScore; +// cout << "Score: " << playerScore< 0){ + m_terminal = true; + } +} + + +/* reset the state of the game */ +void BustAMoveSettings::reset() { + + m_reward = 0; + m_score = 0; + m_terminal = false; +} + + + +/* saves the state of the rom settings */ +void BustAMoveSettings::saveState( Serializer & ser ) { + ser.putInt(m_reward); + ser.putInt(m_score); + ser.putBool(m_terminal); +} + +// loads the state of the rom settings +void BustAMoveSettings::loadState( Deserializer & des ) { + m_reward = des.getInt(); + m_score = des.getInt(); + m_terminal = des.getBool(); +} + + +ActionVect BustAMoveSettings::getStartingActions(){ + int i, num_of_nops(100); + ActionVect startingActions; + + // wait for intro to end + for(i = 0; i<2*num_of_nops; i++){ + startingActions.push_back(JOYPAD_NOOP); + } + // main Screen + startingActions.push_back(JOYPAD_START); + // wait for character select screen + for(i = 0; i<2*num_of_nops; i++){ + startingActions.push_back(JOYPAD_NOOP); + } + //start game + startingActions.push_back(JOYPAD_START); + + for(i = 0; i<2*num_of_nops; i++){ + startingActions.push_back(JOYPAD_NOOP); + } + //start game + startingActions.push_back(JOYPAD_START); + for(i = 0; i<2*num_of_nops; i++){ + startingActions.push_back(JOYPAD_NOOP); + } + //start game + startingActions.push_back(JOYPAD_START); + + return startingActions; +} + + diff --git a/src/games/supported/BustAMove.hpp b/src/games/supported/BustAMove.hpp new file mode 100644 index 0000000..04b4d1b --- /dev/null +++ b/src/games/supported/BustAMove.hpp @@ -0,0 +1,68 @@ +/* ***************************************************************************** + * 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 __BUST_A_MOVE_SETTINGS_HPP__ +#define __BUST_A_MOVE_SETTINGS_HPP__ +/* RL wrapper for AtariCollection settings */ + +#include "../SnesSettings.hpp" +#include + +namespace rle { + +class BustAMoveSettings : public SnesSettings { + + public: + + BustAMoveSettings(); + + // reset + void reset(); + + // the rom-name + const char* rom() const { return "bust_a_move"; } + + // 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(); +}; + +} // namespace rle + +#endif // __BUST_A_MOVE_SETTINGS_HPP__ diff --git a/src/games/supported/StreetFighterII.cpp b/src/games/supported/StreetFighterII.cpp new file mode 100644 index 0000000..091ccda --- /dev/null +++ b/src/games/supported/StreetFighterII.cpp @@ -0,0 +1,173 @@ +/* ***************************************************************************** + * 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 "StreetFighterII.hpp" + +#include "RleSystem.hxx" +#include "RleException.h" + +using namespace rle; + + +StreetFighterIISettings::StreetFighterIISettings() { + reset(); + + minimalActions = { JOYPAD_NOOP, + JOYPAD_UP, // jump + JOYPAD_DOWN, + JOYPAD_LEFT, + JOYPAD_RIGHT, + JOYPAD_R, // upper-cut + JOYPAD_A, // right Kick + JOYPAD_B, // leftkick + JOYPAD_Y, // left punch + JOYPAD_X, // right punch + JOYPAD_L, //spin-kick + JOYPAD_UP | JOYPAD_RIGHT, // jump right + JOYPAD_UP | JOYPAD_LEFT, // jump left + JOYPAD_DOWN | JOYPAD_Y, + JOYPAD_DOWN | JOYPAD_R, + JOYPAD_DOWN | JOYPAD_L, + JOYPAD_DOWN | JOYPAD_A, + JOYPAD_DOWN | JOYPAD_B, + JOYPAD_DOWN | JOYPAD_X, + + JOYPAD_LEFT | JOYPAD_A, + JOYPAD_RIGHT | JOYPAD_A, + JOYPAD_LEFT | JOYPAD_X, + JOYPAD_RIGHT | JOYPAD_X, + JOYPAD_RIGHT | JOYPAD_Y, + JOYPAD_LEFT | JOYPAD_Y, + JOYPAD_RIGHT | JOYPAD_L, + JOYPAD_LEFT | JOYPAD_L, + JOYPAD_RIGHT | JOYPAD_R, + JOYPAD_LEFT | JOYPAD_R, + JOYPAD_RIGHT | JOYPAD_B, + JOYPAD_LEFT | JOYPAD_B, + + }; +} + + +/* create a new instance of the rom */ +RomSettings* StreetFighterIISettings::clone() const { + + RomSettings* rval = new StreetFighterIISettings(); + *rval = *this; + return rval; +} + + +/* process the latest information from ALE */ +void StreetFighterIISettings::step(const RleSystem& system) { + int time = getDecimalScore(0x1ac8, &system); + + // update the reward + reward_t playerScore = getDecimalScore(0xdc3,0xdc4, &system); + playerScore *= 100; + + reward_t score = playerScore; + + m_reward = score - m_score; + m_score = score; + +// update terminal status +// int playerLife = readRam(&system, 0x4c1); +// int npcLife = readRam(&system, 0x4c3); + if(time == 0x1){ //shai:comparing to 1 not zero to avoid terminal upon first run + m_terminal=true; + + } + + int totalWins = m_wins + o_wins; + m_wins = getDecimalScore(0xcd0, &system); + o_wins = getDecimalScore(0xed0, &system); +// cout << "player score: " << playerScore << " Time: " +// << time << " p_wins: " << m_wins << " op wins: " <