diff --git a/CMakeLists.txt b/CMakeLists.txt index d627078..d2c3df8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required (VERSION 3.02) -project(ale) +project(rle) option(USE_SDL "Use SDL" OFF) -option(USE_RLGLUE "Use RL-Glue" OFF) option(BUILD_EXAMPLES "Build Example Agents" ON) option(DEBUG "Suspend optimization & enable debugging" OFF) option(UNIT_TESTING "Build unit tests using Google Test" OFF) @@ -67,7 +66,7 @@ endif() if(WINDOWS OR MINGW) list(APPEND SOURCES ${SOURCE_DIR}/os_dependent/SettingsWin32.cxx ${SOURCE_DIR}/os_dependent/OSystemWin32.cxx ${SOURCE_DIR}/os_dependent/FSNodeWin32.cxx) else() - list(APPEND SOURCES ${SOURCE_DIR}/os_dependent/SettingsUNIX.cxx ${SOURCE_DIR}/os_dependent/AleSystemUNIX.cxx ${SOURCE_DIR}/os_dependent/FSNodePOSIX.cxx) + list(APPEND SOURCES ${SOURCE_DIR}/os_dependent/SettingsUNIX.cxx ${SOURCE_DIR}/os_dependent/RleSystemUNIX.cxx ${SOURCE_DIR}/os_dependent/FSNodePOSIX.cxx) endif() if(UNIX) @@ -86,7 +85,7 @@ include_directories( ${SOURCE_DIR}/external/TinyMT ) -set(INCDIR "${CMAKE_INSTALL_PREFIX}/include/ale") +set(INCDIR "${CMAKE_INSTALL_PREFIX}/include/rle") set(LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") MESSAGE(STATUS "INCLUDE_DIR ${INCDIR}") @@ -126,37 +125,33 @@ ExternalProject_add(stella_libretro INSTALL_COMMAND "${STELLA_INSTALL_COMMAND}" ) -add_library(ale-lib SHARED ${SOURCE_DIR}/ale_interface.cpp ${SOURCES}) -set_target_properties(ale-lib PROPERTIES OUTPUT_NAME ale) -set_target_properties(ale-lib PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -add_dependencies(ale-lib snes9x2010_libretro) -add_dependencies(ale-lib stella_libretro) -add_executable(ale-bin ${SOURCE_DIR}/main.cpp ${SOURCE_DIR}/ale_interface.cpp ${SOURCES}) -set_target_properties(ale-bin PROPERTIES OUTPUT_NAME ale) -set_target_properties(ale-bin PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -add_library(ale-c-lib SHARED ${CMAKE_CURRENT_SOURCE_DIR}/ale_python_interface/ale_c_wrapper.cpp ${SOURCE_DIR}/ale_interface.cpp ${SOURCES}) -set_target_properties(ale-c-lib PROPERTIES OUTPUT_NAME ale_c) -set_target_properties(ale-c-lib PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ale_python_interface) - -target_link_libraries(ale-lib ${LINK_LIBS}) -target_link_libraries(ale-bin ${LINK_LIBS}) -target_link_libraries(ale-c-lib ${LINK_LIBS}) +add_library(rle-lib SHARED ${SOURCE_DIR}/rle_interface.cpp ${SOURCES}) +set_target_properties(rle-lib PROPERTIES OUTPUT_NAME rle) +set_target_properties(rle-lib PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +add_dependencies(rle-lib snes9x2010_libretro) +add_dependencies(rle-lib stella_libretro) +add_library(rle-c-lib SHARED ${CMAKE_CURRENT_SOURCE_DIR}/rle_python_interface/rle_c_wrapper.cpp ${SOURCE_DIR}/rle_interface.cpp ${SOURCES}) +set_target_properties(rle-c-lib PROPERTIES OUTPUT_NAME rle_c) +set_target_properties(rle-c-lib PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rle_python_interface) + +target_link_libraries(rle-lib ${LINK_LIBS}) +target_link_libraries(rle-c-lib ${LINK_LIBS}) IF(INSTALL_CORES) INSTALL( FILES - src/ale_interface.hpp + src/rle_interface.hpp src/libretro.h DESTINATION "${INCDIR}" ) IF(APPLE) INSTALL(FILES - libale.a + librle.a DESTINATION "${LIBDIR}") ELSE() INSTALL(FILES - libale.so + librle.so DESTINATION "${LIBDIR}") ENDIF() ENDIF() @@ -165,9 +160,9 @@ if(BUILD_EXAMPLES) link_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_executable(sharedLibraryInterfaceExample ${CMAKE_CURRENT_SOURCE_DIR}/doc/examples/sharedLibraryInterfaceExample.cpp) set_target_properties(sharedLibraryInterfaceExample PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/examples) - target_link_libraries(sharedLibraryInterfaceExample ale) + target_link_libraries(sharedLibraryInterfaceExample rle) target_link_libraries(sharedLibraryInterfaceExample ${LINK_LIBS}) - add_dependencies(sharedLibraryInterfaceExample ale-lib) + add_dependencies(sharedLibraryInterfaceExample rle-lib) endif() @@ -202,7 +197,7 @@ if(UNIT_TESTING) add_definitions(-D__UNIT_TESTING) add_subdirectory(googletest) enable_testing() - include_directories(${GTEST_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/ale_python_interface) + include_directories(${GTEST_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/rle_python_interface) file(GLOB test_sources test/*.cpp) list(APPEND TEST_SOURCES ${test_sources}) @@ -211,6 +206,6 @@ if(UNIT_TESTING) add_executable( mainTest ${TEST_SOURCES}) # Link test executable against gtest & gtest_main - target_link_libraries(mainTest gtest gtest_main ale ale-c-lib) + target_link_libraries(mainTest gtest gtest_main rle rle-c-lib) add_test( mainTest mainTest ) endif() diff --git a/Readme.txt b/Readme.txt index feb436d..25fa691 100644 --- a/Readme.txt +++ b/Readme.txt @@ -1,3 +1,7 @@ +This is version 0.1 of the Retro Learning Environment (RLE), based upon ALE, +see below for more details. + +============================== This is the 0.5 release of the Arcade Learning Environment (ALE), a platform designed for AI research. ALE is based on Stella, an Atari 2600 VCS emulator. More information and ALE-related publications can be found at @@ -14,33 +18,6 @@ of the ALE team. Enjoy, The ALE team -=============================== -List of command-line parameters -=============================== - -Execute ./ale -help for more details; alternatively, see documentation -available at http://www.arcadelearningenvironment.org. - --random_seed [n] -- sets the random seed; defaults to the current time - --game_controller [fifo|fifo_named] -- specifies how agents interact - with ALE; see Java agent documentation for details - --config [file] -- specifies a configuration file, from which additional - parameters are read - --run_length_encoding [false|true] -- determine whether run-length encoding is - used to send data over pipes; irrelevant when an internal agent is - being used - --max_num_frames_per_episode [n] -- sets the maximum number of frames per - episode. Once this number is reached, a new episode will start. Currently - implemented for all agents when using pipes (fifo/fifo_named) - --max_num_frames [n] -- sets the maximum number of frames (independent of how - many episodes are played) - - ===================================== Citing The Arcade Learning Environment: An Evaluation Platform for General Agents diff --git a/ale-2-0.rockspec b/ale-2-0.rockspec deleted file mode 100644 index 075d5a6..0000000 --- a/ale-2-0.rockspec +++ /dev/null @@ -1,20 +0,0 @@ -package = 'ale' -version = '2-0' - -source = { - url = 'git://github.com/nadavbh12/Arcade-Learning-Environment-2.0.git' -} - -description = { - summary = "Ale" -} - -dependencies = { 'torch >= 7.0' } -build = { - type = "command", - build_command = [[ - cmake -DINSTALL_CORES=ON -DUSE_SDL=OFF -DUSE_RLGLUE=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)/../../../../../" .; - $(MAKE) -j 4 - ]], - install_command = "$(MAKE) install" - } diff --git a/ale_python_interface/__init__.py b/ale_python_interface/__init__.py deleted file mode 100644 index 913cbb5..0000000 --- a/ale_python_interface/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ale_python_interface import * diff --git a/ale_python_interface/ale_c_wrapper.cpp b/ale_python_interface/ale_c_wrapper.cpp deleted file mode 100644 index 4850c04..0000000 --- a/ale_python_interface/ale_c_wrapper.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "ale_c_wrapper.h" - -#include -#include -#include - -//void encodeState(ALEState *state, char *buf, int buf_len) { -// std::string str = state->serialize(); -// -// if (buf_len < int(str.length())) { -// throw new std::runtime_error("Buffer is not big enough to hold serialized ALEState. Please use encodeStateLen to determine the correct buffer size"); -// } -// -// memcpy(buf, str.data(), str.length()); -//} -// -//int encodeStateLen(ALEState *state) { -// return state->serialize().length(); -//} -// -//ALEState *decodeState(const char *serialized, int len) { -// std::string str(serialized, len); -// -// return new ALEState(str); -//} - - -static void ale_rearrangeRgb(uint8_t *dst_buffer, const uint32_t *src_buffer, size_t src_size , const ALEInterface *ale) { - - uint8_t *q = dst_buffer; - uint8_t r, g, b; - for(size_t i = 0; i < src_size; ++i, ++q){ - ale->getScreen().getRGB(((uint16_t*)src_buffer)[i], r, g, b); - *q = (unsigned char) (r); q++; // r - *q = (unsigned char) (g); q++; // g - *q = (unsigned char) (b); q++; // b - } -} - -static void ale_rearrangeGrayscale(uint8_t *dst_buffer, const uint32_t *src_buffer, size_t src_size , const ALEInterface *ale) { - - uint8_t *q = dst_buffer; - uint8_t r, g, b; - for(size_t i = 0; i < src_size; ++i, ++q){ - ale->getScreen().getRGB(((uint16_t*)src_buffer)[i], r, g, b); - *q = (unsigned char) (0.3*r + 0.5*g+0.2*b); - } -} - -void getScreenRGB(ALEInterface *ale, unsigned char *output_buffer){ - const ale::ALEScreen& screen = ale->getScreen(); - size_t w = screen.width(); - size_t h = screen.height(); - size_t screen_size = w*h; - size_t size_in_pixels = screen_size; - ale_rearrangeRgb(output_buffer, (uint32_t*)screen.getArray(), size_in_pixels, ale); -} - -//This method should receive an empty vector to fill it with -//the grayscale colours -void getScreenGrayscale(ALEInterface *ale, unsigned char *output_buffer){ - const ale::ALEScreen& screen = ale->getScreen(); - size_t w = ale->getScreen().width(); - size_t h = ale->getScreen().height(); - size_t screen_size = w*h; - size_t size_in_pixels = screen_size ; - ale_rearrangeGrayscale(output_buffer, (uint32_t*)screen.getArray(), size_in_pixels, ale); -} diff --git a/ale_python_interface/ale_c_wrapper.h b/ale_python_interface/ale_c_wrapper.h deleted file mode 100644 index e7707f2..0000000 --- a/ale_python_interface/ale_c_wrapper.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef __ALE_C_WRAPPER_H__ -#define __ALE_C_WRAPPER_H__ - -#include - -using namespace ale; - -extern "C" { - // Declares int rgb_palette[256] - ALEInterface *ALE_new() {return new ALEInterface();} - void ALE_del(ALEInterface *ale){delete ale;} - const char *getString(ALEInterface *ale, const char *key){return ale->getString(key).c_str();} - int getInt(ALEInterface *ale,const char *key) {return ale->getInt(key);} - bool getBool(ALEInterface *ale,const char *key){return ale->getBool(key);} - float getFloat(ALEInterface *ale,const char *key){return ale->getFloat(key);} - void setString(ALEInterface *ale,const char *key,const char *value){ale->setString(key,value);} - void setInt(ALEInterface *ale,const char *key,int value){ale->setInt(key,value);} - void setBool(ALEInterface *ale,const char *key,bool value){ale->setBool(key,value);} - void setFloat(ALEInterface *ale,const char *key,float value){ale->setFloat(key,value);} - void loadROM(ALEInterface *ale,const char *rom_file, const char *core_file){ale->loadROM(rom_file,core_file);} - int act(ALEInterface *ale,int actionA, int actionB){return ale->act((Action)actionA, (Action)actionB);} - bool game_over(ALEInterface *ale){return ale->game_over();} - void reset_game(ALEInterface *ale){ale->reset_game();} - void getLegalActionSet(ALEInterface *ale,int *actions){ - ActionVect action_vect = ale->getLegalActionSet(); - for(unsigned int i = 0;i < ale->getLegalActionSet().size();i++){ - actions[i] = action_vect[i]; - } - } - int getLegalActionSize(ALEInterface *ale){return ale->getLegalActionSet().size();} - void getMinimalActionSet(ALEInterface *ale,int *actions){ - ActionVect action_vect = ale->getMinimalActionSet(); - for(unsigned int i = 0;i < ale->getMinimalActionSet().size();i++){ - actions[i] = action_vect[i]; - } - } - int getMinimalActionSize(ALEInterface *ale){return ale->getMinimalActionSet().size();} - int getFrameNumber(ALEInterface *ale){return ale->getFrameNumber();} - int lives(ALEInterface *ale){return ale->lives();} - int getEpisodeFrameNumber(ALEInterface *ale){return ale->getEpisodeFrameNumber();} - void getRAM(ALEInterface *ale,unsigned char *ram){ -// unsigned char *ale_ram = ale->getRAM().array(); -// int size = ale->getRAM().size(); -// memcpy(ram,ale_ram,size*sizeof(unsigned char)); - } - int getRAMSize(ALEInterface *ale){return ale->getRAM().size();} - int getScreenWidth(ALEInterface *ale){return ale->getScreen().width();} - int getScreenHeight(ALEInterface *ale){return ale->getScreen().height();} - int getScreenBpp(ALEInterface *ale){return ale->getScreen().getBpp();} - - void getScreenRGB(ALEInterface *ale, unsigned char *output_buffer); - - void getScreenGrayscale(ALEInterface *ale, unsigned char *output_buffer); - - void saveState(ALEInterface *ale){ale->saveState();} - void loadState(ALEInterface *ale){ale->loadState();} -// ALEState* cloneState(ALEInterface *ale){return new ALEState(ale->cloneState());} -// void restoreState(ALEInterface *ale, ALEState* state){ale->restoreState(*state);} -// ALEState* cloneSystemState(ALEInterface *ale){return new ALEState(ale->cloneSystemState());} -// void restoreSystemState(ALEInterface *ale, ALEState* state){ale->restoreSystemState(*state);} -// void deleteState(ALEState* state){delete state;} -// void saveScreenPNG(ALEInterface *ale,const char *filename){ale->saveScreenPNG(filename);} -} - -#endif diff --git a/ale_python_interface/ale_python_interface.py b/ale_python_interface/ale_python_interface.py deleted file mode 100644 index 102418d..0000000 --- a/ale_python_interface/ale_python_interface.py +++ /dev/null @@ -1,234 +0,0 @@ -# ale_python_interface.py -# Author: Ben Goodrich -# This directly implements a python version of the arcade learning -# environment interface. - -from ctypes import * -import numpy as np -from numpy.ctypeslib import as_ctypes -import os - -ale_lib = cdll.LoadLibrary(os.path.join(os.path.dirname(__file__), - 'libale_c.so')) - -ale_lib.ALE_new.argtypes = None -ale_lib.ALE_new.restype = c_void_p -ale_lib.ALE_del.argtypes = [c_void_p] -ale_lib.ALE_del.restype = None -ale_lib.getString.argtypes = [c_void_p, c_char_p] -ale_lib.getString.restype = c_char_p -ale_lib.getInt.argtypes = [c_void_p, c_char_p] -ale_lib.getInt.restype = c_int -ale_lib.getBool.argtypes = [c_void_p, c_char_p] -ale_lib.getBool.restype = c_bool -ale_lib.getFloat.argtypes = [c_void_p, c_char_p] -ale_lib.getFloat.restype = c_float -ale_lib.setString.argtypes = [c_void_p, c_char_p, c_char_p] -ale_lib.setString.restype = None -ale_lib.setInt.argtypes = [c_void_p, c_char_p, c_int] -ale_lib.setInt.restype = None -ale_lib.setBool.argtypes = [c_void_p, c_char_p, c_bool] -ale_lib.setBool.restype = None -ale_lib.setFloat.argtypes = [c_void_p, c_char_p, c_float] -ale_lib.setFloat.restype = None -ale_lib.loadROM.argtypes = [c_void_p, c_char_p, c_char_p] -ale_lib.loadROM.restype = None -ale_lib.act.argtypes = [c_void_p, c_int, c_int] -ale_lib.act.restype = c_int -ale_lib.game_over.argtypes = [c_void_p] -ale_lib.game_over.restype = c_bool -ale_lib.reset_game.argtypes = [c_void_p] -ale_lib.reset_game.restype = None -ale_lib.getLegalActionSet.argtypes = [c_void_p, c_void_p] -ale_lib.getLegalActionSet.restype = None -ale_lib.getLegalActionSize.argtypes = [c_void_p] -ale_lib.getLegalActionSize.restype = c_int -ale_lib.getMinimalActionSet.argtypes = [c_void_p, c_void_p] -ale_lib.getMinimalActionSet.restype = None -ale_lib.getMinimalActionSize.argtypes = [c_void_p] -ale_lib.getMinimalActionSize.restype = c_int -ale_lib.getFrameNumber.argtypes = [c_void_p] -ale_lib.getFrameNumber.restype = c_int -ale_lib.lives.argtypes = [c_void_p] -ale_lib.lives.restype = c_int -ale_lib.getEpisodeFrameNumber.argtypes = [c_void_p] -ale_lib.getEpisodeFrameNumber.restype = c_int -ale_lib.getRAM.argtypes = [c_void_p, c_void_p] -ale_lib.getRAM.restype = None -ale_lib.getRAMSize.argtypes = [c_void_p] -ale_lib.getRAMSize.restype = c_int -ale_lib.getScreenWidth.argtypes = [c_void_p] -ale_lib.getScreenWidth.restype = c_int -ale_lib.getScreenHeight.argtypes = [c_void_p] -ale_lib.getScreenHeight.restype = c_int -ale_lib.getScreenBpp.argtypes = [c_void_p] -ale_lib.getScreenBpp.restype = c_int -ale_lib.getScreenRGB.argtypes = [c_void_p, c_void_p] -ale_lib.getScreenRGB.restype = None -ale_lib.getScreenGrayscale.argtypes = [c_void_p, c_void_p] -ale_lib.getScreenGrayscale.restype = None -ale_lib.saveState.argtypes = [c_void_p] -ale_lib.saveState.restype = None -ale_lib.loadState.argtypes = [c_void_p] -ale_lib.loadState.restype = None -#ale_lib.cloneState.argtypes = [c_void_p] -#ale_lib.cloneState.restype = c_void_p -#ale_lib.restoreState.argtypes = [c_void_p, c_void_p] -#ale_lib.restoreState.restype = None -#ale_lib.cloneSystemState.argtypes = [c_void_p] -#ale_lib.cloneSystemState.restype = c_void_p -#ale_lib.restoreSystemState.argtypes = [c_void_p, c_void_p] -#ale_lib.restoreSystemState.restype = None -#ale_lib.deleteState.argtypes = [c_void_p] -#ale_lib.deleteState.restype = None -#ale_lib.saveScreenPNG.argtypes = [c_void_p, c_char_p] -#ale_lib.saveScreenPNG.restype = None - -class ALEInterface(object): - def __init__(self): - self.obj = ale_lib.ALE_new() - - def getString(self, key): - return ale_lib.getString(self.obj, key) - def getInt(self, key): - return ale_lib.getInt(self.obj, key) - def getBool(self, key): - return ale_lib.getBool(self.obj, key) - def getFloat(self, key): - return ale_lib.getFloat(self.obj, key) - - def setString(self, key, value): - ale_lib.setString(self.obj, key, value) - def setInt(self, key, value): - ale_lib.setInt(self.obj, key, value) - def setBool(self, key, value): - ale_lib.setBool(self.obj, key, value) - def setFloat(self, key, value): - ale_lib.setFloat(self.obj, key, value) - - def loadROM(self, rom_file, core_file): - ale_lib.loadROM(self.obj, rom_file, core_file) - - def act(self, actionA, actionB = 0): - return ale_lib.act(self.obj, int(actionA), int(actionB)) - - def game_over(self): - return ale_lib.game_over(self.obj) - - def reset_game(self): - ale_lib.reset_game(self.obj) - - def getLegalActionSet(self): - act_size = ale_lib.getLegalActionSize(self.obj) - act = np.zeros((act_size), dtype=np.intc) - ale_lib.getLegalActionSet(self.obj, as_ctypes(act)) - return act - - def getMinimalActionSet(self): - act_size = ale_lib.getMinimalActionSize(self.obj) - act = np.zeros((act_size), dtype=np.intc) - ale_lib.getMinimalActionSet(self.obj, as_ctypes(act)) - return act - - def getFrameNumber(self): - return ale_lib.getFrameNumber(self.obj) - - def lives(self): - return ale_lib.lives(self.obj) - - def getEpisodeFrameNumber(self): - return ale_lib.getEpisodeFrameNumber(self.obj) - - def getScreenDims(self): - """returns a tuple that contains (screen_width, screen_height) - """ - width = ale_lib.getScreenWidth(self.obj) - height = ale_lib.getScreenHeight(self.obj) - return (width, height) - - def getScreenRGB(self, screen_data=None): - """This function fills screen_data with the data in RGB format - screen_data MUST be a numpy array of uint8. This can be initialized like so: - screen_data = np.empty((height,width,3), dtype=np.uint8) - If it is None, then this function will initialize it. - """ - if(screen_data is None): - width = ale_lib.getScreenWidth(self.obj) - height = ale_lib.getScreenHeight(self.obj) - screen_data = np.empty((height, width,3), dtype=np.uint8) - ale_lib.getScreenRGB(self.obj, as_ctypes(screen_data[:])) - return screen_data - - def getScreenGrayscale(self, screen_data=None): - """This function fills screen_data with the data in grayscale - screen_data MUST be a numpy array of uint8. This can be initialized like so: - screen_data = np.empty((height,width,1), dtype=np.uint8) - If it is None, then this function will initialize it. - """ - if(screen_data is None): - width = ale_lib.getScreenWidth(self.obj) - height = ale_lib.getScreenHeight(self.obj) - screen_data = np.empty((height, width,1), dtype=np.uint8) - ale_lib.getScreenGrayscale(self.obj, as_ctypes(screen_data[:])) - return screen_data - -# def getRAMSize(self): -# return ale_lib.getRAMSize(self.obj) -# -# def getRAM(self, ram=None): -# """This function grabs the atari RAM. -# ram MUST be a numpy array of uint8/int8. This can be initialized like so: -# ram = np.array(ram_size, dtype=uint8) -# Notice: It must be ram_size where ram_size can be retrieved via the getRAMSize function. -# If it is None, then this function will initialize it. -# """ -# if(ram is None): -# ram_size = ale_lib.getRAMSize(self.obj) -# ram = np.zeros(ram_size, dtype=np.uint8) -# ale_lib.getRAM(self.obj, as_ctypes(ram)) -# return ram -# -# def saveScreenPNG(self, filename): -# """Save the current screen as a png file""" -# return ale_lib.saveScreenPNG(self.obj, filename) - - def saveState(self): - """Saves the state of the system""" - return ale_lib.saveState(self.obj) - - def loadState(self): - """Loads the state of the system""" - return ale_lib.loadState(self.obj) - -# def cloneState(self): -# """This makes a copy of the environment state. This copy does *not* -# include pseudorandomness, making it suitable for planning -# purposes. By contrast, see cloneSystemState. -# """ -# return ale_lib.cloneState(self.obj) - -# def restoreState(self, state): -# """Reverse operation of cloneState(). This does not restore -# pseudorandomness, so that repeated calls to restoreState() in -# the stochastic controls setting will not lead to the same -# outcomes. By contrast, see restoreSystemState. -# """ -# ale_lib.restoreState(self.obj, state) - -# def cloneSystemState(self): -# """This makes a copy of the system & environment state, suitable for -# serialization. This includes pseudorandomness and so is *not* -# suitable for planning purposes. -# """ -# return ale_lib.cloneSystemState(self.obj) - -# def restoreSystemState(self, state): -# """Reverse operation of cloneSystemState.""" -# ale_lib.restoreSystemState(self.obj, state) - -# def deleteState(self, state): -# """ Deallocates the ALEState """ -# ale_lib.deleteState(state) - - def __del__(self): - ale_lib.ALE_del(self.obj) diff --git a/doc/examples/python_example.py b/doc/examples/python_example.py index 24d28b2..6285d28 100755 --- a/doc/examples/python_example.py +++ b/doc/examples/python_example.py @@ -6,16 +6,16 @@ # ALE provided in doc/examples/sharedLibraryInterfaceExample.cpp import sys from random import randrange -from ale_python_interface import ALEInterface +from rle_python_interface import RLEInterface if len(sys.argv) < 2: print 'Usage:', sys.argv[0], 'rom_file' sys.exit() -ale = ALEInterface() +rle = RLEInterface() # Get & Set the desired settings -ale.setInt('random_seed', 123) +rle.setInt('random_seed', 123) # Set USE_SDL to true to display the screen. ALE must be compilied # with SDL enabled for this to work. On OSX, pygame init is used to @@ -25,24 +25,24 @@ if sys.platform == 'darwin': import pygame pygame.init() - ale.setBool('sound', False) # Sound doesn't work on OSX + rle.setBool('sound', False) # Sound doesn't work on OSX elif sys.platform.startswith('linux'): - ale.setBool('sound', True) - ale.setBool('display_screen', True) + rle.setBool('sound', True) + rle.setBool('display_screen', True) # Load the ROM file -ale.loadROM(sys.argv[1], sys.argv[2]) +rle.loadROM(sys.argv[1], sys.argv[2]) # Get the list of legal actions -minimal_actions = ale.getMinimalActionSet() +minimal_actions = rle.getMinimalActionSet() # Play 10 episodes for episode in xrange(10): total_reward = 0 - while not ale.game_over(): + while not rle.game_over(): a = minimal_actions[randrange(len(legal_actions))] # Apply an action and get the resulting reward - reward = ale.act(a); + reward = rle.act(a); total_reward += reward print 'Episode', episode, 'ended with score:', total_reward - ale.reset_game() + rle.reset_game() diff --git a/doc/examples/sharedLibraryInterfaceExample.cpp b/doc/examples/sharedLibraryInterfaceExample.cpp index db5228f..c547e61 100644 --- a/doc/examples/sharedLibraryInterfaceExample.cpp +++ b/doc/examples/sharedLibraryInterfaceExample.cpp @@ -15,7 +15,7 @@ **************************************************************************** */ #include -#include +#include #include #include @@ -26,7 +26,7 @@ #endif using namespace std; -using namespace ale; +using namespace rle; #include int main(int argc, char** argv) { @@ -34,46 +34,46 @@ int main(int argc, char** argv) { std::cerr << "Usage: " << argv[0] << " rom_file core_file" << std::endl; return 1; } - ALEInterface ale; + RLEInterface rle; float maxVal = 1; float minVal = -1; // Get & Set the desired settings - ale.setInt("random_seed", 123); + rle.setInt("random_seed", 123); //The default is already 0.25, this is just an example - ale.setFloat("repeat_action_probability", 0.25); + rle.setFloat("repeat_action_probability", 0.25); #ifdef __USE_SDL - ale.setBool("display_screen", true); - ale.setBool("sound", true); + rle.setBool("display_screen", true); + rle.setBool("sound", true); #endif - ale.setString("MK_player1_character", "cage"); -// ale.setString("MK_player2_character", "scorpion"); - ale.setInt("MK_opponent_character", 4); + rle.setString("MK_player1_character", "cage"); +// rle.setString("MK_player2_character", "scorpion"); + rle.setInt("MK_opponent_character", 4); // Load the ROM file. (Also resets the system for new settings to // take effect.) - ale.loadROM(argv[1], argv[2]); + rle.loadROM(argv[1], argv[2]); // Get the vector of minimal actions - ActionVect legal_actions = ale.getMinimalActionSet(); + ActionVect legal_actions = rle.getMinimalActionSet(); // // Play 10 episodes for (int episode=0; episode<10; episode++) { float totalReward = 0; float totalCroppedReward = 0; - while (!ale.game_over()) { + while (!rle.game_over()) { Action a = legal_actions[rand() % legal_actions.size()]; // Apply the action and get the resulting reward - float reward = ale.act(a); + float reward = rle.act(a); float croppedReward = reward > 0 ? std::min(reward, maxVal) : std::max(reward, minVal); totalCroppedReward += croppedReward; totalReward += reward; } cout << "Episode " << episode << " ended with score: " << totalReward << endl; cout << "Episode " << episode << " ended with cropped score: " << totalCroppedReward << endl; - ale.reset_game(); + rle.reset_game(); } return 0; } diff --git a/rle-1-0.rockspec b/rle-1-0.rockspec new file mode 100644 index 0000000..04335f4 --- /dev/null +++ b/rle-1-0.rockspec @@ -0,0 +1,20 @@ +package = 'rle' +version = '1-0' + +source = { + url = 'git://github.com/nadavbh12/Retro-Learning-Environment.git' +} + +description = { + summary = "Rle" +} + +dependencies = { 'torch >= 7.0' } +build = { + type = "command", + build_command = [[ + cmake -DINSTALL_CORES=ON -DUSE_SDL=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)/../../../../../" .; + $(MAKE) -j 4 + ]], + install_command = "$(MAKE) install" + } diff --git a/ale.cfg b/rle.cfg similarity index 65% rename from ale.cfg rename to rle.cfg index ae9efef..e1f95eb 100644 --- a/ale.cfg +++ b/rle.cfg @@ -1,11 +1,10 @@ -# Use this file to set default options for ALE. +# Use this file to set default options for RLE. # One setting per line. # Format: option-name=option-value # # Example. # -# cpu=low # repeat_action_probability=0.25 # # Note that, for the Python and C++ interface, these options are set when the interface is -# first created (i.e. within ALEInterface's constructor), and not when the ROM is loaded. +# first created (i.e. within RLEInterface's constructor), and not when the ROM is loaded. diff --git a/rle_python_interface/__init__.py b/rle_python_interface/__init__.py new file mode 100644 index 0000000..d30792f --- /dev/null +++ b/rle_python_interface/__init__.py @@ -0,0 +1 @@ +from rle_python_interface import * diff --git a/rle_python_interface/rle_c_wrapper.cpp b/rle_python_interface/rle_c_wrapper.cpp new file mode 100644 index 0000000..ca46de5 --- /dev/null +++ b/rle_python_interface/rle_c_wrapper.cpp @@ -0,0 +1,68 @@ +#include "rle_c_wrapper.h" + +#include +#include +#include + +//void encodeState(RLEState *state, char *buf, int buf_len) { +// std::string str = state->serialize(); +// +// if (buf_len < int(str.length())) { +// throw new std::runtime_error("Buffer is not big enough to hold serialized RLEState. Please use encodeStateLen to determine the correct buffer size"); +// } +// +// memcpy(buf, str.data(), str.length()); +//} +// +//int encodeStateLen(RLEState *state) { +// return state->serialize().length(); +//} +// +//RLEState *decodeState(const char *serialized, int len) { +// std::string str(serialized, len); +// +// return new RLEState(str); +//} + + +static void rle_rearrangeRgb(uint8_t *dst_buffer, const uint32_t *src_buffer, size_t src_size , const RLEInterface *rle) { + + uint8_t *q = dst_buffer; + uint8_t r, g, b; + for(size_t i = 0; i < src_size; ++i, ++q){ + rle->getScreen().getRGB(((uint16_t*)src_buffer)[i], r, g, b); + *q = (unsigned char) (r); q++; // r + *q = (unsigned char) (g); q++; // g + *q = (unsigned char) (b); q++; // b + } +} + +static void rle_rearrangeGrayscrle(uint8_t *dst_buffer, const uint32_t *src_buffer, size_t src_size , const RLEInterface *rle) { + + uint8_t *q = dst_buffer; + uint8_t r, g, b; + for(size_t i = 0; i < src_size; ++i, ++q){ + rle->getScreen().getRGB(((uint16_t*)src_buffer)[i], r, g, b); + *q = (unsigned char) (0.3*r + 0.5*g+0.2*b); + } +} + +void getScreenRGB(RLEInterface *rle, unsigned char *output_buffer){ + const rle::RLEScreen& screen = rle->getScreen(); + size_t w = screen.width(); + size_t h = screen.height(); + size_t screen_size = w*h; + size_t size_in_pixels = screen_size; + rle_rearrangeRgb(output_buffer, (uint32_t*)screen.getArray(), size_in_pixels, rle); +} + +//This method should receive an empty vector to fill it with +//the grayscrle colours +void getScreenGrayscrle(RLEInterface *rle, unsigned char *output_buffer){ + const rle::RLEScreen& screen = rle->getScreen(); + size_t w = rle->getScreen().width(); + size_t h = rle->getScreen().height(); + size_t screen_size = w*h; + size_t size_in_pixels = screen_size ; + rle_rearrangeGrayscrle(output_buffer, (uint32_t*)screen.getArray(), size_in_pixels, rle); +} diff --git a/rle_python_interface/rle_c_wrapper.h b/rle_python_interface/rle_c_wrapper.h new file mode 100644 index 0000000..fb42ffb --- /dev/null +++ b/rle_python_interface/rle_c_wrapper.h @@ -0,0 +1,65 @@ +#ifndef __RLE_C_WRAPPER_H__ +#define __RLE_C_WRAPPER_H__ + +#include + +using namespace rle; + +extern "C" { + // Declares int rgb_prlette[256] + RLEInterface *RLE_new() {return new RLEInterface();} + void RLE_del(RLEInterface *rle){delete rle;} + const char *getString(RLEInterface *rle, const char *key){return rle->getString(key).c_str();} + int getInt(RLEInterface *rle,const char *key) {return rle->getInt(key);} + bool getBool(RLEInterface *rle,const char *key){return rle->getBool(key);} + float getFloat(RLEInterface *rle,const char *key){return rle->getFloat(key);} + void setString(RLEInterface *rle,const char *key,const char *value){rle->setString(key,value);} + void setInt(RLEInterface *rle,const char *key,int value){rle->setInt(key,value);} + void setBool(RLEInterface *rle,const char *key,bool value){rle->setBool(key,value);} + void setFloat(RLEInterface *rle,const char *key,float value){rle->setFloat(key,value);} + void loadROM(RLEInterface *rle,const char *rom_file, const char *core_file){rle->loadROM(rom_file,core_file);} + int act(RLEInterface *rle,int actionA, int actionB){return rle->act((Action)actionA, (Action)actionB);} + bool game_over(RLEInterface *rle){return rle->game_over();} + void reset_game(RLEInterface *rle){rle->reset_game();} + void getLegalActionSet(RLEInterface *rle,int *actions){ + ActionVect action_vect = rle->getLegalActionSet(); + for(unsigned int i = 0;i < rle->getLegalActionSet().size();i++){ + actions[i] = action_vect[i]; + } + } + int getLegalActionSize(RLEInterface *rle){return rle->getLegalActionSet().size();} + void getMinimalActionSet(RLEInterface *rle,int *actions){ + ActionVect action_vect = rle->getMinimalActionSet(); + for(unsigned int i = 0;i < rle->getMinimalActionSet().size();i++){ + actions[i] = action_vect[i]; + } + } + int getMinimalActionSize(RLEInterface *rle){return rle->getMinimalActionSet().size();} + int getFrameNumber(RLEInterface *rle){return rle->getFrameNumber();} + int lives(RLEInterface *rle){return rle->lives();} + int getEpisodeFrameNumber(RLEInterface *rle){return rle->getEpisodeFrameNumber();} + void getRAM(RLEInterface *rle,unsigned char *ram){ +// unsigned char *rle_ram = rle->getRAM().array(); +// int size = rle->getRAM().size(); +// memcpy(ram,rle_ram,size*sizeof(unsigned char)); + } + int getRAMSize(RLEInterface *rle){return rle->getRAM().size();} + int getScreenWidth(RLEInterface *rle){return rle->getScreen().width();} + int getScreenHeight(RLEInterface *rle){return rle->getScreen().height();} + int getScreenBpp(RLEInterface *rle){return rle->getScreen().getBpp();} + + void getScreenRGB(RLEInterface *rle, unsigned char *output_buffer); + + void getScreenGrayscrle(RLEInterface *rle, unsigned char *output_buffer); + + void saveState(RLEInterface *rle){rle->saveState();} + void loadState(RLEInterface *rle){rle->loadState();} +// RLEState* cloneState(RLEInterface *rle){return new RLEState(rle->cloneState());} +// void restoreState(RLEInterface *rle, RLEState* state){rle->restoreState(*state);} +// RLEState* cloneSystemState(RLEInterface *rle){return new RLEState(rle->cloneSystemState());} +// void restoreSystemState(RLEInterface *rle, RLEState* state){rle->restoreSystemState(*state);} +// void deleteState(RLEState* state){delete state;} +// void saveScreenPNG(RLEInterface *rle,const char *filename){rle->saveScreenPNG(filename);} +} + +#endif diff --git a/rle_python_interface/rle_python_interface.py b/rle_python_interface/rle_python_interface.py new file mode 100644 index 0000000..54cf1ab --- /dev/null +++ b/rle_python_interface/rle_python_interface.py @@ -0,0 +1,234 @@ +# rle_python_interface.py +# Author: Ben Goodrich +# This directly implements a python version of the arcade learning +# environment interface. + +from ctypes import * +import numpy as np +from numpy.ctypeslib import as_ctypes +import os + +rle_lib = cdll.LoadLibrary(os.path.join(os.path.dirname(__file__), + 'librle_c.so')) + +rle_lib.RLE_new.argtypes = None +rle_lib.RLE_new.restype = c_void_p +rle_lib.RLE_del.argtypes = [c_void_p] +rle_lib.RLE_del.restype = None +rle_lib.getString.argtypes = [c_void_p, c_char_p] +rle_lib.getString.restype = c_char_p +rle_lib.getInt.argtypes = [c_void_p, c_char_p] +rle_lib.getInt.restype = c_int +rle_lib.getBool.argtypes = [c_void_p, c_char_p] +rle_lib.getBool.restype = c_bool +rle_lib.getFloat.argtypes = [c_void_p, c_char_p] +rle_lib.getFloat.restype = c_float +rle_lib.setString.argtypes = [c_void_p, c_char_p, c_char_p] +rle_lib.setString.restype = None +rle_lib.setInt.argtypes = [c_void_p, c_char_p, c_int] +rle_lib.setInt.restype = None +rle_lib.setBool.argtypes = [c_void_p, c_char_p, c_bool] +rle_lib.setBool.restype = None +rle_lib.setFloat.argtypes = [c_void_p, c_char_p, c_float] +rle_lib.setFloat.restype = None +rle_lib.loadROM.argtypes = [c_void_p, c_char_p, c_char_p] +rle_lib.loadROM.restype = None +rle_lib.act.argtypes = [c_void_p, c_int, c_int] +rle_lib.act.restype = c_int +rle_lib.game_over.argtypes = [c_void_p] +rle_lib.game_over.restype = c_bool +rle_lib.reset_game.argtypes = [c_void_p] +rle_lib.reset_game.restype = None +rle_lib.getLegalActionSet.argtypes = [c_void_p, c_void_p] +rle_lib.getLegalActionSet.restype = None +rle_lib.getLegalActionSize.argtypes = [c_void_p] +rle_lib.getLegalActionSize.restype = c_int +rle_lib.getMinimalActionSet.argtypes = [c_void_p, c_void_p] +rle_lib.getMinimalActionSet.restype = None +rle_lib.getMinimalActionSize.argtypes = [c_void_p] +rle_lib.getMinimalActionSize.restype = c_int +rle_lib.getFrameNumber.argtypes = [c_void_p] +rle_lib.getFrameNumber.restype = c_int +rle_lib.lives.argtypes = [c_void_p] +rle_lib.lives.restype = c_int +rle_lib.getEpisodeFrameNumber.argtypes = [c_void_p] +rle_lib.getEpisodeFrameNumber.restype = c_int +rle_lib.getRAM.argtypes = [c_void_p, c_void_p] +rle_lib.getRAM.restype = None +rle_lib.getRAMSize.argtypes = [c_void_p] +rle_lib.getRAMSize.restype = c_int +rle_lib.getScreenWidth.argtypes = [c_void_p] +rle_lib.getScreenWidth.restype = c_int +rle_lib.getScreenHeight.argtypes = [c_void_p] +rle_lib.getScreenHeight.restype = c_int +rle_lib.getScreenBpp.argtypes = [c_void_p] +rle_lib.getScreenBpp.restype = c_int +rle_lib.getScreenRGB.argtypes = [c_void_p, c_void_p] +rle_lib.getScreenRGB.restype = None +rle_lib.getScreenGrayscrle.argtypes = [c_void_p, c_void_p] +rle_lib.getScreenGrayscrle.restype = None +rle_lib.saveState.argtypes = [c_void_p] +rle_lib.saveState.restype = None +rle_lib.loadState.argtypes = [c_void_p] +rle_lib.loadState.restype = None +#rle_lib.cloneState.argtypes = [c_void_p] +#rle_lib.cloneState.restype = c_void_p +#rle_lib.restoreState.argtypes = [c_void_p, c_void_p] +#rle_lib.restoreState.restype = None +#rle_lib.cloneSystemState.argtypes = [c_void_p] +#rle_lib.cloneSystemState.restype = c_void_p +#rle_lib.restoreSystemState.argtypes = [c_void_p, c_void_p] +#rle_lib.restoreSystemState.restype = None +#rle_lib.deleteState.argtypes = [c_void_p] +#rle_lib.deleteState.restype = None +#rle_lib.saveScreenPNG.argtypes = [c_void_p, c_char_p] +#rle_lib.saveScreenPNG.restype = None + +class RLEInterface(object): + def __init__(self): + self.obj = rle_lib.RLE_new() + + def getString(self, key): + return rle_lib.getString(self.obj, key) + def getInt(self, key): + return rle_lib.getInt(self.obj, key) + def getBool(self, key): + return rle_lib.getBool(self.obj, key) + def getFloat(self, key): + return rle_lib.getFloat(self.obj, key) + + def setString(self, key, value): + rle_lib.setString(self.obj, key, value) + def setInt(self, key, value): + rle_lib.setInt(self.obj, key, value) + def setBool(self, key, value): + rle_lib.setBool(self.obj, key, value) + def setFloat(self, key, value): + rle_lib.setFloat(self.obj, key, value) + + def loadROM(self, rom_file, core_file): + rle_lib.loadROM(self.obj, rom_file, core_file) + + def act(self, actionA, actionB = 0): + return rle_lib.act(self.obj, int(actionA), int(actionB)) + + def game_over(self): + return rle_lib.game_over(self.obj) + + def reset_game(self): + rle_lib.reset_game(self.obj) + + def getLegalActionSet(self): + act_size = rle_lib.getLegalActionSize(self.obj) + act = np.zeros((act_size), dtype=np.intc) + rle_lib.getLegalActionSet(self.obj, as_ctypes(act)) + return act + + def getMinimalActionSet(self): + act_size = rle_lib.getMinimalActionSize(self.obj) + act = np.zeros((act_size), dtype=np.intc) + rle_lib.getMinimalActionSet(self.obj, as_ctypes(act)) + return act + + def getFrameNumber(self): + return rle_lib.getFrameNumber(self.obj) + + def lives(self): + return rle_lib.lives(self.obj) + + def getEpisodeFrameNumber(self): + return rle_lib.getEpisodeFrameNumber(self.obj) + + def getScreenDims(self): + """returns a tuple that contains (screen_width, screen_height) + """ + width = rle_lib.getScreenWidth(self.obj) + height = rle_lib.getScreenHeight(self.obj) + return (width, height) + + def getScreenRGB(self, screen_data=None): + """This function fills screen_data with the data in RGB format + screen_data MUST be a numpy array of uint8. This can be initialized like so: + screen_data = np.empty((height,width,3), dtype=np.uint8) + If it is None, then this function will initialize it. + """ + if(screen_data is None): + width = rle_lib.getScreenWidth(self.obj) + height = rle_lib.getScreenHeight(self.obj) + screen_data = np.empty((height, width,3), dtype=np.uint8) + rle_lib.getScreenRGB(self.obj, as_ctypes(screen_data[:])) + return screen_data + + def getScreenGrayscrle(self, screen_data=None): + """This function fills screen_data with the data in grayscrle + screen_data MUST be a numpy array of uint8. This can be initialized like so: + screen_data = np.empty((height,width,1), dtype=np.uint8) + If it is None, then this function will initialize it. + """ + if(screen_data is None): + width = rle_lib.getScreenWidth(self.obj) + height = rle_lib.getScreenHeight(self.obj) + screen_data = np.empty((height, width,1), dtype=np.uint8) + rle_lib.getScreenGrayscrle(self.obj, as_ctypes(screen_data[:])) + return screen_data + +# def getRAMSize(self): +# return rle_lib.getRAMSize(self.obj) +# +# def getRAM(self, ram=None): +# """This function grabs the atari RAM. +# ram MUST be a numpy array of uint8/int8. This can be initialized like so: +# ram = np.array(ram_size, dtype=uint8) +# Notice: It must be ram_size where ram_size can be retrieved via the getRAMSize function. +# If it is None, then this function will initialize it. +# """ +# if(ram is None): +# ram_size = rle_lib.getRAMSize(self.obj) +# ram = np.zeros(ram_size, dtype=np.uint8) +# rle_lib.getRAM(self.obj, as_ctypes(ram)) +# return ram +# +# def saveScreenPNG(self, filename): +# """Save the current screen as a png file""" +# return rle_lib.saveScreenPNG(self.obj, filename) + + def saveState(self): + """Saves the state of the system""" + return rle_lib.saveState(self.obj) + + def loadState(self): + """Loads the state of the system""" + return rle_lib.loadState(self.obj) + +# def cloneState(self): +# """This makes a copy of the environment state. This copy does *not* +# include pseudorandomness, making it suitable for planning +# purposes. By contrast, see cloneSystemState. +# """ +# return rle_lib.cloneState(self.obj) + +# def restoreState(self, state): +# """Reverse operation of cloneState(). This does not restore +# pseudorandomness, so that repeated calls to restoreState() in +# the stochastic controls setting will not lead to the same +# outcomes. By contrast, see restoreSystemState. +# """ +# rle_lib.restoreState(self.obj, state) + +# def cloneSystemState(self): +# """This makes a copy of the system & environment state, suitable for +# serialization. This includes pseudorandomness and so is *not* +# suitable for planning purposes. +# """ +# return rle_lib.cloneSystemState(self.obj) + +# def restoreSystemState(self, state): +# """Reverse operation of cloneSystemState.""" +# rle_lib.restoreSystemState(self.obj, state) + +# def deleteState(self, state): +# """ Deallocates the RLEState """ +# rle_lib.deleteState(state) + + def __del__(self): + rle_lib.RLE_del(self.obj) diff --git a/setup.py b/setup.py index f139502..fa8eac5 100644 --- a/setup.py +++ b/setup.py @@ -1,25 +1,25 @@ from distutils.core import setup, Extension import os.path, sys -ale_c_lib = 'ale_python_interface/libale_c.so' -if not os.path.isfile(ale_c_lib): +rle_c_lib = 'rle_python_interface/librle_c.so' +if not os.path.isfile(rle_c_lib): print 'ERROR: Unable to find required library: %s. Please ensure you\'ve '\ - 'built ALE using CMake.'%(ale_c_lib) + 'built RLE using CMake.'%(rle_c_lib) sys.exit() -module1 = Extension('ale_python_interface.ale_c_wrapper', - libraries = ['ale_c'], +module1 = Extension('rle_python_interface.rle_c_wrapper', + libraries = ['rle_c'], include_dirs = ['src'], - library_dirs = ['ale_python_interface'], + library_dirs = ['rle_python_interface'], extra_compile_args=['-D__STDC_CONSTANT_MACROS -std=c++11'], - sources=['ale_python_interface/ale_c_wrapper.cpp']) -setup(name = 'ale_python_interface', - version='0.0.1', + sources=['rle_python_interface/rle_c_wrapper.cpp']) +setup(name = 'rle_python_interface', + version='0.1.0', description = 'Arcade Learning Environment Python Interface', - url='https://github.com/bbitmaster/ale_python_interface', - author='Ben Goodrich', + url='github.com/nadavbh12/Retro-Learning-Environment', + author='Ben Goodrich', # Modified by Nadav Bhonker license='GPL', ext_modules = [module1], - packages=['ale_python_interface'], - package_dir={'ale_python_interface': 'ale_python_interface'}, - package_data={'ale_python_interface': ['libale_c.so']}) + packages=['rle_python_interface'], + package_dir={'rle_python_interface': 'rle_python_interface'}, + package_data={'rle_python_interface': ['librle_c.so']}) diff --git a/src/ale_interface.o b/src/ale_interface.o deleted file mode 100644 index cc3da4e..0000000 Binary files a/src/ale_interface.o and /dev/null differ diff --git a/src/common/.deps/SoundNull.d b/src/common/.deps/SoundNull.d deleted file mode 100644 index 3f847a4..0000000 --- a/src/common/.deps/SoundNull.d +++ /dev/null @@ -1,88 +0,0 @@ -src/common/SoundNull.o: src/common/SoundNull.cxx \ - src/emucore/Serializer.hxx src/emucore/m6502/src/bspf/src/bspf.hxx \ - src/emucore/Deserializer.hxx src/emucore/m6502/src/bspf/src/bspf.hxx \ - src/emucore/OSystem.hxx src/emucore/../common/Array.hxx \ - src/emucore/../common/../emucore/m6502/src/bspf/src/bspf.hxx \ - src/emucore/Sound.hxx src/emucore/../common/SoundNull.hxx \ - src/emucore/../common/../emucore/Sound.hxx src/emucore/Settings.hxx \ - src/emucore/Console.hxx src/emucore/Control.hxx src/emucore/Props.hxx \ - src/emucore/TIA.hxx src/emucore/m6502/src/Device.hxx \ - src/emucore/m6502/src/bspf/src/bspf.hxx src/emucore/MediaSrc.hxx \ - src/emucore/Cart.hxx src/emucore/../common/Log.hpp src/emucore/M6532.hxx \ - src/emucore/Random.hxx src/emucore/AtariVox.hxx src/emucore/Event.hxx \ - src/emucore/../common/display_screen.h src/emucore/../common/Constants.h \ - src/emucore/../common/ColourPalette.hpp \ - src/emucore/../common/../emucore/MediaSrc.hxx \ - src/emucore/../common/ColourPalette.hpp \ - src/emucore/../common/ScreenExporter.hpp \ - src/emucore/../common/display_screen.h \ - src/emucore/../common/../environment/ale_screen.hpp \ - src/emucore/Settings.hxx src/common/SoundNull.hxx - -src/emucore/Serializer.hxx: - -src/emucore/m6502/src/bspf/src/bspf.hxx: - -src/emucore/Deserializer.hxx: - -src/emucore/m6502/src/bspf/src/bspf.hxx: - -src/emucore/OSystem.hxx: - -src/emucore/../common/Array.hxx: - -src/emucore/../common/../emucore/m6502/src/bspf/src/bspf.hxx: - -src/emucore/Sound.hxx: - -src/emucore/../common/SoundNull.hxx: - -src/emucore/../common/../emucore/Sound.hxx: - -src/emucore/Settings.hxx: - -src/emucore/Console.hxx: - -src/emucore/Control.hxx: - -src/emucore/Props.hxx: - -src/emucore/TIA.hxx: - -src/emucore/m6502/src/Device.hxx: - -src/emucore/m6502/src/bspf/src/bspf.hxx: - -src/emucore/MediaSrc.hxx: - -src/emucore/Cart.hxx: - -src/emucore/../common/Log.hpp: - -src/emucore/M6532.hxx: - -src/emucore/Random.hxx: - -src/emucore/AtariVox.hxx: - -src/emucore/Event.hxx: - -src/emucore/../common/display_screen.h: - -src/emucore/../common/Constants.h: - -src/emucore/../common/ColourPalette.hpp: - -src/emucore/../common/../emucore/MediaSrc.hxx: - -src/emucore/../common/ColourPalette.hpp: - -src/emucore/../common/ScreenExporter.hpp: - -src/emucore/../common/display_screen.h: - -src/emucore/../common/../environment/ale_screen.hpp: - -src/emucore/Settings.hxx: - -src/common/SoundNull.hxx: diff --git a/src/common/Constants.cpp b/src/common/Constants.cpp index 4cbbf53..2fff320 100644 --- a/src/common/Constants.cpp +++ b/src/common/Constants.cpp @@ -16,11 +16,11 @@ #include "Constants.h" #include -using namespace ale; +using namespace rle; #define CAT_STR(s, x, y) if ((x & y) > 0){ if (first){first=false;s << #y ;} else {s << " | " << #y ;}} -std::string ale::action_to_string(ale::Action a) { +std::string rle::action_to_string(rle::Action a) { std::stringstream ss; bool first = true; CAT_STR(ss, a, JOYPAD_B ); diff --git a/src/common/Constants.h b/src/common/Constants.h index 8fcdf52..81753cf 100644 --- a/src/common/Constants.h +++ b/src/common/Constants.h @@ -27,17 +27,17 @@ #include "DebugMacros.h" #include #include "../libretro.h" -#include "ale_interface.hpp" +#include "rle_interface.hpp" -namespace ale{ +namespace rle{ std::string action_to_string(Action a); const string ATARI_PATH = "./stella-libretro/stella_libretro.so"; const string SNES_PATH = "./snes9x2010/snes9x2010_libretro.so"; -} // namespace ale +} // namespace rle #endif // __CONSTANTS_H__ diff --git a/src/common/Log.cpp b/src/common/Log.cpp index 64ef888..3812c79 100644 --- a/src/common/Log.cpp +++ b/src/common/Log.cpp @@ -1,6 +1,6 @@ #include "Log.hpp" #include -using namespace ale; +using namespace rle; Logger::mode Logger::current_mode = Info; @@ -8,7 +8,7 @@ void Logger::setMode(Logger::mode m){ current_mode = m; } -ale::Logger::mode ale::operator<<(ale::Logger::mode log, std::ostream & (*manip)(std::ostream &)) { +rle::Logger::mode rle::operator<<(rle::Logger::mode log, std::ostream & (*manip)(std::ostream &)) { if(log >= Logger::current_mode) manip(std::cerr); return log; diff --git a/src/common/Log.hpp b/src/common/Log.hpp index 4f5b53c..72bf3cc 100644 --- a/src/common/Log.hpp +++ b/src/common/Log.hpp @@ -1,7 +1,7 @@ #ifndef __LOG_HPP__ #define __LOG_HPP__ #include -namespace ale +namespace rle { class Logger { diff --git a/src/common/AleException.h b/src/common/RleException.h similarity index 65% rename from src/common/AleException.h rename to src/common/RleException.h index eed05c8..ac93c66 100644 --- a/src/common/AleException.h +++ b/src/common/RleException.h @@ -1,5 +1,5 @@ /* - * AleException.h + * RleException.h * * Created on: Jan 5, 2016 * Author: administrator @@ -12,12 +12,12 @@ #include using namespace std; -class AleException : public exception +class RleException : public exception { public: - AleException(); - AleException(string str) : description(str){}; - AleException(const char* str) : description(str){}; + RleException(); + RleException(string str) : description(str){}; + RleException(const char* str) : description(str){}; virtual const char* what() const throw() { return description.c_str(); diff --git a/src/common/ScreenExporter.cpp b/src/common/ScreenExporter.cpp index 91421e7..f139529 100644 --- a/src/common/ScreenExporter.cpp +++ b/src/common/ScreenExporter.cpp @@ -23,7 +23,7 @@ // SN: #include -using namespace ale; +using namespace rle; //// MGB: These methods originally belonged to ExportScreen. Possibly these should be returned to //// their own class, rather than be static methods. They are here to avoid exposing the gritty @@ -61,7 +61,7 @@ using namespace ale; //} // // -//static void writePNGHeader(std::ofstream& out, const ALEScreen &screen, bool doubleWidth = true) { +//static void writePNGHeader(std::ofstream& out, const RLEScreen &screen, bool doubleWidth = true) { // // int width = doubleWidth ? screen.width() * 2: screen.width(); // int height = screen.height(); @@ -88,7 +88,7 @@ using namespace ale; //} // // -//static void writePNGData(std::ofstream &out, const ALEScreen &screen, const ColourPalette &palette, bool doubleWidth = true) { +//static void writePNGData(std::ofstream &out, const RLEScreen &screen, const ColourPrlette &prlette, bool doubleWidth = true) { // // int dataWidth = screen.width(); // int width = doubleWidth ? dataWidth * 2 : dataWidth; @@ -107,7 +107,7 @@ using namespace ale; // for(int j = 0; j < dataWidth; j++) { // int r, g, b; // -// palette.getRGB(screen.getArray()[i * dataWidth + j], r, g, b); +// prlette.getRGB(screen.getArray()[i * dataWidth + j], r, g, b); // // Double the pixel width, if so desired // int jj = doubleWidth ? 2 * j : j; // @@ -134,7 +134,7 @@ using namespace ale; // if((compress(&compmem[0], &compmemsize, &buffer[0], height * (width * 3 + 1)) != Z_OK)) { // // // @todo -- throw a proper exception -// ale::Logger::Error << "Error: Couldn't compress PNG" << std::endl; +// rle::Logger::Error << "Error: Couldn't compress PNG" << std::endl; // return; // } // @@ -149,41 +149,41 @@ using namespace ale; // writePNGChunk(out, "IEND", 0, 0); //} -//ScreenExporter::ScreenExporter(ColourPalette &palette): -// m_palette(palette), +//ScreenExporter::ScreenExporter(ColourPrlette &prlette): +// m_prlette(prlette), // m_frame_number(0), // m_frame_field_width(6) { //} // // -//ScreenExporter::ScreenExporter(ColourPalette &palette, const std::string &path): -// m_palette(palette), +//ScreenExporter::ScreenExporter(ColourPrlette &prlette, const std::string &path): +// m_prlette(prlette), // m_frame_number(0), // m_frame_field_width(6), // m_path(path) { //} -void ScreenExporter::save(const ALEScreen &screen, const std::string &filename) const { +void ScreenExporter::save(const RLEScreen &screen, const std::string &filename) const { // Open file for writing std::ofstream out(filename.c_str(), std::ios_base::binary); if (!out.good()) { // @todo exception - ale::Logger::Error << "Could not open " << filename << " for writing" << std::endl; + rle::Logger::Error << "Could not open " << filename << " for writing" << std::endl; return; } // Now write the PNG proper // writePNGHeader(out, screen, true); -// writePNGData(out, screen, m_palette, true); +// writePNGData(out, screen, m_prlette, true); // writePNGEnd(out); out.close(); } -void ScreenExporter::saveNext(const ALEScreen &screen) { +void ScreenExporter::saveNext(const RLEScreen &screen) { // Must have specified a directory. assert(m_path.size() > 0); diff --git a/src/common/ScreenExporter.hpp b/src/common/ScreenExporter.hpp index c55e5fa..7f8c9da 100644 --- a/src/common/ScreenExporter.hpp +++ b/src/common/ScreenExporter.hpp @@ -19,33 +19,33 @@ #include #include "display_screen.h" -#include "../environment/ale_screen.hpp" +#include "../environment/rle_screen.hpp" //SN: #include -namespace ale { +namespace rle { class ScreenExporter { public: /** Creates a new ScreenExporter which can be used to save screens using save(filename). */ -// ScreenExporter(ColourPalette &palette); +// ScreenExporter(ColourPrlette &prlette); /** Creates a new ScreenExporter which will save frames successively in the directory provided. Frames are sequentially named with 6 digits, starting at 000000. */ -// ScreenExporter(ColourPalette &palette, const std::string &path); +// ScreenExporter(ColourPrlette &prlette, const std::string &path); /** Save the given screen to the given filename. No paths are created. */ - void save(const ALEScreen &screen, const std::string &filename) const; + void save(const RLEScreen &screen, const std::string &filename) const; /** Save the given screen according to our own internal numbering. */ - void saveNext(const ALEScreen &screen); + void saveNext(const RLEScreen &screen); private: -// ColourPalette &m_palette; +// ColourPrlette &m_prlette; /** The next frame number. */ int m_frame_number; @@ -57,7 +57,7 @@ class ScreenExporter { std::string m_path; }; -} // namespace ale +} // namespace rle #endif // __SCREEN_EXPORTER_HPP__ diff --git a/src/common/SoundExporter.cpp b/src/common/SoundExporter.cpp index 742b955..d47fc87 100644 --- a/src/common/SoundExporter.cpp +++ b/src/common/SoundExporter.cpp @@ -1,7 +1,7 @@ #include "SoundExporter.hpp" #include -namespace ale { +namespace rle { namespace sound { // Sample rate is 60Hz x SamplesPerFrame bytes @@ -72,6 +72,6 @@ void SoundExporter::writeWAVData() { // stream.write((const char*)&m_data[0], bufSize); // The samples DATA!!! } -} // namespace ale::sound -} // namespace ale +} // namespace rle::sound +} // namespace rle diff --git a/src/common/SoundExporter.hpp b/src/common/SoundExporter.hpp index 61a52f2..fa3eb47 100644 --- a/src/common/SoundExporter.hpp +++ b/src/common/SoundExporter.hpp @@ -25,7 +25,7 @@ #include #include -namespace ale { +namespace rle { namespace sound { template @@ -66,7 +66,7 @@ class SoundExporter { size_t m_samples_since_write; }; -} // namespace ale::sound -} // namespace ale +} // namespace rle::sound +} // namespace rle #endif // __SOUND_EXPORTER_HPP__ diff --git a/src/common/display_screen.cpp b/src/common/display_screen.cpp index b3ed9eb..1ee03c2 100644 --- a/src/common/display_screen.cpp +++ b/src/common/display_screen.cpp @@ -19,7 +19,7 @@ #include using namespace std; -using namespace ale; +using namespace rle; #ifdef __USE_SDL DisplayScreen::DisplayScreen(RetroAgent* rAgent ): manual_control_active(false), delay_msec(5), ragent(rAgent) { diff --git a/src/common/display_screen.h b/src/common/display_screen.h index 45ee549..005e193 100644 --- a/src/common/display_screen.h +++ b/src/common/display_screen.h @@ -27,7 +27,7 @@ #include "SDL.h" #include "SDL/SDL_rotozoom.h" -namespace ale { +namespace rle { class DisplayScreen { public: @@ -42,7 +42,7 @@ class DisplayScreen { bool manual_control_engaged() { return manual_control_active; } // Captures the keypress of a user in manual control mode. - ale::Action getUserAction(); + rle::Action getUserAction(); protected: // Checks for SDL events. @@ -67,10 +67,10 @@ class DisplayScreen { RetroAgent* ragent; }; -} // namespace ale +} // namespace rle #else -namespace ale { +namespace rle { /** A dummy class that simply ignores display events. */ class DisplayScreen { public: @@ -80,7 +80,7 @@ class DisplayScreen { Action getUserAction() { return JOYPAD_UNDEFINED; } }; -} // namespace ale +} // namespace rle #endif // __USE_SDL #endif // DISPLAY_SCREEN diff --git a/src/environment/RetroAgent.cpp b/src/environment/RetroAgent.cpp index 40de755..9f39e9b 100644 --- a/src/environment/RetroAgent.cpp +++ b/src/environment/RetroAgent.cpp @@ -9,7 +9,7 @@ #include -#include "AleException.h" +#include "RleException.h" #include "RetroAgent.h" #include "DebugMacros.h" #include @@ -17,7 +17,7 @@ #include "Serializer.hxx" #include "Deserializer.hxx" -using namespace ale; +using namespace rle; std::atomic_uint RetroAgent::numAgents{0}; thread_local struct RetroAgent::g_retro_ RetroAgent::g_retro; @@ -510,7 +510,7 @@ uint8_t* RetroAgent::getRamAddress(unsigned id){ size_t size = g_retro.retro_get_memory_size(id); void* data = g_retro.retro_get_memory_data(id); if (!size){ - throw AleException("Ram size is 0"); + throw RleException("Ram size is 0"); }else{ return (uint8_t*)data; } diff --git a/src/environment/RetroAgent.h b/src/environment/RetroAgent.h index 9969638..4a4f57b 100644 --- a/src/environment/RetroAgent.h +++ b/src/environment/RetroAgent.h @@ -14,7 +14,7 @@ typedef unsigned char byte_t; class Serializer; class Deserializer; -namespace ale { +namespace rle { class RetroAgent{ public: @@ -75,7 +75,7 @@ class RetroAgent{ int action_a; int action_b; - // string saveFolder = "/home/administrator/DQN/ale-nano/SNES-Learning-Environment/saves/"; + // string saveFolder = "/home/administrator/DQN/rle-nano/SNES-Learning-Environment/saves/"; string corePath; size_t serializeSize; }; @@ -112,6 +112,6 @@ class RetroAgent{ void unloadRom(); }; -} // namespace ale +} // namespace rle #endif // __RETRO_AGENT_HPP__ diff --git a/src/environment/AleSystem.cxx b/src/environment/RleSystem.cxx similarity index 77% rename from src/environment/AleSystem.cxx rename to src/environment/RleSystem.cxx index 5e001a0..f487be8 100644 --- a/src/environment/AleSystem.cxx +++ b/src/environment/RleSystem.cxx @@ -9,34 +9,27 @@ using namespace std; #include "FSNode.hxx" #include "Settings.hxx" -#include "AleSystem.hxx" -#include "SoundSDL.hxx" -//#define MAX_ROM_SIZE 512 * 1024 - +#include "RleSystem.hxx" #include #include "bspf.hxx" -using namespace ale; +using namespace rle; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AleSystem::AleSystem(RetroAgent* retroagent) +RleSystem::RleSystem(RetroAgent* retroagent) : - myRetroAgent(retroagent), //RLE -// mySound(NULL), mySettings(NULL), - myQuitLoop(false), - mySkipEmulation(false), + myRetroAgent(retroagent), //RLE myRomFile(""), myCoreFile(""), - myFeatures(""), p_display_screen(NULL) {} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AleSystem::~AleSystem() +RleSystem::~RleSystem() { - // AleSystem takes responsibility for framebuffer and sound, + // RleSystem takes responsibility for framebuffer and sound, // since it created them // if (mySound != NULL) // delete mySound; @@ -48,14 +41,14 @@ AleSystem::~AleSystem() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool AleSystem::create() +bool RleSystem::create() { // Create the sound object; the sound subsystem isn't actually // opened until needed, so this is non-blocking (on those systems // that only have a single sound device (no hardware mixing) // createSound(); - // Seed RNG. This will likely get re-called, e.g. by the ALEInterface, but is needed + // Seed RNG. This will likely get re-called, e.g. by the RLEInterface, but is needed // by other interfaces. resetRNGSeed(); @@ -63,7 +56,7 @@ bool AleSystem::create() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void AleSystem::resetRNGSeed() { +void RleSystem::resetRNGSeed() { // We seed the random number generator. The 'time' seed is somewhat redundant, since the // rng defaults to time. But we'll do it anyway. @@ -76,18 +69,18 @@ void AleSystem::resetRNGSeed() { } } -bool AleSystem::saveState(Serializer& out) { +bool RleSystem::saveState(Serializer& out) { // Here we serialize the RNG state. return myRandGen.saveState(out); } -bool AleSystem::loadState(Deserializer& in) { +bool RleSystem::loadState(Deserializer& in) { return myRandGen.loadState(in); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//void AleSystem::setConfigPaths() +//void RleSystem::setConfigPaths() //{ // myGameListCacheFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.cache"; // @@ -96,10 +89,10 @@ bool AleSystem::loadState(Deserializer& in) { // myCheatFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.cht"; // mySettings->setString("cheatfile", myCheatFile); // -// myPaletteFile = mySettings->getString("palettefile"); -// if(myPaletteFile == "") -// myPaletteFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.pal"; -// mySettings->setString("palettefile", myPaletteFile); +// myPrletteFile = mySettings->getString("prlettefile"); +// if(myPrletteFile == "") +// myPrletteFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.pal"; +// mySettings->setString("prlettefile", myPrletteFile); // // myPropertiesFile = mySettings->getString("propsfile"); // if(myPropertiesFile == "") @@ -107,7 +100,7 @@ bool AleSystem::loadState(Deserializer& in) { // mySettings->setString("propsfile", myPropertiesFile); //} -void AleSystem::setBaseDir(const string& basedir) +void RleSystem::setBaseDir(const string& basedir) { myBaseDir = basedir; if(!FilesystemNode::dirExists(myBaseDir)) @@ -115,19 +108,19 @@ void AleSystem::setBaseDir(const string& basedir) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void AleSystem::step() { +void RleSystem::step() { myRetroAgent->run(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void AleSystem::setFramerate(uInt32 framerate) +void RleSystem::setFramerate(uInt32 framerate) { myDisplayFrameRate = framerate; myTimePerFrame = (uInt32)(1000000.0 / (double)myDisplayFrameRate); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//void AleSystem::createSound() +//void RleSystem::createSound() //{ // if (mySound != NULL) { // delete mySound; @@ -150,20 +143,20 @@ void AleSystem::setFramerate(uInt32 framerate) //} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool AleSystem::loadCore(const string& corePath){ +bool RleSystem::loadCore(const string& corePath){ myCoreFile = corePath; myRetroAgent->loadCore(corePath); return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool AleSystem::loadRom(const string& rom){ +bool RleSystem::loadRom(const string& rom){ myRomFile = rom; myRetroAgent->loadRom(rom); return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//void AleSystem::resetLoopTiming() +//void RleSystem::resetLoopTiming() //{ // memset(&myTimingInfo, 0, sizeof(TimingInfo)); // myTimingInfo.start = getTicks(); diff --git a/src/environment/AleSystem.hxx b/src/environment/RleSystem.hxx similarity index 88% rename from src/environment/AleSystem.hxx rename to src/environment/RleSystem.hxx index 9fe46b6..9db258a 100644 --- a/src/environment/AleSystem.hxx +++ b/src/environment/RleSystem.hxx @@ -13,13 +13,13 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: AleSystem.hxx,v 1.55 2007/08/12 23:05:12 stephena Exp $ +// $Id: RleSystem.hxx,v 1.55 2007/08/12 23:05:12 stephena Exp $ //============================================================================ -#ifndef AleSystem_HXX -#define AleSystem_HXX +#ifndef RleSystem_HXX +#define RleSystem_HXX -namespace ale { +namespace rle { //class PropertiesSet; class GameController; @@ -33,7 +33,6 @@ class VideoDialog; } #include "../common/Array.hxx" -#include "../common/SoundNull.hxx" #include "Settings.hxx" #include "../common/display_screen.h" #include "../common/ScreenExporter.hpp" @@ -44,7 +43,7 @@ class VideoDialog; #include "RetroAgent.h" -namespace ale { +namespace rle { struct Resolution { uInt32 width; @@ -53,25 +52,25 @@ struct Resolution { }; typedef Common::Array ResolutionList; -class AleSystem +class RleSystem { public: /** - Create a new AleSystem abstract class + Create a new RleSystem abstract class */ - AleSystem(RetroAgent* retroagent); + RleSystem(RetroAgent* retroagent); /** Destructor */ - virtual ~AleSystem(); + virtual ~RleSystem(); - AleSystem(const AleSystem&) = delete; + RleSystem(const RleSystem&) = delete; - AleSystem& operator = (const AleSystem&) = delete; + RleSystem& operator = (const RleSystem&) = delete; /** - Create all child objects which belong to this AleSystem + Create all child objects which belong to this RleSystem */ virtual bool create(); @@ -128,7 +127,7 @@ class AleSystem virtual void setFramerate(uInt32 framerate); /** - Set all config file paths for the AleSystem. + Set all config file paths for the RleSystem. */ void setConfigPaths(); @@ -196,13 +195,6 @@ class AleSystem */ bool loadRom(const string& rom); - /** - Issue a quit event to the AleSystem. - */ - void quit() { myQuitLoop = true; } - - void skipEmulation() { mySkipEmulation = true; } - /** Returns the random number generator for this emulator. */ @@ -214,12 +206,12 @@ class AleSystem void resetRNGSeed(); /** - Serializes the AleSystem state. + Serializes the RleSystem state. */ bool saveState(Serializer& out); /** - Deserializes the AleSystem state. + Deserializes the RleSystem state. */ bool loadState(Deserializer& in); @@ -254,7 +246,7 @@ class AleSystem Settings* mySettings; // Pointer to RetroAgent - RetroAgent* myRetroAgent; // SLE + RetroAgent* myRetroAgent; // RLE // Random number generator shared across the emulator's components Random myRandGen; @@ -268,9 +260,6 @@ class AleSystem // Number of times per second to iterate through the main loop uInt32 myDisplayFrameRate; - // Indicates whether to stop the main loop - bool myQuitLoop; - // Indicates that the emulation should not occur on the next time step // This is reset to false after one step bool mySkipEmulation; @@ -280,7 +269,6 @@ class AleSystem std::string myRomFile; std::string myCoreFile; std::string myConfigFile; - std::string myFeatures; public: //ALE // Time per frame for a video update, based on the current framerate @@ -298,7 +286,7 @@ class AleSystem // Table of RGB values for GUI elements - //ALE static uInt32 ourGUIColors[kNumUIPalettes][kNumColors-256]; + //ALE static uInt32 ourGUIColors[kNumUIPrlettes][kNumColors-256]; public: DisplayScreen* p_display_screen; //MHAUSKN @@ -326,6 +314,6 @@ class AleSystem }; -} // namespace ale +} // namespace rle #endif diff --git a/src/environment/Settings.cxx b/src/environment/Settings.cxx index f016153..ff4b4bd 100644 --- a/src/environment/Settings.cxx +++ b/src/environment/Settings.cxx @@ -26,14 +26,14 @@ using namespace std; //#include "OSystem.hxx" #include "bspf.hxx" #include "Settings.hxx" -#include "AleSystem.hxx" +#include "RleSystem.hxx" -using namespace ale; +using namespace rle; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Settings::Settings(AleSystem* alesystem) : myAleSystem(alesystem) { +Settings::Settings(RleSystem* rlesystem) : myRleSystem(rlesystem) { // Add this settings object to the OSystem - myAleSystem->attach(this); + myRleSystem->attach(this); setInternal("sound", "false"); setDefaultSettings(); @@ -51,7 +51,7 @@ void Settings::loadConfig(const char* config_file) { ifstream in(config_file); if (!in || !in.is_open()) { - ale::Logger::Warning << "Warning: couldn't load settings file: " + rle::Logger::Warning << "Warning: couldn't load settings file: " << config_file << std::endl; return; } @@ -89,7 +89,7 @@ void Settings::loadConfig(const char* config_file) { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Settings::loadConfig() { - loadConfig(myAleSystem->configFile().c_str()); + loadConfig(myRleSystem->configFile().c_str()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -116,7 +116,7 @@ string Settings::loadCommandLine(int argc, char** argv) { } if (++i >= argc) { - ale::Logger::Error << "Missing argument for '" << key << "'" + rle::Logger::Error << "Missing argument for '" << key << "'" << endl; return ""; } @@ -188,9 +188,9 @@ void Settings::validate() { else if (i > 800) setInternal("pthresh", "800"); - s = getString("palette"); + s = getString("prlette"); if (s != "standard" && s != "z26" && s != "user") - setInternal("palette", "standard"); + setInternal("prlette", "standard"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -203,7 +203,7 @@ void Settings::usage() { " * (Powered by LibRetro)\n" " ***************************************************************************\n" "\n" - " Usage: ale [options ...] -core_file corefile romfile\n" + " Usage: rle [options ...] -core_file corefile romfile\n" "\n" " Main arguments:\n" " -help -- prints out help information\n" @@ -277,9 +277,9 @@ void Settings::saveConfig() { if (!settingsChanged) return; - ofstream out(myAleSystem->configFile().c_str()); + ofstream out(myRleSystem->configFile().c_str()); if (!out || !out.is_open()) { - ale::Logger::Error << "Error: Couldn't save settings file\n"; + rle::Logger::Error << "Error: Couldn't save settings file\n"; return; } @@ -373,8 +373,8 @@ int Settings::getInt(const string& key, bool strict) const { return (int) atoi(myExternalSettings[idx].value.c_str()); } else { if (strict) { - ale::Logger::Error << "No value found for key: " << key << ". "; - ale::Logger::Error + rle::Logger::Error << "No value found for key: " << key << ". "; + rle::Logger::Error << "Make sure all the settings files are loaded." << endl; exit(-1); @@ -396,8 +396,8 @@ float Settings::getFloat(const string& key, bool strict) const { return (float) atof(myExternalSettings[idx].value.c_str()); } else { if (strict) { - ale::Logger::Error << "No value found for key: " << key << ". "; - ale::Logger::Error + rle::Logger::Error << "No value found for key: " << key << ". "; + rle::Logger::Error << "Make sure all the settings files are loaded." << endl; exit(-1); @@ -430,8 +430,8 @@ bool Settings::getBool(const string& key, bool strict) const { return false; } else { if (strict) { - ale::Logger::Error << "No value found for key: " << key << ". "; - ale::Logger::Error << "Make sure all the settings files are loaded." + rle::Logger::Error << "No value found for key: " << key << ". "; + rle::Logger::Error << "Make sure all the settings files are loaded." << endl; exit(-1); } else { @@ -450,8 +450,8 @@ const string& Settings::getString(const string& key, bool strict) const { return myExternalSettings[idx].value; } else { if (strict) { - ale::Logger::Error << "No value found for key: " << key << ". "; - ale::Logger::Error << "Make sure all the settings files are loaded." + rle::Logger::Error << "No value found for key: " << key << ". "; + rle::Logger::Error << "Make sure all the settings files are loaded." << endl; exit(-1); } else { diff --git a/src/environment/Settings.hxx b/src/environment/Settings.hxx index 10a6686..f7f7c4e 100644 --- a/src/environment/Settings.hxx +++ b/src/environment/Settings.hxx @@ -26,9 +26,9 @@ #include "../common/Log.hpp" #include "../common/bspf.hxx" -namespace ale { +namespace rle { -class AleSystem; +class RleSystem; /** This class provides an interface for accessing frontend specific settings. @@ -42,7 +42,7 @@ class Settings /** Create a new settings abstract class */ - Settings(AleSystem* alesystem); + Settings(RleSystem* rlesystem); /** Destructor @@ -189,7 +189,7 @@ class Settings protected: // The parent OSystem object - AleSystem* myAleSystem; + RleSystem* myRleSystem; // Structure used for storing settings struct Setting @@ -234,6 +234,6 @@ class Settings SettingsArray myExternalSettings; }; -} // namespace ale +} // namespace rle #endif diff --git a/src/environment/phosphor_blend.cpp b/src/environment/phosphor_blend.cpp index e869f3e..979a6f7 100644 --- a/src/environment/phosphor_blend.cpp +++ b/src/environment/phosphor_blend.cpp @@ -17,7 +17,7 @@ #include "phosphor_blend.hpp" //#include "../emucore/Console.hxx" -using namespace ale; +using namespace rle; PhosphorBlend::PhosphorBlend( // OSystem * osystem): @@ -28,10 +28,10 @@ PhosphorBlend::PhosphorBlend( // Taken from default Stella settings // m_phosphor_blend_ratio = 77; - makeAveragePalette(); + makeAveragePrlette(); } -void PhosphorBlend::process(ALEScreen& screen) { +void PhosphorBlend::process(RLEScreen& screen) { // Console& console = m_osystem->console(); // TODO SN: replace medisSource @@ -45,28 +45,28 @@ void PhosphorBlend::process(ALEScreen& screen) { // int pv = previous_buffer[i]; // // // Find out the corresponding rgb color -// uInt32 rgb = m_avg_palette[cv][pv]; +// uInt32 rgb = m_avg_prlette[cv][pv]; // // // Set the corresponding pixel in the array // screen.getArray()[i] = rgbToNTSC(rgb); // } } -void PhosphorBlend::makeAveragePalette() { +void PhosphorBlend::makeAveragePrlette() { -// ColourPalette &palette = m_osystem->colourPalette(); +// ColourPrlette &prlette = m_osystem->colourPrlette(); // // // Precompute the average RGB values for phosphor-averaged colors c1 and c2 // for (int c1 = 0; c1 < 256; c1++) { // for (int c2 = 0; c2 < 256; c2++) { // int r1, g1, b1; // int r2, g2, b2; -// palette.getRGB(c1, r1, g1, b1); -// palette.getRGB(c2, r2, g2, b2); +// prlette.getRGB(c1, r1, g1, b1); +// prlette.getRGB(c2, r2, g2, b2); // // uInt8 r = getPhosphor(r1, r2); // uInt8 g = getPhosphor(g1, g2); // uInt8 b = getPhosphor(b1, b2); -// m_avg_palette[c1][c2] = makeRGB(r, g, b); +// m_avg_prlette[c1][c2] = makeRGB(r, g, b); // } // } // @@ -81,7 +81,7 @@ void PhosphorBlend::makeAveragePalette() { // for (int c1 = 0; c1 < 256; c1++) { // // Get the RGB corresponding to c1 // int r1, g1, b1; -// palette.getRGB(c1, r1, g1, b1); +// prlette.getRGB(c1, r1, g1, b1); // // int dist = abs(r1 - r) + abs(g1 - g) + abs(b1 - b); // if (dist < minDist) { diff --git a/src/environment/phosphor_blend.hpp b/src/environment/phosphor_blend.hpp index af6f3fc..567d45b 100644 --- a/src/environment/phosphor_blend.hpp +++ b/src/environment/phosphor_blend.hpp @@ -18,10 +18,10 @@ #define __PHOSPHOR_BLEND_HPP__ //#include "../emucore/OSystem.hxx" -#include "ale_screen.hpp" -#include "AleSystem.hxx" +#include "rle_screen.hpp" +#include "RleSystem.hxx" -namespace ale { +namespace rle { class PhosphorBlend { public: @@ -29,10 +29,10 @@ class PhosphorBlend { // OSystem * ); - void process(ALEScreen& screen); + void process(RLEScreen& screen); private: - void makeAveragePalette(); + void makeAveragePrlette(); // uInt8 getPhosphor(uInt8 v1, uInt8 v2); // uInt32 makeRGB(uInt8 r, uInt8 g, uInt8 b); // /** Converts a RGB value to an 8-bit format */ @@ -43,11 +43,11 @@ class PhosphorBlend { // uInt8 m_rgb_ntsc[64][64][64]; // -// uInt32 m_avg_palette[256][256]; +// uInt32 m_avg_prlette[256][256]; // uInt8 m_phosphor_blend_ratio; }; -} // namespace ale +} // namespace rle #endif // __PHOSPHOR_BLEND_HPP__ diff --git a/src/environment/retro_environment.cpp b/src/environment/retro_environment.cpp index 0817f5d..35da284 100644 --- a/src/environment/retro_environment.cpp +++ b/src/environment/retro_environment.cpp @@ -18,63 +18,63 @@ #include "retro_environment.hpp" #include -using namespace ale; +using namespace rle; -RetroEnvironment::RetroEnvironment(AleSystem* alesystem, RomSettings* settings) : - m_alesystem(alesystem), +RetroEnvironment::RetroEnvironment(RleSystem* rlesystem, RomSettings* settings) : + m_rlesystem(rlesystem), m_settings(settings), - m_phosphor_blend( ), // TODO pass AleSystem - m_screen(m_alesystem->getRetroAgent().getHeight(), - m_alesystem->getRetroAgent().getWidth()), + m_phosphor_blend( ), // TODO pass RleSystem + m_screen(m_rlesystem->getRetroAgent().getHeight(), + m_rlesystem->getRetroAgent().getWidth()), m_player_a_action(PLAYER_A | JOYPAD_NOOP), m_player_b_action(PLAYER_B | JOYPAD_NOOP) { // TODO SN : Add support for paddle-based games // Determine whether this is a paddle-based game -// if (m_alesystem->console().properties().get(Controller_Left) == "PADDLES" || -// m_alesystem->console().properties().get(Controller_Right) == "PADDLES") { +// if (m_rlesystem->console().properties().get(Controller_Left) == "PADDLES" || +// m_rlesystem->console().properties().get(Controller_Right) == "PADDLES") { // m_use_paddles = true; -// m_state.resetPaddles(m_alesystem->event()); +// m_state.resetPaddles(m_rlesystem->event()); // } else { // m_use_paddles = false; // } m_num_reset_steps = 4; - m_max_num_frames_per_episode = m_alesystem->settings().getInt("max_num_frames_per_episode"); - m_colour_averaging = m_alesystem->settings().getBool("color_averaging"); + m_max_num_frames_per_episode = m_rlesystem->settings().getInt("max_num_frames_per_episode"); + m_colour_averaging = m_rlesystem->settings().getBool("color_averaging"); - m_repeat_action_probability = m_alesystem->settings().getFloat("repeat_action_probability"); + m_repeat_action_probability = m_rlesystem->settings().getFloat("repeat_action_probability"); - m_frame_skip = m_alesystem->settings().getInt("frame_skip"); + m_frame_skip = m_rlesystem->settings().getInt("frame_skip"); if (m_frame_skip < 1) { - ale::Logger::Warning << "Warning: frame skip set to < 1. Setting to 1." << std::endl; + rle::Logger::Warning << "Warning: frame skip set to < 1. Setting to 1." << std::endl; m_frame_skip = 1; } // If so desired, we record all emulated frames to a given directory - std::string recordDir = m_alesystem->settings().getString("record_screen_dir"); + std::string recordDir = m_rlesystem->settings().getString("record_screen_dir"); getPixelFormat(*m_screen.m_pixelFormat); if (!recordDir.empty()) { - ale::Logger::Info << "Recording screens to directory: " << recordDir << std::endl; + rle::Logger::Info << "Recording screens to directory: " << recordDir << std::endl; // TODO SN : implement screen_exporter // Create the screen exporter -// m_screen_exporter.reset(new ScreenExporter(m_alesystem->colourPalette(), recordDir)); +// m_screen_exporter.reset(new ScreenExporter(m_rlesystem->colourPrlette(), recordDir)); } } void RetroEnvironment::getPixelFormat(struct pixelFormat &pixel_format){ uint32_t rmask, gmask, bmask, amask; uint32_t rShift, gShift, bShift, aShift; - pixel_format.Bpp=m_alesystem->getRetroAgent().getBpp()/8; //in bytes - m_alesystem->getRetroAgent().getRgbMask(rmask, gmask, bmask, amask); - m_alesystem->getRetroAgent().getRgbShift(rShift, gShift, bShift, aShift); + pixel_format.Bpp=m_rlesystem->getRetroAgent().getBpp()/8; //in bytes + m_rlesystem->getRetroAgent().getRgbMask(rmask, gmask, bmask, amask); + m_rlesystem->getRetroAgent().getRgbShift(rShift, gShift, bShift, aShift); //mask pixel_format.rmask=rmask; pixel_format.gmask=gmask; @@ -97,7 +97,7 @@ void RetroEnvironment::reset() { m_state.resetEpisodeFrameNumber(); // Reset the emulator - m_alesystem->getRetroAgent().reset(); + m_rlesystem->getRetroAgent().reset(); // NOOP for 60 steps in the deterministic environment setting, or some random amount otherwise int noopSteps; @@ -111,7 +111,7 @@ void RetroEnvironment::reset() { m_settings->reset(); // Apply necessary actions specified by the rom itself - ActionVect startingActions = m_settings->getStartingActions(*m_alesystem); + ActionVect startingActions = m_settings->getStartingActions(*m_rlesystem); for (size_t i = 0; i < startingActions.size(); i++){ if((startingActions[i] & PLAYER_B) > 0){ emulateStart(JOYPAD_NOOP, startingActions[i]); @@ -119,41 +119,41 @@ void RetroEnvironment::reset() { emulateStart(startingActions[i], PLAYER_B | JOYPAD_NOOP); } // uncomment to view screen of starting actions -// m_alesystem->p_display_screen->display_screen(); +// m_rlesystem->p_display_screen->display_screen(); } - m_settings->startingOperations(*m_alesystem); + m_settings->startingOperations(*m_rlesystem); } /** Save/restore the environment state. */ void RetroEnvironment::save() { // Store the current state into a new object - ALEState new_state = cloneState(); + RLEState new_state = cloneState(); m_saved_states.push(new_state); } void RetroEnvironment::load() { // Get the state on top of the stack - ALEState& target_state = m_saved_states.top(); + RLEState& target_state = m_saved_states.top(); // Deserialize it into 'm_state' restoreState(target_state); m_saved_states.pop(); } -ALEState RetroEnvironment::cloneState() { - return m_state.save(m_alesystem, m_settings, false); +RLEState RetroEnvironment::cloneState() { + return m_state.save(m_rlesystem, m_settings, false); } -void RetroEnvironment::restoreState(const ALEState& target_state) { - m_state.load(m_alesystem, m_settings, target_state, false); +void RetroEnvironment::restoreState(const RLEState& target_state) { + m_state.load(m_rlesystem, m_settings, target_state, false); } -ALEState RetroEnvironment::cloneSystemState() { - return m_state.save(m_alesystem, m_settings, true); +RLEState RetroEnvironment::cloneSystemState() { + return m_state.save(m_rlesystem, m_settings, true); } -void RetroEnvironment::restoreSystemState(const ALEState& target_state) { - m_state.load(m_alesystem, m_settings, target_state, true); +void RetroEnvironment::restoreSystemState(const RLEState& target_state) { + m_state.load(m_rlesystem, m_settings, target_state, true); } void RetroEnvironment::noopIllegalActions(Action & player_a_action, Action & player_b_action) { @@ -178,7 +178,7 @@ reward_t RetroEnvironment::act(Action player_a_action, Action player_b_action) { // Total reward received as we repeat the action reward_t sum_rewards = 0; - Random& rng = m_alesystem->rng(); + Random& rng = m_rlesystem->rng(); // Apply the same action for a given number of times... note that act() will refuse to emulate // past the terminal state @@ -194,7 +194,7 @@ reward_t RetroEnvironment::act(Action player_a_action, Action player_b_action) { // TODO SN : fix record of sound // If so desired, request one frame's worth of sound (this does nothing if recording // is not enabled) -// m_alesystem->sound().recordNextFrame(); +// m_rlesystem->sound().recordNextFrame(); // Similarly record screen as needed // if (m_screen_exporter.get() != NULL) @@ -244,18 +244,18 @@ void RetroEnvironment::emulate(const Action& player_a_action, const Action& play // // Update paddle position at every step // m_state.applyActionPaddles(event, player_a_action, player_b_action); // -// m_alesystem->console().mediaSource().update(); -// m_settings->step(m_alesystem->console().system()); +// m_rlesystem->console().mediaSource().update(); +// m_settings->step(m_rlesystem->console().system()); // } // } // else { // In joystick mode we only need to set the action events once // m_state.setActionJoysticks(player_a_action, player_b_action); - m_alesystem->getRetroAgent().SetActions(player_a_action,player_b_action); + m_rlesystem->getRetroAgent().SetActions(player_a_action,player_b_action); for (size_t t = 0; t < num_steps; ++t) { - m_alesystem->step(); - m_settings->step(*m_alesystem); + m_rlesystem->step(); + m_settings->step(*m_rlesystem); } // } @@ -267,18 +267,18 @@ void RetroEnvironment::emulate(const Action& player_a_action, const Action& play void RetroEnvironment::emulateStart(Action player_a_action, Action player_b_action, size_t num_steps) { - m_alesystem->getRetroAgent().SetActions(player_a_action,player_b_action); + m_rlesystem->getRetroAgent().SetActions(player_a_action,player_b_action); for (size_t t = 0; t < num_steps; ++t) { - m_alesystem->step(); + m_rlesystem->step(); } } /** Accessor methods for the environment state. */ -void RetroEnvironment::setState(const ALEState& state) { +void RetroEnvironment::setState(const RLEState& state) { m_state = state; } -const ALEState& RetroEnvironment::getState() const { +const RLEState& RetroEnvironment::getState() const { return m_state; } @@ -289,12 +289,12 @@ void RetroEnvironment::processScreen() { // } // else { // Copy screen over and we're done! -// memcpy(m_screen.getArray(),(uint32_t*) m_alesystem->getCurrentFrameBuffer(), 4*m_alesystem->getRetroAgent().getBufferSize()); //shai: consider adding min/max of size // *4 to go to pixel - int height = m_alesystem->getRetroAgent().getHeight(); - int width = m_alesystem->getRetroAgent().getWidth(); - int Bpp = m_alesystem->getRetroAgent().getBpp() / 8; - int pitch = m_alesystem->getRetroAgent().getPitch(); - uint8_t* buffer = m_alesystem->getCurrentFrameBuffer(); +// memcpy(m_screen.getArray(),(uint32_t*) m_rlesystem->getCurrentFrameBuffer(), 4*m_rlesystem->getRetroAgent().getBufferSize()); //shai: consider adding min/max of size // *4 to go to pixel + int height = m_rlesystem->getRetroAgent().getHeight(); + int width = m_rlesystem->getRetroAgent().getWidth(); + int Bpp = m_rlesystem->getRetroAgent().getBpp() / 8; + int pitch = m_rlesystem->getRetroAgent().getPitch(); + uint8_t* buffer = m_rlesystem->getCurrentFrameBuffer(); for(int i = 0 ; i < height; ++i){ memcpy((uint8_t*)m_screen.getArray() + i*width *Bpp , buffer + i*pitch, width * Bpp); } @@ -302,11 +302,11 @@ void RetroEnvironment::processScreen() { //// FILE *a = fopen("/home/administrator/DQN/DeepMind-Atari-Deep-Q-Learner/cWrite1.txt", "w"); // FILE *b = fopen("/home/administrator/DQN/DeepMind-Atari-Deep-Q-Learner/cWrite2.txt", "w"); -// uint8_t* originBuffer = m_alesystem->getCurrentFrameBuffer(); +// uint8_t* originBuffer = m_rlesystem->getCurrentFrameBuffer(); // uint8_t* destBuffer = (uint8_t*)m_screen.getArray(); -// size_t size = m_alesystem->getRetroAgent().getHeight() * m_alesystem->getRetroAgent().getPitch(); +// size_t size = m_rlesystem->getRetroAgent().getHeight() * m_rlesystem->getRetroAgent().getPitch(); // for( int i = 0; i < height * width * Bpp ; i++){ -//// if(i % m_alesystem->getRetroAgent().getPitch() == 0){ +//// if(i % m_rlesystem->getRetroAgent().getPitch() == 0){ //// fprintf(a,"\n"); //// } // if(i % (width * Bpp) == 0){ @@ -324,9 +324,9 @@ void RetroEnvironment::processScreen() { void RetroEnvironment::processRAM() { // Copy RAM over //// for (size_t i = 0; i < m_ram.size(); i++) -//// *m_ram.byte(i) = m_alesystem->console().system().peek(i + 0x80); -// uint32_t* memPtr = m_alesystem->getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); -// uint32_t memSize = m_alesystem->getRetroAgent().getRamSize(); +//// *m_ram.byte(i) = m_rlesystem->console().system().peek(i + 0x80); +// uint32_t* memPtr = m_rlesystem->getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); +// uint32_t memSize = m_rlesystem->getRetroAgent().getRamSize(); // DEBUG2("mem address " << memPtr); // DEBUG2("mem size " << memSize ); // DEBUG2("value at end " << *(memPtr + memSize/8) ); diff --git a/src/environment/retro_environment.hpp b/src/environment/retro_environment.hpp index ed43151..52b5992 100644 --- a/src/environment/retro_environment.hpp +++ b/src/environment/retro_environment.hpp @@ -15,12 +15,12 @@ * **************************************************************************** */ -#ifndef __ALE_ENVIRONMENT_HPP__ -#define __ALE_ENVIRONMENT_HPP__ +#ifndef __RLE_ENVIRONMENT_HPP__ +#define __RLE_ENVIRONMENT_HPP__ -#include "ale_state.hpp" -#include "ale_screen.hpp" -#include "ale_ram.hpp" +#include "rle_state.hpp" +#include "rle_screen.hpp" +#include "rle_ram.hpp" #include "phosphor_blend.hpp" #include "../games/RomSettings.hpp" #include "../common/ScreenExporter.hpp" @@ -28,10 +28,10 @@ #include "../common/DebugMacros.h" #include "RetroAgent.h" -#include "AleSystem.hxx" +#include "RleSystem.hxx" #include -namespace ale { +namespace rle { struct pixelFormat { uint32_t rmask; @@ -55,7 +55,7 @@ class RetroEnvironment { public: RetroEnvironment( - AleSystem * system, + RleSystem * system, RomSettings * settings); /** Resets the system to its start state. */ @@ -67,15 +67,15 @@ class RetroEnvironment { /** Returns a copy of the current emulator state. Note that this doesn't include pseudorandomness, so that clone/restoreState are suitable for planning. */ - ALEState cloneState(); + RLEState cloneState(); /** Restores a previously saved copy of the state. */ - void restoreState(const ALEState&); + void restoreState(const RLEState&); /** Returns a copy of the current emulator state. This includes RNG state information, and more generally should lead to exactly reproducibility. */ - ALEState cloneSystemState(); + RLEState cloneSystemState(); /** Restores a previously saved copy of the state, including RNG state information. */ - void restoreSystemState(const ALEState&); + void restoreSystemState(const RLEState&); /** Applies the given actions (e.g. updating paddle positions when the paddle is used) * and performs one simulation step in Stella. Returns the resultant reward. When @@ -89,13 +89,13 @@ class RetroEnvironment { bool isTerminal(); /** Accessor methods for the environment state. */ - void setState(const ALEState & state); - const ALEState &getState() const; + void setState(const RLEState & state); + const RLEState &getState() const; /** Returns the current screen after processing (e.g. color averaging) */ - const ALEScreen &getScreen() const { return m_screen; } - const ALERAM &getRAM() const { return m_ram; } + const RLEScreen &getScreen() const { return m_screen; } + const RLERAM &getRAM() const { return m_ram; } int getFrameNumber() const{ return m_state.getFrameNumber(); } int getEpisodeFrameNumber() const {return m_state.getEpisodeFrameNumber(); } @@ -123,16 +123,16 @@ class RetroEnvironment { void getPixelFormat(struct pixelFormat &m_pixelFormat); private: - AleSystem *m_alesystem; + RleSystem *m_rlesystem; RomSettings *m_settings; PhosphorBlend m_phosphor_blend; // For performing phosphor colour averaging, if so desired // std::string m_cartridge_md5; // Necessary for saving and loading emulator state - std::stack m_saved_states; // States are saved on a stack + std::stack m_saved_states; // States are saved on a stack - ALEState m_state; // Current environment state - ALEScreen m_screen; // The current ALE screen (possibly colour-averaged) - ALERAM m_ram; // The current ALE RAM + RLEState m_state; // Current environment state + RLEScreen m_screen; // The current ALE screen (possibly colour-averaged) + RLERAM m_ram; // The current ALE RAM // bool m_use_paddles; // Whether this game uses paddles @@ -149,6 +149,6 @@ class RetroEnvironment { }; -} // namespace ale +} // namespace rle -#endif // __ALE_ENVIRONMENT_HPP__ +#endif // __RLE_ENVIRONMENT_HPP__ diff --git a/src/environment/ale_ram.cpp b/src/environment/rle_ram.cpp similarity index 74% rename from src/environment/ale_ram.cpp rename to src/environment/rle_ram.cpp index 4fad26d..2bd0a7d 100644 --- a/src/environment/ale_ram.cpp +++ b/src/environment/rle_ram.cpp @@ -9,34 +9,34 @@ * * ******************************************************************************/ -#include "../ale_interface.hpp" +#include "../rle_interface.hpp" -namespace ale { -inline ALERAM::ALERAM(const ALERAM &rhs) { +namespace rle { +inline RLERAM::RLERAM(const RLERAM &rhs) { // Copy data over // memcpy(m_ram, rhs.m_ram, sizeof(m_ram)); } -inline ALERAM& ALERAM::operator=(const ALERAM &rhs) { +inline RLERAM& RLERAM::operator=(const RLERAM &rhs) { // Copy data over // memcpy(m_ram, rhs.m_ram, sizeof(m_ram)); m_ram = rhs.m_ram; return *this; } -inline bool ALERAM::equals(const ALERAM &rhs) const { +inline bool RLERAM::equals(const RLERAM &rhs) const { return (m_ram == rhs.m_ram); } // Byte accessors -byte_t ALERAM::get(unsigned int x) const { +byte_t RLERAM::get(unsigned int x) const { // Wrap RAM around the first 128 bytes return m_ram[x & 0x7F]; // return m_ram.at(x); } -//inline byte_t* ALERAM::byte(unsigned int x) { +//inline byte_t* RLERAM::byte(unsigned int x) { // return &m_ram[x & 0x7F]; //} -} // ale namespace +} // rle namespace diff --git a/src/environment/ale_ram.hpp b/src/environment/rle_ram.hpp similarity index 73% rename from src/environment/ale_ram.hpp rename to src/environment/rle_ram.hpp index 1be33c8..69b661f 100644 --- a/src/environment/ale_ram.hpp +++ b/src/environment/rle_ram.hpp @@ -8,15 +8,15 @@ * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team * * ***************************************************************************** - * ale_ram.hpp + * rle_ram.hpp * * A class that encapsulates the Atari 2600 RAM. Code is provided inline for * efficiency reasonss. * **************************************************************************** */ -#ifndef __ALE_RAM_HPP__ -#define __ALE_RAM_HPP__ +#ifndef __RLE_RAM_HPP__ +#define __RLE_RAM_HPP__ #include @@ -25,56 +25,56 @@ //#define RAM_SIZE (128) // ///** A simple wrapper around the Atari RAM. */ -//class ALERAM { +//class RLERAM { // public: -// ALERAM(); -// ALERAM(const ALERAM &rhs); +// RLERAM(); +// RLERAM(const RLERAM &rhs); // -// ALERAM& operator=(const ALERAM &rhs); +// RLERAM& operator=(const RLERAM &rhs); // // /** Byte accessors */ // byte_t get(unsigned int x) const; // byte_t *byte(unsigned int x); // -// /** Returns the whole array (equivalent to byte(0)). */ +// /** Returns the whole array (equivrlent to byte(0)). */ // byte_t *array() const { return (byte_t*)(m_ram); } // // size_t size() const { return sizeof(m_ram); } // /** Returns whether two copies of the RAM are equal */ -// bool equals(const ALERAM &rhs) const; +// bool equals(const RLERAM &rhs) const; // // protected: // byte_t m_ram[RAM_SIZE]; //}; // -//inline ALERAM::ALERAM() { +//inline RLERAM::RLERAM() { //} // -//inline ALERAM::ALERAM(const ALERAM &rhs) { +//inline RLERAM::RLERAM(const RLERAM &rhs) { // // Copy data over // memcpy(m_ram, rhs.m_ram, sizeof(m_ram)); //} // -//inline ALERAM& ALERAM::operator=(const ALERAM &rhs) { +//inline RLERAM& RLERAM::operator=(const RLERAM &rhs) { // // Copy data over // memcpy(m_ram, rhs.m_ram, sizeof(m_ram)); // // return *this; //} // -//inline bool ALERAM::equals(const ALERAM &rhs) const { +//inline bool RLERAM::equals(const RLERAM &rhs) const { // return (memcmp(m_ram, rhs.m_ram, size()) == 0); //} // //// Byte accessors -//inline byte_t ALERAM::get(unsigned int x) const { +//inline byte_t RLERAM::get(unsigned int x) const { // // Wrap RAM around the first 128 bytes // return m_ram[x & 0x7F]; //} // -//inline byte_t* ALERAM::byte(unsigned int x) { +//inline byte_t* RLERAM::byte(unsigned int x) { // return &m_ram[x & 0x7F]; //} -#endif // __ALE_RAM_HPP__ +#endif // __RLE_RAM_HPP__ diff --git a/src/environment/ale_screen.cpp b/src/environment/rle_screen.cpp similarity index 83% rename from src/environment/ale_screen.cpp rename to src/environment/rle_screen.cpp index 17f6158..268a5fa 100644 --- a/src/environment/ale_screen.cpp +++ b/src/environment/rle_screen.cpp @@ -9,21 +9,21 @@ * * ******************************************************************************/ -#include "../ale_interface.hpp" +#include "../rle_interface.hpp" #include "retro_environment.hpp" -namespace ale { +namespace rle { -ALEScreen::ALEScreen(int h, int w):m_rows(h), m_columns(w), m_pixels(m_rows * m_columns){ +RLEScreen::RLEScreen(int h, int w):m_rows(h), m_columns(w), m_pixels(m_rows * m_columns){ m_pixelFormat = new pixelFormat(); } -ALEScreen::~ALEScreen(){ +RLEScreen::~RLEScreen(){ delete m_pixelFormat; } -ALEScreen::ALEScreen(const ALEScreen &rhs): m_rows(rhs.m_rows), m_columns(rhs.m_columns), m_pixels(rhs.m_pixels){ +RLEScreen::RLEScreen(const RLEScreen &rhs): m_rows(rhs.m_rows), m_columns(rhs.m_columns), m_pixels(rhs.m_pixels){ m_pixelFormat = new pixelFormat(); m_pixelFormat->Bpp = rhs.m_pixelFormat->Bpp ; @@ -38,7 +38,7 @@ ALEScreen::ALEScreen(const ALEScreen &rhs): m_rows(rhs.m_rows), m_columns(rhs.m_ } -ALEScreen& ALEScreen::operator=(const ALEScreen &rhs) { +RLEScreen& RLEScreen::operator=(const RLEScreen &rhs) { @@ -58,17 +58,17 @@ ALEScreen& ALEScreen::operator=(const ALEScreen &rhs) { return *this; } -bool ALEScreen::equals(const ALEScreen &rhs) const { +bool RLEScreen::equals(const RLEScreen &rhs) const { return (m_rows == rhs.m_rows && m_columns == rhs.m_columns && (memcmp(&m_pixels[0], &rhs.m_pixels[0], arraySize()) == 0) ); } -int ALEScreen::getBpp()const{ +int RLEScreen::getBpp()const{ return m_pixelFormat->Bpp; } -pixel_t ALEScreen::getRGBPixel(const uint32_t &pixel)const{ +pixel_t RLEScreen::getRGBPixel(const uint32_t &pixel)const{ struct pixelFormat* m = m_pixelFormat; uint32_t red = (pixel & m->rmask) >> m->rShift; @@ -83,7 +83,7 @@ pixel_t ALEScreen::getRGBPixel(const uint32_t &pixel)const{ } -void ALEScreen::getRGB(const uint32_t &pixel, uint8_t &red, uint8_t &green, uint8_t &blue)const{ +void RLEScreen::getRGB(const uint32_t &pixel, uint8_t &red, uint8_t &green, uint8_t &blue)const{ struct pixelFormat* m = m_pixelFormat; red = (pixel & m->rmask) >> m->rShift; @@ -96,22 +96,22 @@ void ALEScreen::getRGB(const uint32_t &pixel, uint8_t &red, uint8_t &green, uint } // pixel accessors, (row, column)-ordered -inline pixel_t ALEScreen::get(int r, int c) const { +inline pixel_t RLEScreen::get(int r, int c) const { // Perform some bounds-checking assert (r >= 0 && r < m_rows && c >= 0 && c < m_columns); return m_pixels[r * m_columns + c]; } -inline pixel_t* ALEScreen::pixel(int r, int c) { +inline pixel_t* RLEScreen::pixel(int r, int c) { // Perform some bounds-checking assert (r >= 0 && r < m_rows && c >= 0 && c < m_columns); return &m_pixels[r * m_columns + c]; } // Access a whole row -inline pixel_t* ALEScreen::getRow(int r) const { +inline pixel_t* RLEScreen::getRow(int r) const { assert (r >= 0 && r < m_rows); return const_cast(&m_pixels[r * m_columns]); } -} // namespace ale +} // namespace rle diff --git a/src/environment/ale_screen.hpp b/src/environment/rle_screen.hpp similarity index 80% rename from src/environment/ale_screen.hpp rename to src/environment/rle_screen.hpp index a1e3a2b..4af7ce3 100644 --- a/src/environment/ale_screen.hpp +++ b/src/environment/rle_screen.hpp @@ -8,15 +8,15 @@ * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team * * ***************************************************************************** - * ale_screen.hpp + * rle_screen.hpp * * A class that encapsulates an Atari 2600 screen. Code is provided inline for * efficiency reasonss. * **************************************************************************** */ -#ifndef __ALE_SCREEN_HPP__ -#define __ALE_SCREEN_HPP__ +#ifndef __RLE_SCREEN_HPP__ +#define __RLE_SCREEN_HPP__ #include #include @@ -28,12 +28,12 @@ //typedef unsigned char pixel_t; // ///** A simple wrapper around an Atari screen. */ -//class ALEScreen { +//class RLEScreen { // public: -// ALEScreen(int h, int w); -// ALEScreen(const ALEScreen &rhs); +// RLEScreen(int h, int w); +// RLEScreen(const RLEScreen &rhs); // -// ALEScreen& operator=(const ALEScreen &rhs); +// RLEScreen& operator=(const RLEScreen &rhs); // // /** pixel accessors, (row, column)-ordered */ // pixel_t get(int r, int c) const; @@ -53,7 +53,7 @@ // size_t arraySize() const { return m_rows * m_columns * sizeof(pixel_t); } // // /** Returns whether two screens are equal */ -// bool equals(const ALEScreen &rhs) const; +// bool equals(const RLEScreen &rhs) const; // // protected: // int m_rows; @@ -62,21 +62,21 @@ // std::vector m_pixels; //}; -//inline ALEScreen::ALEScreen(int h, int w): +//inline RLEScreen::RLEScreen(int h, int w): // m_rows(h), // m_columns(w), // // Create a pixel array of the requisite size // m_pixels(m_rows * m_columns) { //} // -//inline ALEScreen::ALEScreen(const ALEScreen &rhs): +//inline RLEScreen::RLEScreen(const RLEScreen &rhs): // m_rows(rhs.m_rows), // m_columns(rhs.m_columns), // m_pixels(rhs.m_pixels) { // //} // -//inline ALEScreen& ALEScreen::operator=(const ALEScreen &rhs) { +//inline RLEScreen& RLEScreen::operator=(const RLEScreen &rhs) { // // m_rows = rhs.m_rows; // m_columns = rhs.m_columns; @@ -88,31 +88,31 @@ // return *this; //} // -//inline bool ALEScreen::equals(const ALEScreen &rhs) const { +//inline bool RLEScreen::equals(const RLEScreen &rhs) const { // return (m_rows == rhs.m_rows && // m_columns == rhs.m_columns && // (memcmp(&m_pixels[0], &rhs.m_pixels[0], arraySize()) == 0) ); //} // //// pixel accessors, (row, column)-ordered -//inline pixel_t ALEScreen::get(int r, int c) const { +//inline pixel_t RLEScreen::get(int r, int c) const { // // Perform some bounds-checking // assert (r >= 0 && r < m_rows && c >= 0 && c < m_columns); // return m_pixels[r * m_columns + c]; //} // -//inline pixel_t* ALEScreen::pixel(int r, int c) { +//inline pixel_t* RLEScreen::pixel(int r, int c) { // // Perform some bounds-checking // assert (r >= 0 && r < m_rows && c >= 0 && c < m_columns); // return &m_pixels[r * m_columns + c]; //} // //// Access a whole row -//inline pixel_t* ALEScreen::getRow(int r) const { +//inline pixel_t* RLEScreen::getRow(int r) const { // assert (r >= 0 && r < m_rows); // return const_cast(&m_pixels[r * m_columns]); //} -#endif // __ALE_SCREEN_HPP__ +#endif // __RLE_SCREEN_HPP__ diff --git a/src/environment/ale_state.cpp b/src/environment/rle_state.cpp similarity index 78% rename from src/environment/ale_state.cpp rename to src/environment/rle_state.cpp index 9e63e60..8119ffa 100644 --- a/src/environment/ale_state.cpp +++ b/src/environment/rle_state.cpp @@ -9,28 +9,28 @@ * * ***************************************************************************** */ -#include "ale_state.hpp" +#include "rle_state.hpp" #include "../common/Constants.h" #include "Serializer.hxx" #include "Deserializer.hxx" using namespace std; -using namespace ale; +using namespace rle; #include /** Default constructor - loads settings from system */ -ALEState::ALEState(): +RLEState::RLEState(): m_frame_number(0), m_episode_frame_number(0) { } -ALEState::ALEState(const ALEState &rhs, std::string serialized): +RLEState::RLEState(const RLEState &rhs, std::string serialized): m_frame_number(rhs.m_frame_number), m_episode_frame_number(rhs.m_episode_frame_number), m_serialized_state(serialized) { } -ALEState::ALEState(const std::string &serialized) { +RLEState::RLEState(const std::string &serialized) { Deserializer des(serialized); this->m_frame_number = des.getInt(); this->m_episode_frame_number = des.getInt(); @@ -39,9 +39,9 @@ ALEState::ALEState(const std::string &serialized) { /** Restores ALE to the given previously saved state. */ -void ALEState::load( - AleSystem* alesystem, - RomSettings* settings, const ALEState &rhs, +void RLEState::load( + RleSystem* rlesystem, + RomSettings* settings, const RLEState &rhs, bool load_system) { assert(rhs.m_serialized_state.length() > 0); @@ -50,21 +50,21 @@ void ALEState::load( // A primitive check to produce a meaningful error if this state does not contain osystem info. if (deser.getBool() != load_system) - throw new std::runtime_error("Attempting to load an ALEState which does not contain " + throw new std::runtime_error("Attempting to load an RLEState which does not contain " "system information."); - alesystem->getRetroAgent().deserialize(deser); + rlesystem->getRetroAgent().deserialize(deser); // If we have osystem data, load it as well if (load_system) - alesystem->loadState(deser); + rlesystem->loadState(deser); settings->loadState(deser); m_episode_frame_number = rhs.m_episode_frame_number; m_frame_number = rhs.m_frame_number; } -ALEState ALEState::save( - AleSystem* alesystem, +RLEState RLEState::save( + RleSystem* rlesystem, RomSettings* settings, bool save_system) { // Use the emulator's built-in serialization to save the state @@ -73,25 +73,25 @@ ALEState ALEState::save( // We use 'save_system' as a check at load time. ser.putBool(save_system); - alesystem->getRetroAgent().serialize(ser); + rlesystem->getRetroAgent().serialize(ser); if (save_system) - alesystem->saveState(ser); + rlesystem->saveState(ser); settings->saveState(ser); // Now make a copy of this state, also storing the emulator serialization - return ALEState(*this, ser.get_str()); + return RLEState(*this, ser.get_str()); } -void ALEState::incrementFrame(int steps /* = 1 */) { +void RLEState::incrementFrame(int steps /* = 1 */) { m_frame_number += steps; m_episode_frame_number += steps; } -void ALEState::resetEpisodeFrameNumber() { +void RLEState::resetEpisodeFrameNumber() { m_episode_frame_number = 0; } -std::string ALEState::serialize() { +std::string RLEState::serialize() { Serializer ser; // // ser.putInt(this->m_left_paddle); @@ -103,7 +103,7 @@ std::string ALEState::serialize() { return ser.get_str(); } -bool ALEState::equals(ALEState &rhs) { +bool RLEState::equals(RLEState &rhs) { return (rhs.m_serialized_state == this->m_serialized_state && // rhs.m_left_paddle == this->m_left_paddle && // rhs.m_right_paddle == this->m_right_paddle && diff --git a/src/environment/ale_state.hpp b/src/environment/rle_state.hpp similarity index 83% rename from src/environment/ale_state.hpp rename to src/environment/rle_state.hpp index 0ab0d24..0f131e2 100644 --- a/src/environment/ale_state.hpp +++ b/src/environment/rle_state.hpp @@ -8,38 +8,38 @@ * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team * * ***************************************************************************** - * ale_state.hpp + * rle_state.hpp * * A class that stores a copy of the current ALE state. We use one to keep track * of paddle resistance and in search trees. * **************************************************************************** */ -#ifndef __ALE_STATE_HPP__ -#define __ALE_STATE_HPP__ +#ifndef __RLE_STATE_HPP__ +#define __RLE_STATE_HPP__ -#include "AleSystem.hxx" +#include "RleSystem.hxx" #include #include "../games/RomSettings.hpp" #include "../common/Log.hpp" -namespace ale { +namespace rle { -class ALEState { +class RLEState { public: - ALEState(); + RLEState(); // Makes a copy of this state, also storing emulator information provided as a string - ALEState(const ALEState &rhs, std::string serialized); + RLEState(const RLEState &rhs, std::string serialized); - // Restores a serialized ALEState - ALEState(const std::string &serialized); + // Restores a serialized RLEState + RLEState(const std::string &serialized); /** Resets the system to its start state. numResetSteps 'RESET' actions are taken after the * start. */ void reset(int numResetSteps = 1); /** Returns true if the two states contain the same saved information */ - bool equals(ALEState &state); + bool equals(RLEState &state); void incrementFrame(int steps = 1); @@ -62,14 +62,14 @@ class ALEState { /** Restores the environment to a previously saved state. If load_system == true, we also restore system-specific information (such as the RNG state). */ void load( - AleSystem* alesystem, - RomSettings* settings, const ALEState &rhs, + RleSystem* rlesystem, + RomSettings* settings, const RLEState &rhs, bool load_system); /** Returns a "copy" of the current state, including the information necessary to restore * the emulator. If save_system == true, this includes the RNG state. */ - ALEState save( - AleSystem* alesystem, + RLEState save( + RleSystem* rlesystem, RomSettings* settings, bool save_system); private: @@ -81,8 +81,8 @@ class ALEState { }; -} // namespace ale +} // namespace rle -#endif // __ALE_STATE_HPP__ +#endif // __RLE_STATE_HPP__ diff --git a/src/games/AtariSettings.cpp b/src/games/AtariSettings.cpp index e5b9962..fa35afd 100644 --- a/src/games/AtariSettings.cpp +++ b/src/games/AtariSettings.cpp @@ -18,7 +18,7 @@ #include "AtariSettings.hpp" #include "Constants.h" -using namespace ale; +using namespace rle; AtariSettings::AtariSettings(){ AllActionsVector = { JOYPAD_NOOP, @@ -42,6 +42,6 @@ AtariSettings::AtariSettings(){ }; } -int AtariSettings::readRam(const AleSystem* system, int offset){ +int AtariSettings::readRam(const RleSystem* system, int offset){ RomSettings::readRam(system, offset & 0x7F ); } diff --git a/src/games/AtariSettings.hpp b/src/games/AtariSettings.hpp index 97899d5..d568930 100644 --- a/src/games/AtariSettings.hpp +++ b/src/games/AtariSettings.hpp @@ -35,7 +35,7 @@ #include "RomSettings.hpp" -namespace ale { +namespace rle { // rom support interface for Atari struct AtariSettings : public RomSettings{ @@ -63,12 +63,12 @@ struct AtariSettings : public RomSettings{ virtual bool isMinimal(const Action &a) const = 0; // process the latest information from ALE - virtual void step(const AleSystem &system) = 0; + virtual void step(const RleSystem &system) = 0; - int readRam(const AleSystem* system, int offset); + int readRam(const RleSystem* system, int offset); }; -} // namespace ale +} // namespace rle #endif // __ATARI_SETTINGS_HPP__ diff --git a/src/games/RomSettings.cpp b/src/games/RomSettings.cpp index f4d9b3a..0d2cce3 100644 --- a/src/games/RomSettings.cpp +++ b/src/games/RomSettings.cpp @@ -16,10 +16,10 @@ * ***************************************************************************** */ #include "RomSettings.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" #include "../libretro.h" -using namespace ale; +using namespace rle; bool RomSettings::isLegal(const Action& a) const { return true; @@ -51,20 +51,20 @@ ActionVect RomSettings::getAllActions() { } -int RomSettings::readRam(const AleSystem* system, int offset) { +int RomSettings::readRam(const RleSystem* system, int offset) { // return system->getRetroAgent().readRam(RETRO_MEMORY_SYSTEM_RAM, (offset & 0x7F) ); return system->getRetroAgent().readRam(RETRO_MEMORY_SYSTEM_RAM, (offset) ); } -void RomSettings::writeRam(const AleSystem* system, int offset, uint8_t data) { +void RomSettings::writeRam(const RleSystem* system, int offset, uint8_t data) { return system->getRetroAgent().writeRam(RETRO_MEMORY_SYSTEM_RAM, offset, data ); } /* extracts a decimal value from a byte */ -int RomSettings::getDecimalScore(int index, const AleSystem* system) { +int RomSettings::getDecimalScore(int index, const RleSystem* system) { int score = 0; int digits_val = readRam(system, index); @@ -77,7 +77,7 @@ int RomSettings::getDecimalScore(int index, const AleSystem* system) { } /* extracts a decimal value from 2 bytes */ -int RomSettings::getDecimalScore(int lower_index, int higher_index, const AleSystem* system) { +int RomSettings::getDecimalScore(int lower_index, int higher_index, const RleSystem* system) { int score = 0; int lower_digits_val = readRam(system, lower_index); @@ -98,7 +98,7 @@ int RomSettings::getDecimalScore(int lower_index, int higher_index, const AleSys /* extracts a decimal value from 3 bytes */ -int RomSettings::getDecimalScore(int lower_index, int middle_index, int higher_index, const AleSystem* system) { +int RomSettings::getDecimalScore(int lower_index, int middle_index, int higher_index, const RleSystem* system) { int score = getDecimalScore(lower_index, middle_index, system); int higher_digits_val = readRam(system, higher_index); @@ -110,7 +110,7 @@ int RomSettings::getDecimalScore(int lower_index, int middle_index, int higher_i } /* extracts a decimal value from a byte */ -int RomSettings::getDecimalScoreWord(int index, const AleSystem* system) { +int RomSettings::getDecimalScoreWord(int index, const RleSystem* system) { int score = 0; int digits_val = readRam(system, index); @@ -119,7 +119,7 @@ int RomSettings::getDecimalScoreWord(int index, const AleSystem* system) { } /* extracts a decimal value from 2 words */ -int RomSettings::getDecimalScoreWord(int lower_index, int higher_index, const AleSystem* system) { +int RomSettings::getDecimalScoreWord(int lower_index, int higher_index, const RleSystem* system) { int score = 0; int lower_digits_val = readRam(system, lower_index); int higher_digits_val = readRam(system, higher_index); @@ -129,7 +129,7 @@ int RomSettings::getDecimalScoreWord(int lower_index, int higher_index, const Al } /* extracts a decimal value from 3 words */ -int RomSettings::getDecimalScoreWord(int lower_index, int middle_index, int higher_index, const AleSystem* system) { +int RomSettings::getDecimalScoreWord(int lower_index, int middle_index, int higher_index, const RleSystem* system) { int score = 0; int lower_digits_val = readRam(system, lower_index); int middle_digits_val = readRam(system, middle_index); @@ -141,7 +141,7 @@ int RomSettings::getDecimalScoreWord(int lower_index, int middle_index, int high } /* extracts a decimal value from words specified in vector */ -int RomSettings::getDecimalScoreWords(std::vector indexes, const AleSystem* system) { +int RomSettings::getDecimalScoreWords(std::vector indexes, const RleSystem* system) { int score = 0; int multiplier = 1; for(auto ind : indexes){ diff --git a/src/games/RomSettings.hpp b/src/games/RomSettings.hpp index 53f1da2..00bf23e 100644 --- a/src/games/RomSettings.hpp +++ b/src/games/RomSettings.hpp @@ -37,9 +37,9 @@ #include "Serializer.hxx" #include "Deserializer.hxx" -namespace ale { +namespace rle { -class AleSystem; +class RleSystem; // rom support interface @@ -53,22 +53,22 @@ struct RomSettings { virtual bool isTerminal() const = 0; // get the most recently observed reward - virtual ale::reward_t getReward() const = 0; + virtual rle::reward_t getReward() const = 0; // get the most recently observed reward for player 2 - virtual ale::reward_t getRewardPlayer2() const{return 0;}; + virtual rle::reward_t getRewardPlayer2() const{return 0;}; // the rom-name virtual const char *rom() const = 0; // create a new instance of the rom - virtual ale::RomSettings *clone() const = 0; + virtual rle::RomSettings *clone() const = 0; // is an action part of the minimal set? - virtual bool isMinimal(const ale::Action &a) const = 0; + virtual bool isMinimal(const rle::Action &a) const = 0; // process the latest information from ALE - virtual void step(const ale::AleSystem &system) = 0; + virtual void step(const rle::RleSystem &system) = 0; // saves the state of the rom settings virtual void saveState( Serializer & ser ) = 0; @@ -77,7 +77,7 @@ struct RomSettings { virtual void loadState( Deserializer & ser ) = 0; // is an action legal (default: yes) - virtual bool isLegal(const ale::Action &a) const; + virtual bool isLegal(const rle::Action &a) const; // Remaining lives. virtual const int lives() { return isTerminal() ? 0 : 1; } @@ -94,33 +94,33 @@ struct RomSettings { virtual ActionVect getStartingActions(); // Returns a list of actions that are required to start the game. - // Some games require the AleSystem for game-specific settings - virtual ActionVect getStartingActions(const AleSystem& system){ return getStartingActions();} + // Some games require the RleSystem for game-specific settings + virtual ActionVect getStartingActions(const RleSystem& system){ return getStartingActions();} // Optionally perform starting operations such as modifying the game's RAM - virtual void startingOperations(AleSystem& system){}; + virtual void startingOperations(RleSystem& system){}; // below functions used to belong to RomUtils // reads a byte at a memory location - virtual int readRam(const AleSystem* system, int offset); + virtual int readRam(const RleSystem* system, int offset); // write a byte at a memory location - virtual void writeRam(const AleSystem* system, int offset, uint8_t data); + virtual void writeRam(const RleSystem* system, int offset, uint8_t data); // extracts a decimal value from 1, 2, and 3 bytes respectively - int getDecimalScore(int idx, const AleSystem* system); - int getDecimalScore(int lo, int hi, const AleSystem* system); - int getDecimalScore(int lo, int mid, int hi, const AleSystem* system); - int getDecimalScoreWord(int idx, const AleSystem* system); - int getDecimalScoreWord(int lo, int hi, const AleSystem* system); - int getDecimalScoreWord(int lo, int mid, int hi, const AleSystem* system); - int getDecimalScoreWords(std::vector indexes, const AleSystem* system); + int getDecimalScore(int idx, const RleSystem* system); + int getDecimalScore(int lo, int hi, const RleSystem* system); + int getDecimalScore(int lo, int mid, int hi, const RleSystem* system); + int getDecimalScoreWord(int idx, const RleSystem* system); + int getDecimalScoreWord(int lo, int hi, const RleSystem* system); + int getDecimalScoreWord(int lo, int mid, int hi, const RleSystem* system); + int getDecimalScoreWords(std::vector indexes, const RleSystem* system); protected: ActionVect AllActionsVector; }; -} // namespace ale +} // namespace rle #endif // __ROMSETTINGS_HPP__ diff --git a/src/games/RomUtils.cpp b/src/games/RomUtils.cpp index 72de469..581ab4b 100644 --- a/src/games/RomUtils.cpp +++ b/src/games/RomUtils.cpp @@ -16,15 +16,15 @@ // */ //#include "RomUtils.hpp" // -//#include "AleSystem.hxx" +//#include "RleSystem.hxx" // -//namespace ale { +//namespace rle { // ///* reads a byte at a memory location between 0 and 128 */ // //#include "../libretro.h" // -//int readRam(const AleSystem* system, int offset) { +//int readRam(const RleSystem* system, int offset) { // //// return system->getRetroAgent().readRam(RETRO_MEMORY_SYSTEM_RAM, (offset & 0x7F) + 0x80); // return system->getRetroAgent().readRam(RETRO_MEMORY_SYSTEM_RAM, (offset & 0x7F) ); @@ -33,7 +33,7 @@ // // ///* extracts a decimal value from a byte */ -//int getDecimalScore(int index, const AleSystem* system) { +//int getDecimalScore(int index, const RleSystem* system) { // // int score = 0; // int digits_val = readRam(system, index); @@ -46,7 +46,7 @@ //} // ///* extracts a decimal value from 2 bytes */ -//int getDecimalScore(int lower_index, int higher_index, const AleSystem* system) { +//int getDecimalScore(int lower_index, int higher_index, const RleSystem* system) { // // int score = 0; // int lower_digits_val = readRam(system, lower_index); @@ -67,7 +67,7 @@ // // ///* extracts a decimal value from 3 bytes */ -//int getDecimalScore(int lower_index, int middle_index, int higher_index, const AleSystem* system) { +//int getDecimalScore(int lower_index, int middle_index, int higher_index, const RleSystem* system) { // // int score = getDecimalScore(lower_index, middle_index, system); // int higher_digits_val = readRam(system, higher_index); @@ -78,4 +78,4 @@ // return score; //} // -//} // namespace ale +//} // namespace rle diff --git a/src/games/RomUtils.hpp b/src/games/RomUtils.hpp index 495bd94..5bdb578 100644 --- a/src/games/RomUtils.hpp +++ b/src/games/RomUtils.hpp @@ -17,19 +17,19 @@ //#ifndef __ROMUTILS_HPP__ //#define __ROMUTILS_HPP__ // -//namespace ale { +//namespace rle { // -//class AleSystem; +//class RleSystem; // //// reads a byte at a memory location between 0 and 1023 -//extern int readRam(const AleSystem* system, int offset); +//extern int readRam(const RleSystem* system, int offset); // //// extracts a decimal value from 1, 2, and 3 bytes respectively -//extern int getDecimalScore(int idx, const AleSystem* system); -//extern int getDecimalScore(int lo, int hi, const AleSystem* system); -//extern int getDecimalScore(int lo, int mid, int hi, const AleSystem* system); +//extern int getDecimalScore(int idx, const RleSystem* system); +//extern int getDecimalScore(int lo, int hi, const RleSystem* system); +//extern int getDecimalScore(int lo, int mid, int hi, const RleSystem* system); // -//} // namespace ale +//} // namespace rle // //#endif // __ROMUTILS_HPP__ // diff --git a/src/games/Roms.cpp b/src/games/Roms.cpp index 10c772a..8c20585 100644 --- a/src/games/Roms.cpp +++ b/src/games/Roms.cpp @@ -18,7 +18,6 @@ /// snes games #include "supported/AtariCollection.hpp" #include "supported/FinalFight.hpp" -#include "supported/FinalFight_WithRight.hpp" #include "supported/FZero.hpp" #include "supported/FZeroNoSpeed.hpp" #include "supported/GradiusIII.hpp" @@ -28,8 +27,6 @@ #include "supported/SuperMarioAllStars.hpp" #include "supported/SuperMarioAllStarsNoRight.hpp" #include "supported/TetrisAndDrMario.hpp" -#include "supported/TetrisAndDrMarioLines.hpp" -#include "supported/TetrisAndDrMarioNumBlocks.hpp" #include "supported/Boxing.hpp" #include "supported/Wolfenstein.hpp" @@ -84,7 +81,7 @@ //#include "supported/YarsRevenge.hpp" //#include "supported/Zaxxon.hpp" -using namespace ale; +using namespace rle; /* list of supported games */ static const RomSettings *roms[] = { @@ -155,7 +152,6 @@ static const RomSettings *roms[] = { // SNES games new AtariCollectionSettings(), new FinalFightSettings(), - new FinalFightWithRightSettings(), new FZeroSettings(), new FZeroNoSpeedSettings(), new GradiusIIISettings(), @@ -166,14 +162,12 @@ static const RomSettings *roms[] = { new SuperMarioAllStarsNoRightSettings(), new SuperMarioWorldSettings(), new TetrisAndDrMarioSettings(), - new TetrisAndDrMarioLinesSettings(), - new TetrisAndDrMarioNumBlocksSettings(), new WolfensteinSettings(), }; /* looks for the RL wrapper corresponding to a particular rom title */ -RomSettings *ale::buildRomRLWrapper(const std::string &rom, bool twoPlayers) { +RomSettings *rle::buildRomRLWrapper(const std::string &rom, bool twoPlayers) { size_t slash_ind = rom.find_last_of("/\\"); std::string rom_str = rom.substr(slash_ind + 1); diff --git a/src/games/Roms.hpp b/src/games/Roms.hpp index 0b9457c..d36f9e5 100644 --- a/src/games/Roms.hpp +++ b/src/games/Roms.hpp @@ -14,7 +14,7 @@ #include -namespace ale { +namespace rle { struct RomSettings; @@ -22,7 +22,7 @@ struct RomSettings; // looks for the RL wrapper corresponding to a particular rom title extern RomSettings *buildRomRLWrapper(const std::string &rom, bool twoPlayers = false); -} // namespace ale +} // namespace rle #endif // __ROMS_HPP__ diff --git a/src/games/SnesSettings.cpp b/src/games/SnesSettings.cpp index b73b809..39bb5ec 100644 --- a/src/games/SnesSettings.cpp +++ b/src/games/SnesSettings.cpp @@ -18,7 +18,7 @@ #include "SnesSettings.hpp" #include "Constants.h" -using namespace ale; +using namespace rle; SnesSettings::SnesSettings(){ diff --git a/src/games/SnesSettings.hpp b/src/games/SnesSettings.hpp index 2709042..1c866bd 100644 --- a/src/games/SnesSettings.hpp +++ b/src/games/SnesSettings.hpp @@ -42,7 +42,7 @@ #define INSERT_ACTION_SINGLE_A(action) INSERT_ACTION_SINGLE(action, A) #define INSERT_NOPS(repeat) INSERT_ACTIONS(JOYPAD_NOOP, A, repeat) -namespace ale { +namespace rle { // rom support interface for snes struct SnesSettings : public RomSettings{ @@ -69,11 +69,11 @@ struct SnesSettings : public RomSettings{ virtual bool isMinimal(const Action &a) const = 0; // process the latest information from ALE - virtual void step(const AleSystem &system) = 0; + virtual void step(const RleSystem &system) = 0; }; -} // namespace ale +} // namespace rle #endif // __SNES_SETTINGS_HPP__ diff --git a/src/games/supported/AtariCollection.cpp b/src/games/supported/AtariCollection.cpp index 495c764..5de2acb 100644 --- a/src/games/supported/AtariCollection.cpp +++ b/src/games/supported/AtariCollection.cpp @@ -15,7 +15,7 @@ #include "../RomUtils.hpp" #include "AtariCollection.hpp" -using namespace ale; +using namespace rle; AtariCollectionSettings::AtariCollectionSettings() { @@ -32,9 +32,7 @@ RomSettings* AtariCollectionSettings::clone() const { return rval; } - -/* process the latest information from ALE */ -void AtariCollectionSettings::step(const AleSystem& system) { +void AtariCollectionSettings::step(const RleSystem& system) { // update the reward reward_t score = getDecimalScore(0x52, 0x53, &system); score *= 10; diff --git a/src/games/supported/AtariCollection.hpp b/src/games/supported/AtariCollection.hpp index 5d13839..0828cc4 100644 --- a/src/games/supported/AtariCollection.hpp +++ b/src/games/supported/AtariCollection.hpp @@ -31,7 +31,7 @@ #include "../SnesSettings.hpp" -namespace ale { +namespace rle { struct AtariCollectionSettings : public SnesSettings { @@ -58,7 +58,7 @@ struct AtariCollectionSettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -78,6 +78,6 @@ struct AtariCollectionSettings : public SnesSettings { int m_lives; }; -} // namespace ale +} // namespace rle #endif // __ATARI_COLLECTION_SETTINGS_HPP__ diff --git a/src/games/supported/Boxing.cpp b/src/games/supported/Boxing.cpp index 5757d5a..382545c 100644 --- a/src/games/supported/Boxing.cpp +++ b/src/games/supported/Boxing.cpp @@ -14,7 +14,7 @@ #include "../RomUtils.hpp" #include -using namespace ale; +using namespace rle; BoxingSettings::BoxingSettings() { @@ -32,7 +32,7 @@ RomSettings* BoxingSettings::clone() const { /* process the latest information from ALE */ -void BoxingSettings::step(const AleSystem& system) { +void BoxingSettings::step(const RleSystem& system) { // update the reward int my_score = getDecimalScore(0x92, &system); diff --git a/src/games/supported/Boxing.hpp b/src/games/supported/Boxing.hpp index 3978197..5a2ef7a 100644 --- a/src/games/supported/Boxing.hpp +++ b/src/games/supported/Boxing.hpp @@ -29,7 +29,7 @@ #include "../AtariSettings.hpp" -namespace ale { +namespace rle { /* RL wrapper for Boxing settings */ struct BoxingSettings : public AtariSettings { @@ -57,7 +57,7 @@ struct BoxingSettings : public AtariSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -76,7 +76,7 @@ struct BoxingSettings : public AtariSettings { reward_t m_score; }; -} // namespace ale +} // namespace rle #endif // __BOXING_HPP__ diff --git a/src/games/supported/Breakout.cpp b/src/games/supported/Breakout.cpp deleted file mode 100644 index 6933768..0000000 --- a/src/games/supported/Breakout.cpp +++ /dev/null @@ -1,122 +0,0 @@ -///* ***************************************************************************** -// * The lines 61, 101, 113 and 122 are 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 -// * -// * ***************************************************************************** -// */ -//#include "Breakout.hpp" -// -//#include "../RomUtils.hpp" -// -// -//BreakoutSettings::BreakoutSettings() { -// -// reset(); -//} -// -// -///* create a new instance of the rom */ -//RomSettings* BreakoutSettings::clone() const { -// -// RomSettings* rval = new BreakoutSettings(); -// *rval = *this; -// return rval; -//} -// -// -///* process the latest information from ALE */ -//void BreakoutSettings::step(const System& system) { -// -// // update the reward -// int x = readRam(&system, 77); -// int y = readRam(&system, 76); -// reward_t score = 1 * (x & 0x000F) + 10 * ((x & 0x00F0) >> 4) + 100 * (y & 0x000F); -// m_reward = score - m_score; -// m_score = score; -// -// // update terminal status -// int byte_val = readRam(&system, 57); -// if (!m_started && byte_val == 5) m_started = true; -// m_terminal = m_started && byte_val == 0; -// m_lives = byte_val; -//} -// -// -///* is end of game */ -//bool BreakoutSettings::isTerminal() const { -// -// return m_terminal; -//}; -// -// -///* get the most recently observed reward */ -//reward_t BreakoutSettings::getReward() const { -// -// return m_reward; -//} -// -// -///* is an action part of the minimal set? */ -//bool BreakoutSettings::isMinimal(const Action &a) const { -// -// switch (a) { -// case PLAYER_A_NOOP: -// case PLAYER_A_FIRE: -// case PLAYER_A_RIGHT: -// case PLAYER_A_LEFT: -// return true; -// default: -// return false; -// } -//} -// -// -///* reset the state of the game */ -//void BreakoutSettings::reset() { -// -// m_reward = 0; -// m_score = 0; -// m_lives = 5; -// m_terminal = false; -// m_started = false; -//} -// -// -///* saves the state of the rom settings */ -//void BreakoutSettings::saveState(Serializer & ser) { -// ser.putInt(m_reward); -// ser.putInt(m_score); -// ser.putBool(m_terminal); -// ser.putBool(m_started); -// ser.putInt(m_lives); -//} -// -//// loads the state of the rom settings -//void BreakoutSettings::loadState(Deserializer & ser) { -// m_reward = ser.getInt(); -// m_score = ser.getInt(); -// m_terminal = ser.getBool(); -// m_started = ser.getBool(); -// m_lives = ser.getInt(); -//} -// diff --git a/src/games/supported/Breakout.hpp b/src/games/supported/Breakout.hpp deleted file mode 100644 index 4425b6c..0000000 --- a/src/games/supported/Breakout.hpp +++ /dev/null @@ -1,80 +0,0 @@ -///* ***************************************************************************** -// * The lines 68 and 76 are 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 __BREAKOUT_HPP__ -//#define __BREAKOUT_HPP__ -// -//#include "../RomSettings.hpp" -// -// -///* RL wrapper for Breakout */ -//class BreakoutSettings : public RomSettings { -// -// public: -// -// BreakoutSettings(); -// -// // reset -// void reset(); -// -// // is end of game -// bool isTerminal() const; -// -// // get the most recently observed reward -// reward_t getReward() const; -// -// // the rom-name -// const char* rom() const { return "breakout"; } -// -// // create a new instance of the rom -// RomSettings* clone() const; -// -// // is an action part of the minimal set? -// bool isMinimal(const Action& a) const; -// -// // process the latest information from ALE -// void step(const System& system); -// -// // saves the state of the rom settings -// void saveState(Serializer & ser); -// -// // loads the state of the rom settings -// void loadState(Deserializer & ser); -// -// // remaining lives -// const int lives() { return isTerminal() ? 0 : m_lives; } -// -// private: -// -// bool m_terminal; -// bool m_started; -// reward_t m_reward; -// reward_t m_score; -// int m_lives; -//}; -// -//#endif // __BREAKOUT_HPP__ -// diff --git a/src/games/supported/FZero.cpp b/src/games/supported/FZero.cpp index bfb5653..358198d 100644 --- a/src/games/supported/FZero.cpp +++ b/src/games/supported/FZero.cpp @@ -13,10 +13,10 @@ #include #include "../RomUtils.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" #include "FZero.hpp" -using namespace ale; +using namespace rle; FZeroSettings::FZeroSettings() { @@ -59,7 +59,7 @@ RomSettings* FZeroSettings::clone() const { /* process the latest information from ALE */ -void FZeroSettings::step(const AleSystem& system) { +void FZeroSettings::step(const RleSystem& system) { // uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); // uint32_t time = 60 * readRam(&system, 0xAC) + readRam(&system, 0xAE); diff --git a/src/games/supported/FZero.hpp b/src/games/supported/FZero.hpp index a919a19..f9d2db4 100644 --- a/src/games/supported/FZero.hpp +++ b/src/games/supported/FZero.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { class FZeroSettings : public SnesSettings { @@ -59,7 +59,7 @@ class FZeroSettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -78,6 +78,6 @@ class FZeroSettings : public SnesSettings { reward_t m_score; }; -} // namespace ale +} // namespace rle #endif // __F_ZERO_SETTINGS_HPP__ diff --git a/src/games/supported/FZeroNoSpeed.cpp b/src/games/supported/FZeroNoSpeed.cpp index 22c73c8..268d334 100644 --- a/src/games/supported/FZeroNoSpeed.cpp +++ b/src/games/supported/FZeroNoSpeed.cpp @@ -13,10 +13,10 @@ #include #include "../RomUtils.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" #include "FZeroNoSpeed.hpp" -using namespace ale; +using namespace rle; FZeroNoSpeedSettings::FZeroNoSpeedSettings() { @@ -59,7 +59,7 @@ RomSettings* FZeroNoSpeedSettings::clone() const { /* process the latest information from ALE */ -void FZeroNoSpeedSettings::step(const AleSystem& system) { +void FZeroNoSpeedSettings::step(const RleSystem& system) { // uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); // uint32_t time = 60 * readRam(&system, 0xAC) + readRam(&system, 0xAE); diff --git a/src/games/supported/FZeroNoSpeed.hpp b/src/games/supported/FZeroNoSpeed.hpp index e98ee07..86519c0 100644 --- a/src/games/supported/FZeroNoSpeed.hpp +++ b/src/games/supported/FZeroNoSpeed.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { class FZeroNoSpeedSettings : public SnesSettings { @@ -59,7 +59,7 @@ class FZeroNoSpeedSettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -78,6 +78,6 @@ class FZeroNoSpeedSettings : public SnesSettings { reward_t m_score; }; -} // namespace ale +} // namespace rle #endif // __F_ZERO_NO_SPEED_SETTINGS_HPP__ diff --git a/src/games/supported/FinalFight.cpp b/src/games/supported/FinalFight.cpp index 9231023..cdde209 100644 --- a/src/games/supported/FinalFight.cpp +++ b/src/games/supported/FinalFight.cpp @@ -15,9 +15,9 @@ #include "../RomUtils.hpp" #include "FinalFight.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" -using namespace ale; +using namespace rle; FinalFightSettings::FinalFightSettings() { @@ -54,7 +54,7 @@ RomSettings* FinalFightSettings::clone() const { /* process the latest information from ALE */ -void FinalFightSettings::step(const AleSystem& system) { +void FinalFightSettings::step(const RleSystem& system) { // int time = getDecimalScoreWords({0xcbc, 0xcbd}, &system); diff --git a/src/games/supported/FinalFight.hpp b/src/games/supported/FinalFight.hpp index 74ec062..bce48ac 100644 --- a/src/games/supported/FinalFight.hpp +++ b/src/games/supported/FinalFight.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { struct FinalFightSettings : public SnesSettings { @@ -59,7 +59,7 @@ struct FinalFightSettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -79,6 +79,6 @@ struct FinalFightSettings : public SnesSettings { reward_t m_prev_lives; }; -} // namespace ale +} // namespace rle #endif // __FINAL_FIGHT_SETTINGS_HPP__ diff --git a/src/games/supported/FinalFight_WithRight.hpp b/src/games/supported/FinalFight_WithRight.hpp deleted file mode 100644 index 06fadd1..0000000 --- a/src/games/supported/FinalFight_WithRight.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/* ***************************************************************************** - * 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 __FINAL_FIGHT_WITH_RIGHT_SETTINGS_HPP__ -#define __FINAL_FIGHT_WITH_RIGHT_SETTINGS_HPP__ -/* RL wrapper for AtariCollection settings */ - -#include "../SnesSettings.hpp" -#include - -namespace ale { - -struct FinalFightWithRightSettings : public SnesSettings { - - public: - - FinalFightWithRightSettings(); - - // reset - void reset(); - - // is end of game - bool isTerminal() const; - - // get the most recently observed reward - reward_t getReward() const; - - // the rom-name - const char* rom() const { return "final_fight_with_right"; } - - // create a new instance of the rom - RomSettings* clone() const; - - // is an action part of the minimal set? - bool isMinimal(const Action& a) const; - - // process the latest information from ALE - void step(const AleSystem& 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: - std::unordered_set minimalActions; - bool m_terminal; - reward_t m_reward; - reward_t m_score; - reward_t m_prev_lives; - -}; - -} // namespace ale - -#endif // __FINAL_FIGHT_WITH_RIGHT_SETTINGS_HPP__ diff --git a/src/games/supported/FinalFight_withRight.cpp b/src/games/supported/FinalFight_withRight.cpp deleted file mode 100644 index 2b4ee06..0000000 --- a/src/games/supported/FinalFight_withRight.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* ***************************************************************************** - * 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 "FinalFight_WithRight.hpp" - -#include "AleSystem.hxx" - -using namespace ale; - - -FinalFightWithRightSettings::FinalFightWithRightSettings() { - reset(); - - minimalActions = { JOYPAD_NOOP, - JOYPAD_UP, - JOYPAD_DOWN, - JOYPAD_LEFT, - JOYPAD_RIGHT, - JOYPAD_UP | JOYPAD_RIGHT, - JOYPAD_UP | JOYPAD_LEFT, - JOYPAD_B | JOYPAD_RIGHT, - JOYPAD_B | JOYPAD_LEFT, - JOYPAD_B | JOYPAD_DOWN, // knee attack when in air - JOYPAD_Y | JOYPAD_RIGHT, // toss enemy - JOYPAD_Y | JOYPAD_LEFT, // as above - JOYPAD_DOWN | JOYPAD_RIGHT, - JOYPAD_DOWN | JOYPAD_LEFT, - JOYPAD_Y, // punch - JOYPAD_B, // jump - JOYPAD_Y | JOYPAD_B, - }; -} - - -/* create a new instance of the rom */ -RomSettings* FinalFightWithRightSettings::clone() const { - - RomSettings* rval = new FinalFightWithRightSettings(); - *rval = *this; - return rval; -} - - -/* process the latest information from ALE */ -void FinalFightWithRightSettings::step(const AleSystem& system) { - - // int time = getDecimalScoreWords({0xcbc, 0xcbd}, &system); - - // update the reward - reward_t playerScore = 100 * getDecimalScoreWords({0xc95,0xc94,0xc93}, &system); - - reward_t rightScore = readRam(&system, 0xf4) + 256 * readRam(&system, 0xf5) ; - - reward_t score = playerScore + rightScore; - - m_reward = score - m_score; - -// update terminal status - int lives = readRam(&system, 0x2456); - if ((lives == 0) && (m_prev_lives == 1)){ - m_terminal = true; - } else{ - m_terminal = false; - } - m_prev_lives = lives; -} - -/* is end of game */ -bool FinalFightWithRightSettings::isTerminal() const { - - return m_terminal; -}; - - -/* get the most recently observed reward */ -reward_t FinalFightWithRightSettings::getReward() const { - - return m_reward; -} - - -/* is an action part of the minimal set? */ -bool FinalFightWithRightSettings::isMinimal(const Action &a) const { - - if(minimalActions.find(a) == minimalActions.end()) - return false; - else - return true; -} - - -/* reset the state of the game */ -void FinalFightWithRightSettings::reset() { - - m_reward = 0; - m_score = 0; - m_terminal = false; - m_prev_lives = 5; - -} - - - -/* saves the state of the rom settings */ -void FinalFightWithRightSettings::saveState( Serializer & ser ) { - ser.putInt(m_reward); - ser.putInt(m_score); - ser.putInt(m_prev_lives); - ser.putBool(m_terminal); -} - -// loads the state of the rom settings -void FinalFightWithRightSettings::loadState( Deserializer & des ) { - m_reward = des.getInt(); - m_score = des.getInt(); - m_prev_lives = des.getInt(); - m_terminal = des.getBool(); -} - - -ActionVect FinalFightWithRightSettings::getStartingActions(){ - int num_of_nops(100); - ActionVect startingActions; - // wait for intro to end - startingActions.insert(startingActions.end(), 2.5*num_of_nops, JOYPAD_NOOP); - // press start to skip intro - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 2*num_of_nops, JOYPAD_NOOP); - // press start to select character - startingActions.push_back(JOYPAD_START); - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 2.2*num_of_nops, JOYPAD_NOOP); - // select character - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 4*num_of_nops, JOYPAD_NOOP); - - return startingActions; -} - diff --git a/src/games/supported/GradiusIII.cpp b/src/games/supported/GradiusIII.cpp index 6edfe39..e91d41e 100644 --- a/src/games/supported/GradiusIII.cpp +++ b/src/games/supported/GradiusIII.cpp @@ -15,9 +15,9 @@ #include "../RomUtils.hpp" #include "GradiusIII.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" -using namespace ale; +using namespace rle; GradiusIIISettings::GradiusIIISettings() { @@ -67,7 +67,7 @@ RomSettings* GradiusIIISettings::clone() const { /* process the latest information from ALE */ -void GradiusIIISettings::step(const AleSystem& system) { +void GradiusIIISettings::step(const RleSystem& system) { // uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); // // update the reward diff --git a/src/games/supported/GradiusIII.hpp b/src/games/supported/GradiusIII.hpp index f88ebdc..a019498 100644 --- a/src/games/supported/GradiusIII.hpp +++ b/src/games/supported/GradiusIII.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { struct GradiusIIISettings : public SnesSettings { @@ -59,7 +59,7 @@ struct GradiusIIISettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -80,6 +80,6 @@ struct GradiusIIISettings : public SnesSettings { int m_prev_lives; }; -} // namespace ale +} // namespace rle #endif // __GRADIUS_III_SETTINGS_HPP__ diff --git a/src/games/supported/MortalKombat.cpp b/src/games/supported/MortalKombat.cpp index d3c188a..df98d7e 100644 --- a/src/games/supported/MortalKombat.cpp +++ b/src/games/supported/MortalKombat.cpp @@ -15,10 +15,10 @@ #include "../RomUtils.hpp" #include "MortalKombat.hpp" -#include "AleSystem.hxx" -#include "AleException.h" +#include "RleSystem.hxx" +#include "RleException.h" -using namespace ale; +using namespace rle; MortalKombatSettings::MortalKombatSettings() { @@ -62,7 +62,7 @@ RomSettings* MortalKombatSettings::clone() const { /* process the latest information from ALE */ -void MortalKombatSettings::step(const AleSystem& system) { +void MortalKombatSettings::step(const RleSystem& system) { int time = getDecimalScore(0x122, &system); int npcScore = getDecimalScore(0x2a, 0x2b, 0x2c, &system); @@ -100,7 +100,7 @@ void MortalKombatSettings::step(const AleSystem& system) { if(newMatchStarted){ match_ended = false; // set random positions for players - startingOperations(const_cast(system)); + startingOperations(const_cast(system)); } } @@ -166,7 +166,7 @@ void MortalKombatSettings::loadState( Deserializer & des ) { } -ActionVect MortalKombatSettings::getStartingActions(const AleSystem& system){ +ActionVect MortalKombatSettings::getStartingActions(const RleSystem& system){ int num_of_nops(100); ActionVect startingActions; @@ -201,7 +201,7 @@ ActionVect MortalKombatSettings::getStartingActions(const AleSystem& system){ INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) INSERT_ACTION_SINGLE(JOYPAD_DOWN, A) }else{ - throw AleException("MK_player1_character illegal"); + throw RleException("MK_player1_character illegal"); } INSERT_NOPS(num_of_nops) @@ -218,7 +218,7 @@ ActionVect MortalKombatSettings::getStartingActions(const AleSystem& system){ }else if(4 == opponent_character){ INSERT_NOPS(15) }else{ - throw AleException("MK_opponent_character must be between 0 and 3"); + throw RleException("MK_opponent_character must be between 0 and 3"); } // INSERT_NOPS(10) // sub_zero @@ -241,7 +241,7 @@ ActionVect MortalKombatSettings::getStartingActions(const AleSystem& system){ return startingActions; } -void MortalKombatSettings::startingOperations(AleSystem& system){ +void MortalKombatSettings::startingOperations(RleSystem& system){ if(system.settings().getBool("MK_random_position")){ Random& rng = system.rng(); writeRam(&system, 0x30d, (rng.next()%0x100)); // set player 1's random init position diff --git a/src/games/supported/MortalKombat.hpp b/src/games/supported/MortalKombat.hpp index 28c31e5..447e1a3 100644 --- a/src/games/supported/MortalKombat.hpp +++ b/src/games/supported/MortalKombat.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { struct MortalKombatSettings : public SnesSettings { @@ -59,7 +59,7 @@ struct MortalKombatSettings : public SnesSettings { virtual bool isMinimal(const Action& a) const; // process the latest information from ALE - virtual void step(const AleSystem& system); + virtual void step(const RleSystem& system); // saves the state of the rom settings virtual void saveState( Serializer & ser ); @@ -69,9 +69,9 @@ struct MortalKombatSettings : public SnesSettings { virtual const int lives() { return 0; } - virtual ActionVect getStartingActions(const AleSystem& system); + virtual ActionVect getStartingActions(const RleSystem& system); - void startingOperations(AleSystem& system); + void startingOperations(RleSystem& system); protected: std::unordered_set minimalActions; @@ -83,6 +83,6 @@ struct MortalKombatSettings : public SnesSettings { bool match_ended; }; -} // namespace ale +} // namespace rle #endif // __MORTAL_KOMBAT_SETTINGS_HPP__ diff --git a/src/games/supported/MortalKombat2Players.cpp b/src/games/supported/MortalKombat2Players.cpp index a1fecfc..b04da12 100644 --- a/src/games/supported/MortalKombat2Players.cpp +++ b/src/games/supported/MortalKombat2Players.cpp @@ -12,13 +12,13 @@ #include #include "../RomUtils.hpp" #include "MortalKombat2Players.hpp" -#include "AleSystem.hxx" -#include "AleException.h" +#include "RleSystem.hxx" +#include "RleException.h" -using namespace ale; +using namespace rle; -MortalKombat2PlayersSettings::MortalKombat2PlayersSettings() : m_rewardB(0), MortalKombatSettings() {} +MortalKombat2PlayersSettings::MortalKombat2PlayersSettings() : MortalKombatSettings(), m_rewardB(0) {} /* create a new instance of the rom */ @@ -31,7 +31,7 @@ RomSettings* MortalKombat2PlayersSettings::clone() const { /* process the latest information from ALE */ -void MortalKombat2PlayersSettings::step(const AleSystem& system) { +void MortalKombat2PlayersSettings::step(const RleSystem& system) { MortalKombatSettings::step(system); m_rewardB = - m_reward; } @@ -65,7 +65,7 @@ void MortalKombat2PlayersSettings::loadState( Deserializer & des ) { m_rewardB = des.getInt(); } -ActionVect MortalKombat2PlayersSettings::getStartingActions(const AleSystem& system){ +ActionVect MortalKombat2PlayersSettings::getStartingActions(const RleSystem& system){ int num_of_nops(100); ActionVect startingActions; @@ -103,7 +103,7 @@ ActionVect MortalKombat2PlayersSettings::getStartingActions(const AleSystem& sys INSERT_ACTION_SINGLE(JOYPAD_NOOP, A) INSERT_ACTION_SINGLE(JOYPAD_DOWN, A) }else{ - throw AleException("MK_player1_character illegal"); + throw RleException("MK_player1_character illegal"); } INSERT_NOPS(num_of_nops) // choose for player b - Sonya @@ -129,7 +129,7 @@ ActionVect MortalKombat2PlayersSettings::getStartingActions(const AleSystem& sys }else if("scorpion" == player2_character){ INSERT_ACTION_SINGLE(JOYPAD_DOWN, B) }else{ - throw AleException("MK_player2_character illegal"); + throw RleException("MK_player2_character illegal"); } INSERT_NOPS(num_of_nops) diff --git a/src/games/supported/MortalKombat2Players.hpp b/src/games/supported/MortalKombat2Players.hpp index 2cfbbf8..8e0c8b0 100644 --- a/src/games/supported/MortalKombat2Players.hpp +++ b/src/games/supported/MortalKombat2Players.hpp @@ -32,7 +32,7 @@ #include "MortalKombat.hpp" #include -namespace ale { +namespace rle { struct MortalKombat2PlayersSettings : public MortalKombatSettings { @@ -53,7 +53,7 @@ struct MortalKombat2PlayersSettings : public MortalKombatSettings { RomSettings* clone() const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -63,12 +63,12 @@ struct MortalKombat2PlayersSettings : public MortalKombatSettings { virtual const int lives() { return 0; } - virtual ActionVect getStartingActions(const AleSystem& system); + virtual ActionVect getStartingActions(const RleSystem& system); private: reward_t m_rewardB; }; -} // namespace ale +} // namespace rle #endif // __MORTAL_KOMBAT_TWO_PLAYERS_SETTINGS_HPP__ diff --git a/src/games/supported/NBAGiveNGo.cpp b/src/games/supported/NBAGiveNGo.cpp index bfac79d..2c7b3bd 100644 --- a/src/games/supported/NBAGiveNGo.cpp +++ b/src/games/supported/NBAGiveNGo.cpp @@ -13,10 +13,10 @@ #include #include "../RomUtils.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" #include "NBAGiveNGo.hpp" -using namespace ale; +using namespace rle; NBAGiveNGoSettings::NBAGiveNGoSettings() { @@ -44,7 +44,7 @@ RomSettings* NBAGiveNGoSettings::clone() const { /* process the latest information from ALE */ -void NBAGiveNGoSettings::step(const AleSystem& system) { +void NBAGiveNGoSettings::step(const RleSystem& system) { // uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); uint32_t time = 60 * readRam(&system, 0xAC) + readRam(&system, 0xAE); diff --git a/src/games/supported/NBAGiveNGo.hpp b/src/games/supported/NBAGiveNGo.hpp index d0ce0de..c1715b0 100644 --- a/src/games/supported/NBAGiveNGo.hpp +++ b/src/games/supported/NBAGiveNGo.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { class NBAGiveNGoSettings : public SnesSettings { @@ -59,7 +59,7 @@ class NBAGiveNGoSettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -79,6 +79,6 @@ class NBAGiveNGoSettings : public SnesSettings { int m_time; }; -} // namespace ale +} // namespace rle #endif // __NBA_GIVE_N_GO_SETTINGS_HPP__ diff --git a/src/games/supported/Seaquest.cpp b/src/games/supported/Seaquest.cpp index f2144ac..298ac0b 100644 --- a/src/games/supported/Seaquest.cpp +++ b/src/games/supported/Seaquest.cpp @@ -29,7 +29,7 @@ #include "../RomUtils.hpp" #include -using namespace ale; +using namespace rle; SeaquestSettings::SeaquestSettings() { @@ -47,7 +47,7 @@ RomSettings* SeaquestSettings::clone() const { /* process the latest information from ALE */ -void SeaquestSettings::step(const AleSystem& system) { +void SeaquestSettings::step(const RleSystem& system) { // update the reward reward_t score = getDecimalScore(0xBA, 0xB9, 0xB8, &system); diff --git a/src/games/supported/Seaquest.hpp b/src/games/supported/Seaquest.hpp index 3ddffaf..dde239d 100644 --- a/src/games/supported/Seaquest.hpp +++ b/src/games/supported/Seaquest.hpp @@ -29,7 +29,7 @@ #include "../AtariSettings.hpp" -namespace ale { +namespace rle { /* RL wrapper for Seaquest */ @@ -58,7 +58,7 @@ class SeaquestSettings : public AtariSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState(Serializer & ser); @@ -76,7 +76,7 @@ class SeaquestSettings : public AtariSettings { int m_lives; }; -} // namespace ale +} // namespace rle #endif // __SEAQUEST_HPP__ diff --git a/src/games/supported/SuperMarioAllStars.cpp b/src/games/supported/SuperMarioAllStars.cpp index 98c5f94..2291f53 100644 --- a/src/games/supported/SuperMarioAllStars.cpp +++ b/src/games/supported/SuperMarioAllStars.cpp @@ -13,10 +13,10 @@ #include #include "../RomUtils.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" #include "SuperMarioAllStars.hpp" -using namespace ale; +using namespace rle; SuperMarioAllStarsSettings::SuperMarioAllStarsSettings() { @@ -46,7 +46,7 @@ RomSettings* SuperMarioAllStarsSettings::clone() const { /* process the latest information from ALE */ -void SuperMarioAllStarsSettings::step(const AleSystem& system) { +void SuperMarioAllStarsSettings::step(const RleSystem& system) { // uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); // update the reward diff --git a/src/games/supported/SuperMarioAllStars.hpp b/src/games/supported/SuperMarioAllStars.hpp index 9809014..0b7e7a7 100644 --- a/src/games/supported/SuperMarioAllStars.hpp +++ b/src/games/supported/SuperMarioAllStars.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { class SuperMarioAllStarsSettings : public SnesSettings { @@ -59,7 +59,7 @@ class SuperMarioAllStarsSettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -80,6 +80,6 @@ class SuperMarioAllStarsSettings : public SnesSettings { int m_time; }; -} // namespace ale +} // namespace rle #endif // __SUPER_MARIO_ALL_STARS_SETTINGS_HPP__ diff --git a/src/games/supported/SuperMarioAllStarsNoRight.cpp b/src/games/supported/SuperMarioAllStarsNoRight.cpp index a30213c..7c8fb76 100644 --- a/src/games/supported/SuperMarioAllStarsNoRight.cpp +++ b/src/games/supported/SuperMarioAllStarsNoRight.cpp @@ -13,10 +13,10 @@ #include #include "../RomUtils.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" #include "SuperMarioAllStarsNoRight.hpp" -using namespace ale; +using namespace rle; SuperMarioAllStarsNoRightSettings::SuperMarioAllStarsNoRightSettings() { @@ -46,7 +46,7 @@ RomSettings* SuperMarioAllStarsNoRightSettings::clone() const { /* process the latest information from ALE */ -void SuperMarioAllStarsNoRightSettings::step(const AleSystem& system) { +void SuperMarioAllStarsNoRightSettings::step(const RleSystem& system) { // uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); // update the reward diff --git a/src/games/supported/SuperMarioAllStarsNoRight.hpp b/src/games/supported/SuperMarioAllStarsNoRight.hpp index fc9c5da..42afd7f 100644 --- a/src/games/supported/SuperMarioAllStarsNoRight.hpp +++ b/src/games/supported/SuperMarioAllStarsNoRight.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { class SuperMarioAllStarsNoRightSettings : public SnesSettings { @@ -59,7 +59,7 @@ class SuperMarioAllStarsNoRightSettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -80,6 +80,6 @@ class SuperMarioAllStarsNoRightSettings : public SnesSettings { int m_time; }; -} // namespace ale +} // namespace rle #endif // __SUPER_MARIO_ALL_STARS_NO_RIGHT_SETTINGS_HPP__ diff --git a/src/games/supported/SuperMarioWorld.cpp b/src/games/supported/SuperMarioWorld.cpp index 155f15f..bfc8473 100644 --- a/src/games/supported/SuperMarioWorld.cpp +++ b/src/games/supported/SuperMarioWorld.cpp @@ -15,9 +15,9 @@ #include "../RomUtils.hpp" #include "SuperMarioWorld.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" -using namespace ale; +using namespace rle; SuperMarioWorldSettings::SuperMarioWorldSettings() { @@ -64,7 +64,7 @@ RomSettings* SuperMarioWorldSettings::clone() const { /* process the latest information from ALE */ -void SuperMarioWorldSettings::step(const AleSystem& system) { +void SuperMarioWorldSettings::step(const RleSystem& system) { // uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); int time = getDecimalScoreWords({0xf33, 0xf32, 0xf31}, &system); // DEBUG2("time: " << std::dec << time); diff --git a/src/games/supported/SuperMarioWorld.hpp b/src/games/supported/SuperMarioWorld.hpp index 0eef96d..e06a569 100644 --- a/src/games/supported/SuperMarioWorld.hpp +++ b/src/games/supported/SuperMarioWorld.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { struct SuperMarioWorldSettings : public SnesSettings { @@ -59,7 +59,7 @@ struct SuperMarioWorldSettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -79,6 +79,6 @@ struct SuperMarioWorldSettings : public SnesSettings { vector m_lastTime; }; -} // namespace ale +} // namespace rle #endif // __SUPER_MARIO_WORLD_SETTINGS_HPP__ diff --git a/src/games/supported/TetrisAndDrMario.cpp b/src/games/supported/TetrisAndDrMario.cpp index 4747baa..2272a46 100644 --- a/src/games/supported/TetrisAndDrMario.cpp +++ b/src/games/supported/TetrisAndDrMario.cpp @@ -13,10 +13,10 @@ #include #include "../RomUtils.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" #include "TetrisAndDrMario.hpp" -using namespace ale; +using namespace rle; TetrisAndDrMarioSettings::TetrisAndDrMarioSettings() { @@ -41,7 +41,7 @@ RomSettings* TetrisAndDrMarioSettings::clone() const { /* process the latest information from ALE */ -void TetrisAndDrMarioSettings::step(const AleSystem& system) { +void TetrisAndDrMarioSettings::step(const RleSystem& system) { // uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); // update the reward diff --git a/src/games/supported/TetrisAndDrMario.hpp b/src/games/supported/TetrisAndDrMario.hpp index b992ba5..9edf097 100644 --- a/src/games/supported/TetrisAndDrMario.hpp +++ b/src/games/supported/TetrisAndDrMario.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { class TetrisAndDrMarioSettings : public SnesSettings { @@ -59,7 +59,7 @@ class TetrisAndDrMarioSettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -78,6 +78,6 @@ class TetrisAndDrMarioSettings : public SnesSettings { reward_t m_score; }; -} // namespace ale +} // namespace rle #endif // __TETRIS_AND_DR_MARIO_SETTINGS_HPP__ diff --git a/src/games/supported/TetrisAndDrMarioLines.cpp b/src/games/supported/TetrisAndDrMarioLines.cpp deleted file mode 100644 index 8eecedf..0000000 --- a/src/games/supported/TetrisAndDrMarioLines.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* ***************************************************************************** - * 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 "AleSystem.hxx" -#include "TetrisAndDrMarioLines.hpp" - -using namespace ale; - - -TetrisAndDrMarioLinesSettings::TetrisAndDrMarioLinesSettings() { - reset(); - - minimalActions = { JOYPAD_NOOP, - JOYPAD_DOWN, - JOYPAD_LEFT, - JOYPAD_RIGHT, - JOYPAD_A, // counter clockwise rotation - JOYPAD_B, // clockwise rotation - }; -} - - -/* create a new instance of the rom */ -RomSettings* TetrisAndDrMarioLinesSettings::clone() const { - RomSettings* rval = new TetrisAndDrMarioLinesSettings(); - *rval = *this; - return rval; -} - - -/* process the latest information from ALE */ -void TetrisAndDrMarioLinesSettings::step(const AleSystem& system) { -// uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); - - // update the reward -// reward_t playerScore = (256 * 256) * readRam(&system, 0x272) + 256 * readRam(&system, 0x271) + readRam(&system, 0x270); - - reward_t numOfLinesCompleted = readRam(&system, 0x328); - - m_reward = numOfLinesCompleted - m_score; - m_score = numOfLinesCompleted; -// DEBUG2("score is:" << m_score); -// DEBUG2("reward is:" << m_reward); - -// update terminal status - int isAlive = readRam(&system, 0x125); - if (isAlive > 0){ - m_terminal = true; - } -// DEBUG2("Is terminal: " << std::dec << m_terminal); -} - -/* is end of game */ -bool TetrisAndDrMarioLinesSettings::isTerminal() const { - return m_terminal; -}; - - -/* get the most recently observed reward */ -reward_t TetrisAndDrMarioLinesSettings::getReward() const { - - return m_reward; -} - - -/* is an action part of the minimal set? */ -bool TetrisAndDrMarioLinesSettings::isMinimal(const Action &a) const { - - if(minimalActions.find(a) == minimalActions.end()) - return false; - else - return true; -} - - -/* reset the state of the game */ -void TetrisAndDrMarioLinesSettings::reset() { - - m_reward = 0; - m_score = 0; - m_terminal = false; -} - - - -/* saves the state of the rom settings */ -void TetrisAndDrMarioLinesSettings::saveState( Serializer & ser ) { - ser.putInt(m_reward); - ser.putInt(m_score); - ser.putBool(m_terminal); -} - -// loads the state of the rom settings -void TetrisAndDrMarioLinesSettings::loadState( Deserializer & des ) { - m_reward = des.getInt(); - m_score = des.getInt(); - m_terminal = des.getBool(); -} - - -ActionVect TetrisAndDrMarioLinesSettings::getStartingActions(){ - int num_of_nops(100); - ActionVect startingActions; -// startingActions.reserve(num_of_xs*num_of_nops); - - // wait for intro to end - startingActions.insert(startingActions.end(), 3.5*num_of_nops, JOYPAD_NOOP); - // select game - startingActions.push_back(JOYPAD_START); - // wait for character select screen - startingActions.insert(startingActions.end(), 0.8*num_of_nops, JOYPAD_NOOP); - // select 1 player - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 0.6*num_of_nops, JOYPAD_NOOP); - // select type (?) - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 0.6*num_of_nops, JOYPAD_NOOP); - // select level - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 0.6*num_of_nops, JOYPAD_NOOP); - // start the level - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 1*num_of_nops, JOYPAD_NOOP); - return startingActions; -} - diff --git a/src/games/supported/TetrisAndDrMarioLines.hpp b/src/games/supported/TetrisAndDrMarioLines.hpp deleted file mode 100644 index 6984d41..0000000 --- a/src/games/supported/TetrisAndDrMarioLines.hpp +++ /dev/null @@ -1,83 +0,0 @@ -/* ***************************************************************************** - * 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 __TETRIS_AND_DR_MARIO_LINES_SETTINGS_HPP__ -#define __TETRIS_AND_DR_MARIO_LINES_SETTINGS_HPP__ -/* RL wrapper for AtariCollection settings */ - -#include "../SnesSettings.hpp" -#include - -namespace ale { - -class TetrisAndDrMarioLinesSettings : public SnesSettings { - - public: - - TetrisAndDrMarioLinesSettings(); - - // reset - void reset(); - - // is end of game - bool isTerminal() const; - - // get the most recently observed reward - reward_t getReward() const; - - // the rom-name - const char* rom() const { return "tetris_and_dr_mario_lines"; } - - // create a new instance of the rom - RomSettings* clone() const; - - // is an action part of the minimal set? - bool isMinimal(const Action& a) const; - - // process the latest information from ALE - void step(const AleSystem& 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: - std::unordered_set minimalActions; - bool m_terminal; - reward_t m_reward; - reward_t m_score; -}; - -} // namespace ale - -#endif // __TETRIS_AND_DR_MARIO_LINES_SETTINGS_HPP__ diff --git a/src/games/supported/TetrisAndDrMarioNumBlocks.cpp b/src/games/supported/TetrisAndDrMarioNumBlocks.cpp deleted file mode 100644 index ad7dd95..0000000 --- a/src/games/supported/TetrisAndDrMarioNumBlocks.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* ***************************************************************************** - * 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 "AleSystem.hxx" -#include "TetrisAndDrMarioNumBlocks.hpp" - -using namespace ale; - - -TetrisAndDrMarioNumBlocksSettings::TetrisAndDrMarioNumBlocksSettings() { - reset(); - - minimalActions = { JOYPAD_NOOP, - JOYPAD_DOWN, - JOYPAD_LEFT, - JOYPAD_RIGHT, - JOYPAD_A, // counter clockwise rotation - JOYPAD_B, // clockwise rotation - }; -} - - -/* create a new instance of the rom */ -RomSettings* TetrisAndDrMarioNumBlocksSettings::clone() const { - RomSettings* rval = new TetrisAndDrMarioNumBlocksSettings(); - *rval = *this; - return rval; -} - - -/* process the latest information from ALE */ -void TetrisAndDrMarioNumBlocksSettings::step(const AleSystem& system) { -// uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); - - // update the reward -// reward_t playerScore = (256 * 256) * readRam(&system, 0x272) + 256 * readRam(&system, 0x271) + readRam(&system, 0x270); - - reward_t numBlocks = readRam(&system, 0x357) + readRam(&system, 0x359) + readRam(&system, 0x35b) + readRam(&system, 0x35D) + readRam(&system, 0x35F) + readRam(&system, 0x361) + readRam(&system, 0x363); - m_reward = numBlocks - m_score; - m_score = numBlocks; - //shai: temp fix - -// DEBUG2("score is:" << m_score); -// DEBUG2("reward is:" << m_reward); - -// update terminal status - int isAlive = readRam(&system, 0x125); - if (isAlive > 0){ - m_terminal = true; - } -// DEBUG2("Is terminal: " << std::dec << m_terminal); -} - -/* is end of game */ -bool TetrisAndDrMarioNumBlocksSettings::isTerminal() const { - return m_terminal; -}; - - -/* get the most recently observed reward */ -reward_t TetrisAndDrMarioNumBlocksSettings::getReward() const { - - return m_reward; -} - - -/* is an action part of the minimal set? */ -bool TetrisAndDrMarioNumBlocksSettings::isMinimal(const Action &a) const { - - if(minimalActions.find(a) == minimalActions.end()) - return false; - else - return true; -} - - -/* reset the state of the game */ -void TetrisAndDrMarioNumBlocksSettings::reset() { - - m_reward = 0; - m_score = 0; - m_terminal = false; -} - - - -/* saves the state of the rom settings */ -void TetrisAndDrMarioNumBlocksSettings::saveState( Serializer & ser ) { - ser.putInt(m_reward); - ser.putInt(m_score); - ser.putBool(m_terminal); -} - -// loads the state of the rom settings -void TetrisAndDrMarioNumBlocksSettings::loadState( Deserializer & des ) { - m_reward = des.getInt(); - m_score = des.getInt(); - m_terminal = des.getBool(); -} - - -ActionVect TetrisAndDrMarioNumBlocksSettings::getStartingActions(){ - int num_of_nops(100); - ActionVect startingActions; -// startingActions.reserve(num_of_xs*num_of_nops); - - // wait for intro to end - startingActions.insert(startingActions.end(), 3.5*num_of_nops, JOYPAD_NOOP); - // select game - startingActions.push_back(JOYPAD_START); - // wait for character select screen - startingActions.insert(startingActions.end(), 0.8*num_of_nops, JOYPAD_NOOP); - // select 1 player - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 0.6*num_of_nops, JOYPAD_NOOP); - // select type (?) - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 0.6*num_of_nops, JOYPAD_NOOP); - // select level - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 0.6*num_of_nops, JOYPAD_NOOP); - // start the level - startingActions.push_back(JOYPAD_START); - startingActions.insert(startingActions.end(), 1*num_of_nops, JOYPAD_NOOP); - return startingActions; -} - diff --git a/src/games/supported/TetrisAndDrMarioNumBlocks.hpp b/src/games/supported/TetrisAndDrMarioNumBlocks.hpp deleted file mode 100644 index fc31d24..0000000 --- a/src/games/supported/TetrisAndDrMarioNumBlocks.hpp +++ /dev/null @@ -1,83 +0,0 @@ -/* ***************************************************************************** - * 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 __TETRIS_AND_DR_MARIO_NUM_BLOCKS_SETTINGS_HPP__ -#define __TETRIS_AND_DR_MARIO_NUM_BLOCKS_SETTINGS_HPP__ -/* RL wrapper for AtariCollection settings */ - -#include "../SnesSettings.hpp" -#include - -namespace ale { - -class TetrisAndDrMarioNumBlocksSettings : public SnesSettings { - - public: - - TetrisAndDrMarioNumBlocksSettings(); - - // reset - void reset(); - - // is end of game - bool isTerminal() const; - - // get the most recently observed reward - reward_t getReward() const; - - // the rom-name - const char* rom() const { return "tetris_and_dr_mario_num_blocks"; } - - // create a new instance of the rom - RomSettings* clone() const; - - // is an action part of the minimal set? - bool isMinimal(const Action& a) const; - - // process the latest information from ALE - void step(const AleSystem& 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: - std::unordered_set minimalActions; - bool m_terminal; - reward_t m_reward; - reward_t m_score; -}; - -} // namespace ale - -#endif // __TETRIS_AND_DR_MARIO_NUM_BLOCKS_SETTINGS_HPP__ diff --git a/src/games/supported/Wolfenstein.cpp b/src/games/supported/Wolfenstein.cpp index fd54498..9ba4a97 100644 --- a/src/games/supported/Wolfenstein.cpp +++ b/src/games/supported/Wolfenstein.cpp @@ -15,9 +15,9 @@ #include "../RomUtils.hpp" #include "Wolfenstein.hpp" -#include "AleSystem.hxx" +#include "RleSystem.hxx" -using namespace ale; +using namespace rle; WolfensteinSettings::WolfensteinSettings() { @@ -67,7 +67,7 @@ RomSettings* WolfensteinSettings::clone() const { /* process the latest information from ALE */ -void WolfensteinSettings::step(const AleSystem& system) { +void WolfensteinSettings::step(const RleSystem& system) { // uint8_t* address = system.getRetroAgent().getRamAddress(RETRO_MEMORY_SYSTEM_RAM); // // update the reward diff --git a/src/games/supported/Wolfenstein.hpp b/src/games/supported/Wolfenstein.hpp index 64a0d23..681391b 100644 --- a/src/games/supported/Wolfenstein.hpp +++ b/src/games/supported/Wolfenstein.hpp @@ -32,7 +32,7 @@ #include "../SnesSettings.hpp" #include -namespace ale { +namespace rle { struct WolfensteinSettings : public SnesSettings { @@ -59,7 +59,7 @@ struct WolfensteinSettings : public SnesSettings { bool isMinimal(const Action& a) const; // process the latest information from ALE - void step(const AleSystem& system); + void step(const RleSystem& system); // saves the state of the rom settings void saveState( Serializer & ser ); @@ -82,6 +82,6 @@ struct WolfensteinSettings : public SnesSettings { // int m_ammo; }; -} // namespace ale +} // namespace rle #endif // __WOLFENSTEIN_SETTINGS_HPP__ diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index b4ecd1e..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* ***************************************************************************** - * 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 -#include -#include -#include - -#if (defined(WIN32) || defined(__MINGW32__)) -# include "os_dependent/SettingsWin32.hxx" -# include "os_dependent/AleSystemWin32.hxx" -#else -# include "os_dependent/SettingsUNIX.hxx" -# include "os_dependent/AleSystemUNIX.hxx" -#endif - -#include "controllers/ale_controller.hpp" -#include "controllers/fifo_controller.hpp" -#include "controllers/rlglue_controller.hpp" -#include "common/Constants.h" -#include "ale_interface.hpp" - -using namespace ale; - -static std::unique_ptr theAleSystem; -static std::unique_ptr theSettings; -static std::unique_ptr theRetroAgent; - -static ALEController* createController(AleSystem* alesystem, std::string type) { - if(type.empty()){ - std::cerr << "You must specify a controller type (via -game_controller)." << std::endl; - exit(1); - } - else if (type == "fifo") { - std::cerr << "Game will be controlled through FIFO pipes." << std::endl; - return new FIFOController(alesystem, false); - } - else if (type == "fifo_named") { - std::cerr << "Game will be controlled through named FIFO pipes." << std::endl; - return new FIFOController(alesystem, true); - } - else if (type == "rlglue") { - std::cerr << "Game will be controlled through RL-Glue." << std::endl; - return new RLGlueController(alesystem); - } - else { - std::cerr << "Invalid controller type: " << type << " " << std::endl; - exit(1); - } -} - -/* application entry point */ -int main(int argc, char* argv[]) { - - ALEInterface::disableBufferedIO(); - - std::cerr << ALEInterface::welcomeMessage() << std::endl; - - ALEInterface::createAleSystem(theAleSystem, theSettings, theRetroAgent); - // Process commandline arguments, which over-ride all possible - // config file settings - std::string romfile = theAleSystem->settings().loadCommandLine(argc, argv); - std::string corefile = theAleSystem->settings().getString("core_file"); - ALEInterface::loadSettings(romfile, corefile, theAleSystem); - - // Create the game controller - std::string controller_type = theAleSystem->settings().getString("game_controller"); - std::auto_ptr controller(createController(theAleSystem.get(), controller_type)); - - controller->run(); - - // MUST delete theOSystem to avoid a segfault (theOSystem relies on Settings - // still being a valid construct) - theAleSystem.reset(); - - return 0; -} diff --git a/src/os_dependent/.deps/OSystemUNIX.d b/src/os_dependent/.deps/OSystemUNIX.d deleted file mode 100644 index f8c5c77..0000000 --- a/src/os_dependent/.deps/OSystemUNIX.d +++ /dev/null @@ -1,85 +0,0 @@ -src/os_dependent/OSystemUNIX.o: src/os_dependent/OSystemUNIX.cxx \ - src/emucore/m6502/src/bspf/src/bspf.hxx src/emucore/OSystem.hxx \ - src/emucore/../common/Array.hxx \ - src/emucore/../common/../emucore/m6502/src/bspf/src/bspf.hxx \ - src/emucore/Sound.hxx src/emucore/m6502/src/bspf/src/bspf.hxx \ - src/emucore/../common/SoundNull.hxx \ - src/emucore/../common/../emucore/Sound.hxx src/emucore/Settings.hxx \ - src/emucore/Console.hxx src/emucore/Control.hxx src/emucore/Props.hxx \ - src/emucore/TIA.hxx src/emucore/m6502/src/Device.hxx \ - src/emucore/m6502/src/bspf/src/bspf.hxx src/emucore/MediaSrc.hxx \ - src/emucore/Cart.hxx src/emucore/../common/Log.hpp src/emucore/M6532.hxx \ - src/emucore/Random.hxx src/emucore/AtariVox.hxx src/emucore/Event.hxx \ - src/emucore/../common/display_screen.h src/emucore/../common/Constants.h \ - src/emucore/../common/ColourPalette.hpp \ - src/emucore/../common/../emucore/MediaSrc.hxx \ - src/emucore/../common/ColourPalette.hpp \ - src/emucore/../common/ScreenExporter.hpp \ - src/emucore/../common/display_screen.h \ - src/emucore/../common/../environment/ale_screen.hpp \ - src/os_dependent/OSystemUNIX.hxx \ - src/os_dependent/../emucore/m6502/src/bspf/src/bspf.hxx - -src/emucore/m6502/src/bspf/src/bspf.hxx: - -src/emucore/OSystem.hxx: - -src/emucore/../common/Array.hxx: - -src/emucore/../common/../emucore/m6502/src/bspf/src/bspf.hxx: - -src/emucore/Sound.hxx: - -src/emucore/m6502/src/bspf/src/bspf.hxx: - -src/emucore/../common/SoundNull.hxx: - -src/emucore/../common/../emucore/Sound.hxx: - -src/emucore/Settings.hxx: - -src/emucore/Console.hxx: - -src/emucore/Control.hxx: - -src/emucore/Props.hxx: - -src/emucore/TIA.hxx: - -src/emucore/m6502/src/Device.hxx: - -src/emucore/m6502/src/bspf/src/bspf.hxx: - -src/emucore/MediaSrc.hxx: - -src/emucore/Cart.hxx: - -src/emucore/../common/Log.hpp: - -src/emucore/M6532.hxx: - -src/emucore/Random.hxx: - -src/emucore/AtariVox.hxx: - -src/emucore/Event.hxx: - -src/emucore/../common/display_screen.h: - -src/emucore/../common/Constants.h: - -src/emucore/../common/ColourPalette.hpp: - -src/emucore/../common/../emucore/MediaSrc.hxx: - -src/emucore/../common/ColourPalette.hpp: - -src/emucore/../common/ScreenExporter.hpp: - -src/emucore/../common/display_screen.h: - -src/emucore/../common/../environment/ale_screen.hpp: - -src/os_dependent/OSystemUNIX.hxx: - -src/os_dependent/../emucore/m6502/src/bspf/src/bspf.hxx: diff --git a/src/os_dependent/OSystemWin32.cxx b/src/os_dependent/OSystemWin32.cxx index c319a6c..22112d0 100644 --- a/src/os_dependent/OSystemWin32.cxx +++ b/src/os_dependent/OSystemWin32.cxx @@ -47,7 +47,7 @@ // // For now, we just put it in the same directory as the executable. // const string& basedir = "."; // setBaseDir(basedir); -// setConfigFile(basedir + "\\ale.cfg"); +// setConfigFile(basedir + "\\rle.cfg"); //} // //// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/os_dependent/AleSystemUNIX.cxx b/src/os_dependent/RleSystemUNIX.cxx similarity index 85% rename from src/os_dependent/AleSystemUNIX.cxx rename to src/os_dependent/RleSystemUNIX.cxx index 716038f..2486def 100644 --- a/src/os_dependent/AleSystemUNIX.cxx +++ b/src/os_dependent/RleSystemUNIX.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: AleSystemUNIX.cxx,v 1.27 2007/07/19 16:21:39 stephena Exp $ +// $Id: RleSystemUNIX.cxx,v 1.27 2007/07/19 16:21:39 stephena Exp $ //============================================================================ #include @@ -25,10 +25,10 @@ #include //#include "bspf.hxx" -#include "AleSystem.hxx" -#include "AleSystemUNIX.hxx" +#include "RleSystem.hxx" +#include "RleSystemUNIX.hxx" using namespace std; -using namespace ale; +using namespace rle; //ALE #ifdef HAVE_GETTIMEOFDAY #include @@ -46,8 +46,8 @@ using namespace ale; */ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AleSystemUNIX::AleSystemUNIX(RetroAgent* retroagent) - : AleSystem(retroagent) +RleSystemUNIX::RleSystemUNIX(RetroAgent* retroagent) + : RleSystem(retroagent) { //ALE const string& basedir = string(getenv("HOME")) + "/.stella"; string basedir = string("."); //ALE @@ -55,12 +55,12 @@ AleSystemUNIX::AleSystemUNIX(RetroAgent* retroagent) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AleSystemUNIX::~AleSystemUNIX() +RleSystemUNIX::~RleSystemUNIX() { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 AleSystemUNIX::getTicks() { +uInt32 RleSystemUNIX::getTicks() { //ALE #ifdef HAVE_GETTIMEOFDAY timeval now; gettimeofday(&now, 0); diff --git a/src/os_dependent/AleSystemUNIX.hxx b/src/os_dependent/RleSystemUNIX.hxx similarity index 78% rename from src/os_dependent/AleSystemUNIX.hxx rename to src/os_dependent/RleSystemUNIX.hxx index 057f8fb..96a9bba 100644 --- a/src/os_dependent/AleSystemUNIX.hxx +++ b/src/os_dependent/RleSystemUNIX.hxx @@ -13,16 +13,16 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: AleSystemUNIX.hxx,v 1.16 2007/07/19 16:21:39 stephena Exp $ +// $Id: RleSystemUNIX.hxx,v 1.16 2007/07/19 16:21:39 stephena Exp $ //============================================================================ #ifndef OSYSTEM_UNIX_HXX #define OSYSTEM_UNIX_HXX #include "../common/bspf.hxx" -#include "../environment/AleSystem.hxx" +#include "../environment/RleSystem.hxx" -namespace ale { +namespace rle { class RetroAgent; @@ -30,20 +30,20 @@ class RetroAgent; This class defines UNIX-like OS's (Linux) system specific settings. @author Stephen Anthony - @version $Id: AleSystemUNIX.hxx,v 1.16 2007/07/19 16:21:39 stephena Exp $ + @version $Id: RleSystemUNIX.hxx,v 1.16 2007/07/19 16:21:39 stephena Exp $ */ -class AleSystemUNIX : public AleSystem +class RleSystemUNIX : public RleSystem { public: /** Create a new UNIX-specific operating system object */ - AleSystemUNIX(RetroAgent* retroagent); + RleSystemUNIX(RetroAgent* retroagent); /** Destructor */ - virtual ~AleSystemUNIX(); + virtual ~RleSystemUNIX(); /** This method returns number of ticks in microseconds. @@ -53,6 +53,6 @@ class AleSystemUNIX : public AleSystem uInt32 getTicks(); }; -} // namespace ale +} // namespace rle #endif diff --git a/src/os_dependent/SettingsUNIX.cxx b/src/os_dependent/SettingsUNIX.cxx index 3ddcb19..bbfda26 100644 --- a/src/os_dependent/SettingsUNIX.cxx +++ b/src/os_dependent/SettingsUNIX.cxx @@ -23,10 +23,10 @@ #include "SettingsUNIX.hxx" -namespace ale { +namespace rle { -SettingsUNIX::SettingsUNIX(AleSystem* alesystem) - : Settings(alesystem) +SettingsUNIX::SettingsUNIX(RleSystem* rlesystem) + : Settings(rlesystem) { setInternal("gl_lib", "libGL.so"); // Most Linux GL implementations don't support this yet @@ -38,4 +38,4 @@ SettingsUNIX::~SettingsUNIX() { } -} // namespace ale +} // namespace rle diff --git a/src/os_dependent/SettingsUNIX.hxx b/src/os_dependent/SettingsUNIX.hxx index deb9479..e9677df 100644 --- a/src/os_dependent/SettingsUNIX.hxx +++ b/src/os_dependent/SettingsUNIX.hxx @@ -20,9 +20,9 @@ #define SETTINGS_UNIX_HXX #include "../environment/Settings.hxx" -#include "../environment/AleSystem.hxx" +#include "../environment/RleSystem.hxx" -namespace ale { +namespace rle { /** This class defines UNIX-like OS's (Linux) system specific settings. @@ -35,7 +35,7 @@ class SettingsUNIX : public Settings /** Create a new UNIX settings object */ - SettingsUNIX(AleSystem* aleSystem); + SettingsUNIX(RleSystem* rleSystem); /** Destructor @@ -43,6 +43,6 @@ class SettingsUNIX : public Settings virtual ~SettingsUNIX(); }; -} // namespace ale +} // namespace rle #endif diff --git a/src/ale_interface.cpp b/src/rle_interface.cpp similarity index 64% rename from src/ale_interface.cpp rename to src/rle_interface.cpp index c03f0e8..bb99d40 100644 --- a/src/ale_interface.cpp +++ b/src/rle_interface.cpp @@ -23,24 +23,24 @@ * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team * * ***************************************************************************** - * ale_interface.cpp + * rle_interface.cpp * * The shared library interface. **************************************************************************** */ -#include "ale_interface.hpp" +#include "rle_interface.hpp" #include "os_dependent/SettingsWin32.hxx" #include "os_dependent/SettingsUNIX.hxx" -#include "os_dependent/AleSystemUNIX.hxx" +#include "os_dependent/RleSystemUNIX.hxx" #include "games/Roms.hpp" #include "common/display_screen.h" #include "environment/retro_environment.hpp" #include "os_dependent/SettingsUNIX.hxx" #include "os_dependent/SettingsWin32.hxx" #include "environment/FSNode.hxx" -#include "common/ScreenExporter.hpp" +//#include "common/ScreenExporter.hpp" #include "common/Log.hpp" -#include "common/AleException.h" +#include "common/RleException.h" #include #include #include @@ -48,9 +48,9 @@ #include using namespace std; -namespace ale { +namespace rle { -class ALEInterface::Impl{ +class RLEInterface::Impl{ public: Impl(); ~Impl(); @@ -74,7 +74,7 @@ class ALEInterface::Impl{ // Resets the Atari and loads a game. After this call the game // should be ready to play. This is necessary after changing a // setting for the setting to take effect. - // ALE2: specify which core to load as well. Default is Atari. + // RLE: specify which core to load as well. Default is Atari. void loadROM(std::string rom_file ="", std::string core_file = ""); // Applies an action to the game and returns the reward. It is the @@ -104,10 +104,10 @@ class ALEInterface::Impl{ int getEpisodeFrameNumber() const; // Returns the current game screen - const ALEScreen &getScreen() const; + const RLEScreen &getScreen() const; // Returns the current RAM content - const ALERAM &getRAM() const; + const RLERAM &getRAM() const; // Saves the state of the system void saveState(); @@ -117,19 +117,19 @@ class ALEInterface::Impl{ // This makes a copy of the environment state. This copy does *not* include pseudorandomness, // making it suitable for planning purposes. By contrast, see cloneSystemState. - ALEState cloneState(); + RLEState cloneState(); // Reverse operation of cloneState(). This does not restore pseudorandomness, so that repeated // calls to restoreState() in the stochastic controls setting will not lead to the same outcomes. // By contrast, see restoreSystemState. - void restoreState(const ALEState& state); + void restoreState(const RLEState& state); // This makes a copy of the system & environment state, suitable for serialization. This includes // pseudorandomness and so is *not* suitable for planning purposes. - ALEState cloneSystemState(); + RLEState cloneSystemState(); // Reverse operation of cloneSystemState. - void restoreSystemState(const ALEState& state); + void restoreSystemState(const RLEState& state); // Save the current screen as a png file void saveScreenPNG(const std::string& filename); @@ -140,14 +140,14 @@ class ALEInterface::Impl{ ScreenExporter *createScreenExporter(const std::string &path) const; // static functions - void createAleSystem(std::unique_ptr &theAleSystem, + void createRleSystem(std::unique_ptr &theRleSystem, std::unique_ptr &theSettings, std::unique_ptr &theRetroAgent); void loadSettings(const std::string& romfile, const std::string& corefile, - std::unique_ptr &theSLESystem); + std::unique_ptr &theSLESystem); private: - std::unique_ptr theAleSystem; + std::unique_ptr theRleSystem; std::unique_ptr theSettings; std::unique_ptr theRetroAgent; std::unique_ptr romSettings; @@ -156,153 +156,154 @@ class ALEInterface::Impl{ }; -//thread_local bool ALEInterface::Impl::initialized = false; +//thread_local bool RLEInterface::Impl::initialized = false; -ALEInterface::Impl::Impl() : max_num_frames(0){ - ALEInterface::createAleSystem(theAleSystem, theSettings, theRetroAgent); +RLEInterface::Impl::Impl() : max_num_frames(0){ + RLEInterface::createRleSystem(theRleSystem, theSettings, theRetroAgent); } -ALEInterface::Impl::~Impl() { +RLEInterface::Impl::~Impl() { } // Get the value of a setting. -std::string ALEInterface::Impl::getString(const std::string& key) { +std::string RLEInterface::Impl::getString(const std::string& key) { assert(theSettings); return theSettings->getString(key); } -int ALEInterface::Impl::getInt(const std::string& key) { +int RLEInterface::Impl::getInt(const std::string& key) { assert(theSettings); return theSettings->getInt(key); } -bool ALEInterface::Impl::getBool(const std::string& key) { +bool RLEInterface::Impl::getBool(const std::string& key) { assert(theSettings); return theSettings->getBool(key); } -float ALEInterface::Impl::getFloat(const std::string& key) { +float RLEInterface::Impl::getFloat(const std::string& key) { assert(theSettings); return theSettings->getFloat(key); } // Set the value of a setting. -void ALEInterface::Impl::setString(const string& key, const string& value) { +void RLEInterface::Impl::setString(const string& key, const string& value) { assert(theSettings); - assert(theAleSystem); + assert(theRleSystem); theSettings->setString(key, value); theSettings->validate(); } -void ALEInterface::Impl::setInt(const string& key, const int value) { +void RLEInterface::Impl::setInt(const string& key, const int value) { assert(theSettings); - assert(theAleSystem); + assert(theRleSystem); theSettings->setInt(key, value); theSettings->validate(); } -void ALEInterface::Impl::setBool(const string& key, const bool value) { +void RLEInterface::Impl::setBool(const string& key, const bool value) { assert(theSettings); - assert(theAleSystem); + assert(theRleSystem); theSettings->setBool(key, value); theSettings->validate(); } -void ALEInterface::Impl::setFloat(const string& key, const float value) { +void RLEInterface::Impl::setFloat(const string& key, const float value) { assert(theSettings); - assert(theAleSystem); + assert(theRleSystem); theSettings->setFloat(key, value); theSettings->validate(); if(key == "random_seed"){ - theAleSystem->resetRNGSeed(); + theRleSystem->resetRNGSeed(); } } // Get the value of a setting. -std::string ALEInterface::getString(const std::string& key) { +std::string RLEInterface::getString(const std::string& key) { return m_pimpl->getString(key); } -int ALEInterface::getInt(const std::string& key) { +int RLEInterface::getInt(const std::string& key) { return m_pimpl->getInt(key); } -bool ALEInterface::getBool(const std::string& key) { +bool RLEInterface::getBool(const std::string& key) { return m_pimpl->getBool(key); } -float ALEInterface::getFloat(const std::string& key) { +float RLEInterface::getFloat(const std::string& key) { return m_pimpl->getFloat(key); } // Set the value of a setting. -void ALEInterface::setString(const string& key, const string& value) { +void RLEInterface::setString(const string& key, const string& value) { m_pimpl->setString(key, value); } -void ALEInterface::setInt(const string& key, const int value) { +void RLEInterface::setInt(const string& key, const int value) { m_pimpl->setInt(key, value); } -void ALEInterface::setBool(const string& key, const bool value) { +void RLEInterface::setBool(const string& key, const bool value) { m_pimpl->setBool(key, value); } -void ALEInterface::setFloat(const string& key, const float value) { +void RLEInterface::setFloat(const string& key, const float value) { m_pimpl->setFloat(key, value); } -ALEInterface::ALEInterface() : m_pimpl(new ALEInterface::Impl()) { +RLEInterface::RLEInterface() : m_pimpl(new RLEInterface::Impl()) { disableBufferedIO(); Logger::Info << welcomeMessage() << std::endl; } -ALEInterface::ALEInterface(const std::string &rom_file, const std::string &core_file) : - ALEInterface(){ +RLEInterface::RLEInterface(const std::string &rom_file, const std::string &core_file) : + RLEInterface(){ loadROM(rom_file, core_file); } -ALEInterface::ALEInterface(bool display_screen) : ALEInterface() { +RLEInterface::RLEInterface(bool display_screen) : RLEInterface() { m_pimpl->setBool("display_screen", display_screen); } -ALEInterface::~ALEInterface() { +RLEInterface::~RLEInterface() { delete m_pimpl; } -void ALEInterface::reset_game() { +void RLEInterface::reset_game() { m_pimpl->reset_game(); } // Resets the game, but not the full system. -void ALEInterface::Impl::reset_game() { +void RLEInterface::Impl::reset_game() { environment->reset(); } -reward_t ALEInterface::act(Action actionA, Action actionB) { +reward_t RLEInterface::act(Action actionA, Action actionB) { return m_pimpl->act(actionA, actionB); } -reward_t ALEInterface::Impl::act(Action actionA, Action actionB) { +reward_t RLEInterface::Impl::act(Action actionA, Action actionB) { reward_t reward = environment->act(actionA, actionB); - if (theAleSystem->p_display_screen != NULL) { - theAleSystem->p_display_screen->display_screen(); - while (theAleSystem->p_display_screen->manual_control_engaged() && !game_over()) { - Action user_action = theAleSystem->p_display_screen->getUserAction(); + if (theRleSystem->p_display_screen != NULL) { + theRleSystem->p_display_screen->display_screen(); + while (theRleSystem->p_display_screen->manual_control_engaged() && !game_over()) { + Action user_action = theRleSystem->p_display_screen->getUserAction(); // Used to reset game manually pressing 'r' implemneted in display screen if (user_action == JOYPAD_SYSTEM_RESET){ environment->reset(); } reward += environment->act(user_action, PLAYER_B | JOYPAD_NOOP); - theAleSystem->p_display_screen->display_screen(); + theRleSystem->p_display_screen->display_screen(); } } return reward; } -// Display ALE welcome message -std::string ALEInterface::welcomeMessage() { +// Display RLE welcome message +std::string RLEInterface::welcomeMessage() { std::ostringstream oss; - oss << "A.L.E: Arcade Learning Environment (version " + oss << "R.L.E: Retro Learning Environment (version " << Version << ")\n" - << "[Powered by Stella]\n" + << "[Based upon the Arcade Learning Environment (A.L.E)]\n" + << "[Powered by LibRetro]\n" << "Use -help for help screen."; return oss.str(); } -void ALEInterface::disableBufferedIO() { +void RLEInterface::disableBufferedIO() { setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdin, NULL, _IONBF, 0); cin.rdbuf()->pubsetbuf(0,0); @@ -311,58 +312,58 @@ void ALEInterface::disableBufferedIO() { cout.sync_with_stdio(); } -void ALEInterface::createAleSystem(std::unique_ptr &theAleSystem, +void RLEInterface::createRleSystem(std::unique_ptr &theRleSystem, std::unique_ptr &theSettings, std::unique_ptr &theRetroAgent) { #if (defined(WIN32) || defined(__MINGW32__)) theRetroAgent.reset(new RetroAgent()); - theAleSystem.reset(new OSystemWin32()); - theSettings.reset(new SettingsWin32(theAleSystem.get())); + theRleSystem.reset(new OSystemWin32()); + theSettings.reset(new SettingsWin32(theRleSystem.get())); #else theRetroAgent.reset(new RetroAgent()); - theAleSystem.reset(new AleSystemUNIX(theRetroAgent.get())); - theSettings.reset(new SettingsUNIX(theAleSystem.get())); + theRleSystem.reset(new RleSystemUNIX(theRetroAgent.get())); + theSettings.reset(new SettingsUNIX(theRleSystem.get())); #endif - theAleSystem->settings().loadConfig(); + theRleSystem->settings().loadConfig(); } -void ALEInterface::loadSettings(const string& romfile, const std::string& corefile, - std::unique_ptr &theAleSystem) { +void RLEInterface::loadSettings(const string& romfile, const std::string& corefile, + std::unique_ptr &theRleSystem) { // Load the configuration from a config file (passed on the command // line), if provided - string configFile = theAleSystem->settings().getString("config", false); + string configFile = theRleSystem->settings().getString("config", false); if (!configFile.empty()) - theAleSystem->settings().loadConfig(configFile.c_str()); + theRleSystem->settings().loadConfig(configFile.c_str()); - theAleSystem->settings().validate(); - theAleSystem->create(); + theRleSystem->settings().validate(); + theRleSystem->create(); if (romfile == "" || !FilesystemNode::fileExists(romfile)) { Logger::Error << "No ROM File specified or the ROM file was not found." << std::endl; exit(1); } - theAleSystem->loadCore(corefile); - theAleSystem->loadRom(romfile); + theRleSystem->loadCore(corefile); + theRleSystem->loadRom(romfile); Logger::Info << "Running ROM file..." << std::endl; - theAleSystem->settings().setString("rom_file", romfile); + theRleSystem->settings().setString("rom_file", romfile); #ifdef __USE_SDL - if(theAleSystem->settings().getBool("display_screen")){ - theAleSystem->p_display_screen = new DisplayScreen(&theAleSystem->getRetroAgent()); + if(theRleSystem->settings().getBool("display_screen")){ + theRleSystem->p_display_screen = new DisplayScreen(&theRleSystem->getRetroAgent()); } #endif //Shai : added format handling for RGB // Must force the resetting of the OSystem's random seed, which is set before we change // choose our random seed. - Logger::Info << "Random seed is " << theAleSystem->settings().getInt("random_seed") << std::endl; - theAleSystem->resetRNGSeed(); + Logger::Info << "Random seed is " << theRleSystem->settings().getInt("random_seed") << std::endl; + theRleSystem->resetRNGSeed(); } -void ALEInterface::loadROM(string rom_file, string core_file) { +void RLEInterface::loadROM(string rom_file, string core_file) { m_pimpl->loadROM(rom_file, core_file); } @@ -370,22 +371,22 @@ void ALEInterface::loadROM(string rom_file, string core_file) { // ready to play. Resets the OSystem/Console/Environment/etc. This is // necessary after changing a setting. Optionally specify a new rom to // load. -void ALEInterface::Impl::loadROM(string rom_file, string core_file) { - assert(theAleSystem.get()); +void RLEInterface::Impl::loadROM(string rom_file, string core_file) { + assert(theRleSystem.get()); if (rom_file.empty()) { - rom_file = theAleSystem->romFile(); + rom_file = theRleSystem->romFile(); } if (core_file.empty()) { - core_file = theAleSystem->coreFile(); + core_file = theRleSystem->coreFile(); } - ALEInterface::loadSettings(rom_file, core_file, theAleSystem); + RLEInterface::loadSettings(rom_file, core_file, theRleSystem); bool twoPlayers = getBool("two_players"); romSettings.reset(buildRomRLWrapper(rom_file, twoPlayers)); - environment.reset(new RetroEnvironment(theAleSystem.get(), romSettings.get())); - max_num_frames = theAleSystem->settings().getInt("max_num_frames_per_episode"); + environment.reset(new RetroEnvironment(theRleSystem.get(), romSettings.get())); + max_num_frames = theRleSystem->settings().getInt("max_num_frames_per_episode"); environment->reset(); #ifndef __USE_SDL - if (theAleSystem->p_display_screen != NULL) { + if (theRleSystem->p_display_screen != NULL) { Logger::Error << "Screen display requires directive __USE_SDL to be defined." << endl; Logger::Error << "Please recompile this code with flag '-D__USE_SDL'." << endl; Logger::Error << "Also ensure ALE has been compiled with USE_SDL active (see ALE makefile)." << endl; @@ -394,157 +395,157 @@ void ALEInterface::Impl::loadROM(string rom_file, string core_file) { #endif } -bool ALEInterface::game_over() const{ +bool RLEInterface::game_over() const{ return m_pimpl->game_over(); } // Indicates if the game has ended. -bool ALEInterface::Impl::game_over() const{ +bool RLEInterface::Impl::game_over() const{ return (environment->isTerminal() || (max_num_frames > 0 && getEpisodeFrameNumber() >= max_num_frames)); } -const int ALEInterface::lives() const { +const int RLEInterface::lives() const { return m_pimpl->lives(); } // The remaining number of lives. -const int ALEInterface::Impl::lives() const{ +const int RLEInterface::Impl::lives() const{ if (!romSettings.get()){ throw std::runtime_error("ROM not set"); } return romSettings->lives(); } -ActionVect ALEInterface::getLegalActionSet() { +ActionVect RLEInterface::getLegalActionSet() { return m_pimpl->getLegalActionSet(); } // TODO SN : replace function with something else since the vector of all legal actions woul dbe too big // Returns the vector of legal actions. This should be called only // after the rom is loaded. -ActionVect ALEInterface::Impl::getLegalActionSet() { +ActionVect RLEInterface::Impl::getLegalActionSet() { if (!romSettings.get()){ throw std::runtime_error("ROM not set"); } return romSettings->getAllActions(); } -ActionVect ALEInterface::getMinimalActionSet() { +ActionVect RLEInterface::getMinimalActionSet() { return m_pimpl->getMinimalActionSet(); } // Returns the vector of the minimal set of actions needed to play // the game. -ActionVect ALEInterface::Impl::getMinimalActionSet() { +ActionVect RLEInterface::Impl::getMinimalActionSet() { if (!romSettings.get()){ throw std::runtime_error("ROM not set"); } return romSettings->getMinimalActionSet(); } -int ALEInterface::getFrameNumber() { +int RLEInterface::getFrameNumber() { return m_pimpl->getFrameNumber(); } // Returns the frame number since the loading of the ROM -int ALEInterface::Impl::getFrameNumber() { +int RLEInterface::Impl::getFrameNumber() { return environment->getFrameNumber(); } -int ALEInterface::getEpisodeFrameNumber() const{ +int RLEInterface::getEpisodeFrameNumber() const{ return m_pimpl->getEpisodeFrameNumber(); } // Returns the frame number since the start of the current episode -int ALEInterface::Impl::getEpisodeFrameNumber() const{ +int RLEInterface::Impl::getEpisodeFrameNumber() const{ return environment->getEpisodeFrameNumber(); } -const ALEScreen& ALEInterface::getScreen() const { +const RLEScreen& RLEInterface::getScreen() const { return m_pimpl->getScreen(); } // Returns the current game screen -const ALEScreen& ALEInterface::Impl::getScreen() const{ +const RLEScreen& RLEInterface::Impl::getScreen() const{ return environment->getScreen(); } -const ALERAM& ALEInterface::getRAM() const{ +const RLERAM& RLEInterface::getRAM() const{ return m_pimpl->getRAM(); } // Returns the current RAM content -const ALERAM& ALEInterface::Impl::getRAM() const{ +const RLERAM& RLEInterface::Impl::getRAM() const{ return environment->getRAM(); } -void ALEInterface::saveState() { +void RLEInterface::saveState() { m_pimpl->saveState(); } // Saves the state of the system -void ALEInterface::Impl::saveState() { +void RLEInterface::Impl::saveState() { environment->save(); } -void ALEInterface::loadState() { +void RLEInterface::loadState() { m_pimpl->loadState(); } // Loads the state of the system -void ALEInterface::Impl::loadState() { +void RLEInterface::Impl::loadState() { environment->load(); } -ALEState ALEInterface::cloneState() { +RLEState RLEInterface::cloneState() { return m_pimpl->cloneState(); } -ALEState ALEInterface::Impl::cloneState() { +RLEState RLEInterface::Impl::cloneState() { return environment->cloneState(); } -void ALEInterface::restoreState(const ALEState& state) { +void RLEInterface::restoreState(const RLEState& state) { return m_pimpl->restoreState(state); } -void ALEInterface::Impl::restoreState(const ALEState& state) { +void RLEInterface::Impl::restoreState(const RLEState& state) { return environment->restoreState(state); } -ALEState ALEInterface::cloneSystemState() { +RLEState RLEInterface::cloneSystemState() { return m_pimpl->cloneSystemState(); } -ALEState ALEInterface::Impl::cloneSystemState() { +RLEState RLEInterface::Impl::cloneSystemState() { return environment->cloneSystemState(); } -void ALEInterface::restoreSystemState(const ALEState& state) { +void RLEInterface::restoreSystemState(const RLEState& state) { return m_pimpl->restoreSystemState(state); } -void ALEInterface::Impl::restoreSystemState(const ALEState& state) { +void RLEInterface::Impl::restoreSystemState(const RLEState& state) { return environment->restoreSystemState(state); } -void ALEInterface::saveScreenPNG(const string& filename) { +void RLEInterface::saveScreenPNG(const string& filename) { m_pimpl->saveScreenPNG(filename); } -void ALEInterface::Impl::saveScreenPNG(const string& filename) { +void RLEInterface::Impl::saveScreenPNG(const string& filename) { -// ScreenExporter exporter(theAleSystem->colourPalette()); +// ScreenExporter exporter(theRleSystem->colourPrlette()); // exporter.save(environment->getScreen(), filename); } -ScreenExporter *ALEInterface::createScreenExporter(const std::string &filename) const { - return m_pimpl->createScreenExporter(filename); -} +//ScreenExporter *RLEInterface::createScreenExporter(const std::string &filename) const { +// return m_pimpl->createScreenExporter(filename); +//} -ScreenExporter *ALEInterface::Impl::createScreenExporter(const std::string &filename) const { -// return new ScreenExporter(theAleSystem->colourPalette(), filename); -} +//ScreenExporter *RLEInterface::Impl::createScreenExporter(const std::string &filename) const { +//// return new ScreenExporter(theRleSystem->colourPrlette(), filename); +//} -} // namespace ale +} // namespace rle diff --git a/src/ale_interface.hpp b/src/rle_interface.hpp similarity index 81% rename from src/ale_interface.hpp rename to src/rle_interface.hpp index 6d55886..a006a82 100644 --- a/src/ale_interface.hpp +++ b/src/rle_interface.hpp @@ -23,12 +23,12 @@ * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team * * ***************************************************************************** - * ale_interface.hpp + * rle_interface.hpp * * The shared library interface. **************************************************************************** */ -#ifndef __ALE_INTERFACE_HPP__ -#define __ALE_INTERFACE_HPP__ +#ifndef __RLE_INTERFACE_HPP__ +#define __RLE_INTERFACE_HPP__ #include #include @@ -38,16 +38,16 @@ #include #include -namespace ale { +namespace rle { static const std::string Version = "0.5.0"; -class AleSystem; +class RleSystem; class Settings; struct pixelFormat; struct RomSettings; class RetroEnvironment; -class ALEState; +class RLEState; class ScreenExporter; class RetroAgent; @@ -88,7 +88,7 @@ typedef uint32_t Action; // Atari actions #define JOYPAD_FIRE JOYPAD_B // for atari -// a list of ALE actions +// a list of RLE actions typedef std::vector ActionVect; // type used to represent insantanteous reward @@ -99,12 +99,12 @@ typedef uint32_t pixel_t; typedef unsigned char byte_t; /** A simple wrapper around an Atari screen. */ -class ALEScreen { +class RLEScreen { public: - ALEScreen(int h, int w); - ALEScreen(const ALEScreen &rhs); - ~ALEScreen(); - ALEScreen& operator=(const ALEScreen &rhs); + RLEScreen(int h, int w); + RLEScreen(const RLEScreen &rhs); + ~RLEScreen(); + RLEScreen& operator=(const RLEScreen &rhs); /** pixel accessors, (row, column)-ordered */ pixel_t get(int r, int c) const; @@ -126,7 +126,7 @@ class ALEScreen { size_t arraySize() const { return m_pixels.size(); } /** Returns whether two screens are equal */ - bool equals(const ALEScreen &rhs) const; + bool equals(const RLEScreen &rhs) const; /** Returns a 32bit pixel in an R|G|B Format, 8 bits each */ pixel_t getRGBPixel(const uint32_t &pixel)const; @@ -143,12 +143,12 @@ class ALEScreen { /** A simple wrapper around the Atari RAM. */ -class ALERAM { +class RLERAM { public: - ALERAM() : m_ram(NULL){} - ALERAM(const ALERAM &rhs); + RLERAM() : m_ram(NULL){} + RLERAM(const RLERAM &rhs); - ALERAM& operator=(const ALERAM &rhs); + RLERAM& operator=(const RLERAM &rhs); /** Byte accessors */ byte_t get(unsigned int x) const; @@ -161,7 +161,7 @@ class ALERAM { size_t size() const { return sizeof(m_ram); } /** Returns whether two copies of the RAM are equal */ - bool equals(const ALERAM &rhs) const; + bool equals(const RLERAM &rhs) const; protected: byte_t* m_ram; @@ -169,28 +169,28 @@ class ALERAM { }; /** - This class interfaces ALE with external code for controlling agents. + This class interfaces RLE with external code for controlling agents. */ -class ALEInterface { +class RLEInterface { public: - /** create an ALEInterface. Cannot create two instances within one thread */ - ALEInterface(); + /** create an RLEInterface. Cannot create two instances within one thread */ + RLEInterface(); - /** create an ALEInterface. Cannot create two instances within one thread */ - ALEInterface(const std::string &rom_file, const std::string &core_file); + /** create an RLEInterface. Cannot create two instances within one thread */ + RLEInterface(const std::string &rom_file, const std::string &core_file); // Legacy constructor - ALEInterface(bool display_screen); + RLEInterface(bool display_screen); /** Unload the emulator. */ - ~ALEInterface(); + ~RLEInterface(); /** Copying is explicitly disallowed. */ - ALEInterface(const ALEInterface &) = delete; + RLEInterface(const RLEInterface &) = delete; /** Assignment is explicitly disallowed. */ - ALEInterface &operator=(const ALEInterface &) = delete; + RLEInterface &operator=(const RLEInterface &) = delete; // Resets the game, but not the full system. void reset_game(); @@ -228,10 +228,10 @@ class ALEInterface { int getEpisodeFrameNumber() const; // Returns the current game screen - const ALEScreen &getScreen() const; + const RLEScreen &getScreen() const; // Returns the current RAM content - const ALERAM &getRAM() const; + const RLERAM &getRAM() const; // Saves the state of the system void saveState(); @@ -241,19 +241,19 @@ class ALEInterface { // This makes a copy of the environment state. This copy does *not* include pseudorandomness, // making it suitable for planning purposes. By contrast, see cloneSystemState. - ALEState cloneState(); + RLEState cloneState(); // Reverse operation of cloneState(). This does not restore pseudorandomness, so that repeated // calls to restoreState() in the stochastic controls setting will not lead to the same outcomes. // By contrast, see restoreSystemState. - void restoreState(const ALEState& state); + void restoreState(const RLEState& state); // This makes a copy of the system & environment state, suitable for serialization. This includes // pseudorandomness and so is *not* suitable for planning purposes. - ALEState cloneSystemState(); + RLEState cloneSystemState(); // Reverse operation of cloneSystemState. - void restoreSystemState(const ALEState& state); + void restoreSystemState(const RLEState& state); // Save the current screen as a png file void saveScreenPNG(const std::string& filename); @@ -261,33 +261,33 @@ class ALEInterface { // Creates a ScreenExporter object which can be used to save a sequence of frames. Ownership // said object is passed to the caller. Frames are saved in the directory 'path', which needs // to exists. - ScreenExporter *createScreenExporter(const std::string &path) const; - - // Get the value of a setting. - std::string getString(const std::string& key); - int getInt(const std::string& key); - bool getBool(const std::string& key); - float getFloat(const std::string& key); - - // Set the value of a setting. loadRom() must be called before the - // setting will take effect. - void setString(const std::string& key, const std::string& value); - void setInt(const std::string& key, const int value); - void setBool(const std::string& key, const bool value); - void setFloat(const std::string& key, const float value); - - // Display ALE welcome message +// ScreenExporter *createScreenExporter(const std::string &path) const; + + // Get the value of a setting. + std::string getString(const std::string& key); + int getInt(const std::string& key); + bool getBool(const std::string& key); + float getFloat(const std::string& key); + + // Set the value of a setting. loadRom() must be called before the + // setting will take effect. + void setString(const std::string& key, const std::string& value); + void setInt(const std::string& key, const int value); + void setBool(const std::string& key, const bool value); + void setFloat(const std::string& key, const float value); + + // Display RLE welcome message static std::string welcomeMessage(); static void disableBufferedIO(); - static void createAleSystem(std::unique_ptr &theAleSystem, + static void createRleSystem(std::unique_ptr &theRleSystem, std::unique_ptr &theSettings, std::unique_ptr &theRetroAgent); static void loadSettings(const std::string& romfile, const std::string& corefile, - std::unique_ptr &theSLESystem); + std::unique_ptr &theSLESystem); private: class Impl; Impl* m_pimpl; }; -} // namespace ale -#endif // __ALE_INTERFACE_HPP__ +} // namespace rle +#endif // __RLE_INTERFACE_HPP__ diff --git a/test/RetroAgentTest.cpp b/test/RetroAgentTest.cpp index 916c20b..aef1251 100644 --- a/test/RetroAgentTest.cpp +++ b/test/RetroAgentTest.cpp @@ -15,7 +15,7 @@ #include "gtest/gtest.h" namespace { -using namespace ale; +using namespace rle; // The fixture for testing class Foo. class RetroAgentTest : public ::testing::Test { protected: diff --git a/test/RleTest.cpp b/test/RleTest.cpp index 16c2d09..35511ed 100644 --- a/test/RleTest.cpp +++ b/test/RleTest.cpp @@ -7,13 +7,13 @@ #include #include -#include "ale_interface.hpp" +#include "rle_interface.hpp" #include "gtest/gtest.h" -#include "common/AleException.h" +#include "common/RleException.h" namespace { -using namespace ale; +using namespace rle; using std::string; // The fixture for testing class Foo. class RleTest : public ::testing::Test { @@ -25,30 +25,30 @@ class RleTest : public ::testing::Test { }; TEST_F(RleTest, simpleCtor) { - ale::ALEInterface ale; + rle::RLEInterface rle; } -static void run_example(ALEInterface* ale, string romPath, string corePath){ - ale->loadROM(romPath, corePath); - ActionVect legal_actions = ale->getMinimalActionSet(); +static void run_example(RLEInterface* rle, string romPath, string corePath){ + rle->loadROM(romPath, corePath); + ActionVect legal_actions = rle->getMinimalActionSet(); for (int episode=0; episode<1; ++episode) { int steps(0); - while (!ale->game_over() && steps < 100) { + while (!rle->game_over() && steps < 100) { Action a = legal_actions[rand() % legal_actions.size()]; - ale->act(a); + rle->act(a); ++steps; } - ale->reset_game(); + rle->reset_game(); } } TEST_F(RleTest, multiThreading) { int numThreads(8); - ale::ALEInterface ale[numThreads]; + rle::RLEInterface rle[numThreads]; std::vector threads; for(int i(0); i < numThreads; ++i){ - threads.push_back(std::thread(run_example, &ale[i], romPath, corePath)); + threads.push_back(std::thread(run_example, &rle[i], romPath, corePath)); } for (auto& th : threads){ th.join(); @@ -56,38 +56,38 @@ TEST_F(RleTest, multiThreading) { } TEST_F(RleTest, runTwoAgentsNoDelete) { - ale::ALEInterface ale; - run_example(&ale, romPath, corePath); - ale::ALEInterface ale2; - ale.getEpisodeFrameNumber(); + rle::RLEInterface rle; + run_example(&rle, romPath, corePath); + rle::RLEInterface rle2; + rle.getEpisodeFrameNumber(); } TEST_F(RleTest, runTwoAgentsNoDeleteWithDoubleInit) { - ale::ALEInterface ale; - run_example(&ale, romPath, corePath); - ale::ALEInterface ale2; - run_example(&ale2, romPath, corePath); - ale.getEpisodeFrameNumber(); + rle::RLEInterface rle; + run_example(&rle, romPath, corePath); + rle::RLEInterface rle2; + run_example(&rle2, romPath, corePath); + rle.getEpisodeFrameNumber(); } TEST_F(RleTest, runTwoAgentsWithDelete) { - auto ale = new ale::ALEInterface(); - run_example(ale, romPath, corePath); - delete ale; + auto rle = new rle::RLEInterface(); + run_example(rle, romPath, corePath); + delete rle; - ale::ALEInterface ale2; - run_example(&ale2, romPath, corePath); + rle::RLEInterface rle2; + run_example(&rle2, romPath, corePath); } TEST_F(RleTest, serialization) { - ale::ALEInterface ale; - run_example(&ale, romPath, corePath); -// ALEState stateA = ale.cloneSystemState(); -// ALEState stateB = ale.cloneSystemState(); + rle::RLEInterface rle; + run_example(&rle, romPath, corePath); +// RLEState stateA = rle.cloneSystemState(); +// RLEState stateB = rle.cloneSystemState(); // EXPECT_EQ(stateA, stateB); - ale.saveState(); -// ale.loadState(); + rle.saveState(); +// rle.loadState(); } diff --git a/test/rleCInterfaceTest.cpp b/test/rleCInterfaceTest.cpp index ae697c5..e972d57 100644 --- a/test/rleCInterfaceTest.cpp +++ b/test/rleCInterfaceTest.cpp @@ -5,7 +5,7 @@ * Author: nadav */ -#include "ale_c_wrapper.h" +#include "rle_c_wrapper.h" #include "gtest/gtest.h" namespace { @@ -14,47 +14,47 @@ class RleCInterfaceTest : public ::testing::Test { }; TEST_F(RleCInterfaceTest, simpleCtorDtor) { - ALEInterface* ale = ALE_new(); - ALE_del(ale); + RLEInterface* rle = RLE_new(); + RLE_del(rle); } //TEST_F(RleCInterfaceTest, getScreenRGB) { -// ALEInterface *ale = ALE_new(); -// loadROM(ale,"/home/administrator/DQN/roms/mortal_kombat.sfc", "/home/administrator/DQN/tempDQN/Arcade-Learning-Environment-2.0/snes9x-next/snes9x_next_libretro.so"); -// reset_game(ale); +// RLEInterface *rle = RLE_new(); +// loadROM(rle,"/home/administrator/DQN/roms/mortal_kombat.sfc", "/home/administrator/DQN/tempDQN/Arcade-Learning-Environment-2.0/snes9x-next/snes9x_next_libretro.so"); +// reset_game(rle); // for(int i = 0; i < 50; ++i){ -// act(ale, (Action)JOYPAD_NOOP,(Action)JOYPAD_NOOP); +// act(rle, (Action)JOYPAD_NOOP,(Action)JOYPAD_NOOP); // } -// int height = getScreenHeight(ale); -// int width = getScreenWidth(ale); +// int height = getScreenHeight(rle); +// int width = getScreenWidth(rle); // uint8_t* output_buffer = new uint8_t[height * width]; -// getScreenRGB(ale,output_buffer); +// getScreenRGB(rle,output_buffer); //} -void loadAndPlay(ALEInterface* ale){ - loadROM(ale,"/home/nadav/DQN/roms/mortal_kombat.sfc", "/home/nadav/DQN/Arcade-Learning-Environment-2.0/snes9x2010/snes9x2010_libretro.so"); - reset_game(ale); +void loadAndPlay(RLEInterface* rle){ + loadROM(rle,"/home/nadav/DQN/roms/mortal_kombat.sfc", "/home/nadav/DQN/Arcade-Learning-Environment-2.0/snes9x2010/snes9x2010_libretro.so"); + reset_game(rle); for(int i = 0; i < 50; ++i){ - act(ale, (Action)JOYPAD_NOOP,(Action)JOYPAD_NOOP); + act(rle, (Action)JOYPAD_NOOP,(Action)JOYPAD_NOOP); } } -TEST_F(RleCInterfaceTest, getScreenGrayscale) { - ALEInterface *ale = ALE_new(); - loadAndPlay(ale); - int height = getScreenHeight(ale); - int width = getScreenWidth(ale); +TEST_F(RleCInterfaceTest, getScreenGrayscrle) { + RLEInterface *rle = RLE_new(); + loadAndPlay(rle); + int height = getScreenHeight(rle); + int width = getScreenWidth(rle); uint8_t* output_buffer = new uint8_t[height * width]; - getScreenGrayscale(ale,output_buffer); - ALE_del(ale); + getScreenGrayscrle(rle,output_buffer); + RLE_del(rle); } TEST_F(RleCInterfaceTest, setBool) { - ALEInterface* ale = ALE_new(); - setBool(ale, "display_screen", true); - loadAndPlay(ale); - reset_game(ale); - ALE_del(ale); + RLEInterface* rle = RLE_new(); + setBool(rle, "display_screen", true); + loadAndPlay(rle); + reset_game(rle); + RLE_del(rle); }