├── priv ├── unsupported.bin └── tetris.bin ├── test ├── test_helper.exs ├── alex │ └── rom_test.exs └── alex_test.exs ├── assets └── alex.gif ├── src └── ale │ ├── libale.so │ ├── src │ ├── common │ │ ├── stella.png │ │ ├── Log.cpp │ │ ├── module.mk │ │ ├── Log.hpp │ │ ├── Version.hxx │ │ ├── stella.xpm │ │ ├── ScreenExporter.hpp │ │ ├── SoundExporter.hpp │ │ ├── Constants.cpp │ │ ├── SoundNull.cxx │ │ ├── SoundExporter.cpp │ │ ├── misc_tools.h │ │ └── display_screen.h │ ├── module.mk │ ├── external │ │ ├── module.mk │ │ └── TinyMT │ │ │ └── LICENSE.txt │ ├── environment │ │ ├── module.mk │ │ ├── stella_environment_wrapper.cpp │ │ ├── phosphor_blend.hpp │ │ ├── stella_environment_wrapper.hpp │ │ └── ale_ram.hpp │ ├── os_dependent │ │ ├── module.mk │ │ ├── SettingsWin32.hxx │ │ ├── SettingsUNIX.cxx │ │ ├── SettingsUNIX.hxx │ │ ├── SettingsWin32.cxx │ │ ├── OSystemUNIX.hxx │ │ ├── OSystemWin32.hxx │ │ ├── OSystemWin32.cxx │ │ └── OSystemUNIX.cxx │ ├── controllers │ │ ├── module.mk │ │ ├── ale_controller.hpp │ │ ├── fifo_controller.hpp │ │ └── ale_controller.cpp │ ├── emucore │ │ ├── rsynth │ │ │ ├── phones.h │ │ │ ├── phtoelm.h │ │ │ ├── module.mk │ │ │ ├── useconfig.h │ │ │ ├── phfeat.h │ │ │ ├── trie.h │ │ │ ├── phones.c │ │ │ ├── kmap │ │ │ ├── elements.c │ │ │ ├── PORTING │ │ │ └── trie.c │ │ ├── m6502 │ │ │ ├── module.mk │ │ │ ├── src │ │ │ │ ├── Device.cxx │ │ │ │ ├── bspf │ │ │ │ │ └── Copyright.txt │ │ │ │ └── NullDev.cxx │ │ │ └── Copyright.txt │ │ ├── MD5.hxx │ │ ├── MediaSrc.cxx │ │ ├── module.mk │ │ ├── Switches.hxx │ │ ├── Control.cxx │ │ ├── Event.cxx │ │ ├── Serializer.cxx │ │ ├── Random.hxx │ │ ├── Deserializer.cxx │ │ ├── Joystick.hxx │ │ ├── Keyboard.hxx │ │ ├── Booster.hxx │ │ ├── Joystick.cxx │ │ ├── Deserializer.hxx │ │ ├── Driving.hxx │ │ └── Paddles.hxx │ └── games │ │ ├── Roms.hpp │ │ ├── RomUtils.hpp │ │ ├── supported │ │ ├── Koolaid.hpp │ │ ├── Kaboom.hpp │ │ ├── DonkeyKong.hpp │ │ ├── Trondead.hpp │ │ ├── LaserGates.hpp │ │ ├── SirLancelot.hpp │ │ ├── KeystoneKapers.hpp │ │ ├── MrDo.hpp │ │ ├── Frogger.hpp │ │ ├── Turmoil.hpp │ │ ├── AirRaid.hpp │ │ ├── LostLuggage.hpp │ │ ├── Carnival.cpp │ │ ├── Kaboom.cpp │ │ ├── Koolaid.cpp │ │ ├── Tetris.hpp │ │ ├── Carnival.hpp │ │ ├── Krull.hpp │ │ ├── Phoenix.hpp │ │ ├── Solaris.hpp │ │ ├── Enduro.hpp │ │ ├── SirLancelot.cpp │ │ ├── Assault.hpp │ │ ├── RoboTank.hpp │ │ ├── RoadRunner.hpp │ │ ├── KungFuMaster.hpp │ │ ├── Pitfall.hpp │ │ ├── Skiing.hpp │ │ ├── MontezumaRevenge.hpp │ │ ├── Asterix.hpp │ │ ├── ElevatorAction.hpp │ │ └── Boxing.hpp │ │ └── RomSettings.cpp │ ├── ale.cfg │ ├── README-SDL.txt │ ├── common.rules │ └── Copyright.txt ├── .formatter.exs ├── .travis.yml ├── CHANGELOG.md ├── .gitignore ├── guides ├── installation.md ├── configuration.md └── getting-started.md ├── examples └── random_agent.exs ├── lib └── alex │ ├── ram.ex │ ├── state.ex │ └── screen.ex └── README.md /priv/unsupported.bin: -------------------------------------------------------------------------------- 1 | For test purposes only. -------------------------------------------------------------------------------- /test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /assets/alex.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seanmor5/alex/HEAD/assets/alex.gif -------------------------------------------------------------------------------- /priv/tetris.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seanmor5/alex/HEAD/priv/tetris.bin -------------------------------------------------------------------------------- /src/ale/libale.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seanmor5/alex/HEAD/src/ale/libale.so -------------------------------------------------------------------------------- /src/ale/src/common/stella.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seanmor5/alex/HEAD/src/ale/src/common/stella.png -------------------------------------------------------------------------------- /.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: elixir 2 | 3 | elixir: 4 | - 1.10.0 5 | 6 | otp_release: 7 | - 22.0 8 | 9 | env: 10 | - MIX_ENV=test 11 | 12 | script: mix coveralls.travis -------------------------------------------------------------------------------- /src/ale/src/module.mk: -------------------------------------------------------------------------------- 1 | MODULE := src/ 2 | 3 | MODULE_OBJS := \ 4 | src/main.o \ 5 | src/ale_interface.o 6 | 7 | MODULE_DIRS += \ 8 | src/ 9 | 10 | # Include common rules 11 | include $(srcdir)/common.rules 12 | -------------------------------------------------------------------------------- /src/ale/src/external/module.mk: -------------------------------------------------------------------------------- 1 | MODULE := src/external 2 | 3 | MODULE_OBJS := \ 4 | src/external/TinyMT/tinymt32.o \ 5 | 6 | MODULE_DIRS += \ 7 | src/external/TinyMT 8 | 9 | # Include common rules 10 | include $(srcdir)/common.rules 11 | -------------------------------------------------------------------------------- /src/ale/src/environment/module.mk: -------------------------------------------------------------------------------- 1 | MODULE := src/environment 2 | 3 | MODULE_OBJS := \ 4 | src/environment/ale_state.o \ 5 | src/environment/stella_environment.o \ 6 | src/environment/phosphor_blend.o \ 7 | 8 | MODULE_DIRS += \ 9 | src/environment 10 | 11 | # Include common rules 12 | include $(srcdir)/common.rules 13 | -------------------------------------------------------------------------------- /src/ale/src/os_dependent/module.mk: -------------------------------------------------------------------------------- 1 | MODULE := src/os_dependent 2 | 3 | MODULE_OBJS := \ 4 | src/os_dependent/FSNodePOSIX.o \ 5 | src/os_dependent/OSystemUNIX.o \ 6 | src/os_dependent/SettingsUNIX.o \ 7 | 8 | MODULE_DIRS += \ 9 | src/os_dependent 10 | 11 | # Include common rules 12 | include $(srcdir)/common.rules 13 | -------------------------------------------------------------------------------- /src/ale/src/controllers/module.mk: -------------------------------------------------------------------------------- 1 | MODULE := src/controllers 2 | 3 | MODULE_OBJS := \ 4 | src/controllers/ale_controller.o \ 5 | src/controllers/fifo_controller.o \ 6 | src/controllers/rlglue_controller.o \ 7 | 8 | MODULE_DIRS += \ 9 | src/controllers 10 | 11 | # Include common rules 12 | include $(srcdir)/common.rules 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v0.1.0 2 | 3 | # v0.2.0 4 | * Changed location of libale_c target to `priv`. 5 | * Changes to `mix.exs` due to compilation issues. 6 | 7 | # v0.3.0 8 | * Fixed double compilation bug. 9 | * Stopped shipping libale_c with package which caused compilation to fail. 10 | * Added Safety Checks to `get_` and `set_` NIFs so they no longer SegFault when given bad arguments. -------------------------------------------------------------------------------- /src/ale/ale.cfg: -------------------------------------------------------------------------------- 1 | # Use this file to set default options for ALE. 2 | # One setting per line. 3 | # Format: option-name=option-value 4 | # 5 | # Example. 6 | # 7 | # cpu=low 8 | # repeat_action_probability=0.25 9 | # 10 | # Note that, for the Python and C++ interface, these options are set when the interface is 11 | # first created (i.e. within ALEInterface's constructor), and not when the ROM is loaded. 12 | -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/phones.h: -------------------------------------------------------------------------------- 1 | #ifndef __PHONES_H 2 | #define __PHONES_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define PHONE(nm,st,br,am,ex) nm 9 | enum phone_e { SIL, 10 | #include "phones.def" 11 | END }; 12 | #undef PHONE 13 | extern char *ph_name[]; 14 | extern char *ph_br[]; 15 | extern char *ph_am[]; 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/ale/src/common/Log.cpp: -------------------------------------------------------------------------------- 1 | #include "Log.hpp" 2 | 3 | #include 4 | 5 | namespace ale { 6 | 7 | Logger::mode Logger::current_mode = Info; 8 | 9 | void Logger::setMode(Logger::mode m) { current_mode = m; } 10 | 11 | Logger::mode operator<<(Logger::mode log, std::ostream& (*manip)(std::ostream&)) { 12 | if (log >= Logger::current_mode) { 13 | manip(std::cerr); 14 | } 15 | return log; 16 | } 17 | 18 | } // namespace ale 19 | -------------------------------------------------------------------------------- /src/ale/src/common/module.mk: -------------------------------------------------------------------------------- 1 | MODULE := src/common 2 | 3 | MODULE_OBJS := \ 4 | src/common/SoundNull.o \ 5 | src/common/SoundSDL.o \ 6 | src/common/SoundExporter.o \ 7 | src/common/display_screen.o \ 8 | src/common/ColourPalette.o \ 9 | src/common/ScreenExporter.o \ 10 | src/common/Constants.o \ 11 | src/common/Log.o 12 | 13 | MODULE_DIRS += \ 14 | src/common 15 | 16 | # Include common rules 17 | include $(srcdir)/common.rules 18 | -------------------------------------------------------------------------------- /src/ale/src/emucore/m6502/module.mk: -------------------------------------------------------------------------------- 1 | MODULE := src/emucore/m6502 2 | 3 | MODULE_OBJS := \ 4 | src/emucore/m6502/src/Device.o \ 5 | src/emucore/m6502/src/M6502.o \ 6 | src/emucore/m6502/src/M6502Low.o \ 7 | src/emucore/m6502/src/M6502Hi.o \ 8 | src/emucore/m6502/src/NullDev.o \ 9 | src/emucore/m6502/src/System.o 10 | 11 | MODULE_DIRS += \ 12 | src/emucore/m6502/src 13 | 14 | # Include common rules 15 | include $(srcdir)/common.rules 16 | -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/phtoelm.h: -------------------------------------------------------------------------------- 1 | /* $Id: phtoelm.h,v 1.2 2006/06/11 21:49:09 stephena Exp $ 2 | */ 3 | #ifndef __PHTOELM_H 4 | #define __PHTOELM_H 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | struct rsynth_s; 11 | extern unsigned phone_to_elm (char *s, int n, darray_ptr elm, darray_ptr f0); 12 | extern void say_pho(struct rsynth_s *rsynth, const char *path, int dodur,char *phoneset); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/ale/README-SDL.txt: -------------------------------------------------------------------------------- 1 | Please distribute this file with the SDL runtime environment: 2 | 3 | The Simple DirectMedia Layer (SDL for short) is a cross-platfrom library 4 | designed to make it easy to write multi-media software, such as games and 5 | emulators. 6 | 7 | The Simple DirectMedia Layer library source code is available from: 8 | http://www.libsdl.org/ 9 | 10 | This library is distributed under the terms of the GNU LGPL license: 11 | http://www.gnu.org/copyleft/lesser.html 12 | -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/module.mk: -------------------------------------------------------------------------------- 1 | MODULE := src/emucore/rsynth 2 | 3 | MODULE_OBJS := \ 4 | src/emucore/rsynth/darray.o \ 5 | src/emucore/rsynth/elements.o \ 6 | src/emucore/rsynth/holmes.o \ 7 | src/emucore/rsynth/opsynth.o \ 8 | src/emucore/rsynth/phones.o \ 9 | src/emucore/rsynth/phtoelm.o \ 10 | src/emucore/rsynth/trie.o 11 | 12 | MODULE_DIRS += \ 13 | src/emucore/rsynth 14 | 15 | # Include common rules 16 | include $(srcdir)/common.rules 17 | -------------------------------------------------------------------------------- /test/alex/rom_test.exs: -------------------------------------------------------------------------------- 1 | defmodule ROMTest do 2 | import Alex.ROM 3 | use ExUnit.Case 4 | 5 | describe "rom" do 6 | test "rom_exists?/1" do 7 | path_to_rom = "priv/tetris.bin" 8 | assert :ok = rom_exists?(path_to_rom) 9 | assert {:error, err} = rom_exists?("bad") 10 | end 11 | 12 | test "rom_supported?/1" do 13 | path_to_rom = "priv/tetris.bin" 14 | assert :ok = rom_supported?(path_to_rom) 15 | assert {:error, err} = rom_supported?("priv/unsupported.bin") 16 | end 17 | end 18 | end -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build/ 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover/ 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps/ 9 | 10 | # Where third-party dependencies like ExDoc output generated docs. 11 | /doc/ 12 | 13 | # Ignore .fetch files in case you like to edit your project deps locally. 14 | /.fetch 15 | 16 | # If the VM crashes, it generates a dump, let's ignore it too. 17 | erl_crash.dump 18 | 19 | # Also ignore archive artifacts (built via "mix archive.build"). 20 | *.ez 21 | 22 | # Ignore package tarball (built via "mix hex.build"). 23 | alex-*.tar 24 | 25 | /src/ale/build 26 | 27 | /priv/alex 28 | -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/useconfig.h: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_SYS_TYPES_H 2 | #include 3 | #endif 4 | 5 | #if STDC_HEADERS 6 | #include 7 | #include 8 | #include 9 | #else 10 | #ifndef HAVE_STRCHR 11 | #define strchr index 12 | #define strrchr rindex 13 | #endif 14 | char *strchr (), *strrchr (); 15 | #ifndef HAVE_MEMCPY 16 | #define memcpy(d, s, n) bcopy ((s), (d), (n)) 17 | #endif 18 | #ifdef HAVE_MALLOC_H 19 | #include 20 | #endif 21 | #endif /* STDC_HEADERS */ 22 | 23 | #if HAVE_UNISTD_H 24 | #include 25 | #endif 26 | 27 | #if HAVE_LIBC_H 28 | /* From NeXT stuff */ 29 | #include 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /guides/installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | ## Install Dependencies 4 | 5 | The ALE requires [CMake](https://cmake.org/) and [SDL](https://www.libsdl.org/). You need to install them before compiling ALEx. 6 | 7 | ### Linux 8 | 9 | ``` 10 | $ sudo apt-get install libsdl1.2-dev libsdl-gfx1.2-dev libsdl-image1.2-dev cmake 11 | ``` 12 | 13 | ### Mac 14 | 15 | ``` 16 | $ brew install cmake 17 | $ brew install sdl 18 | ``` 19 | 20 | ### Windows 21 | 22 | ALEx hasn't been tested on Windows yet. Sorry :( 23 | 24 | ## Add to Mix 25 | 26 | Add `alex` to your dependencies: 27 | 28 | ``` 29 | defp deps do 30 | {:alex, "~> 0.3.1"} 31 | end 32 | ``` 33 | 34 | ## Compile 35 | 36 | Run `mix deps.get, deps.compile`. 37 | 38 | The first compilation will take quite a bit of time as the ALE compiles. After that you should be good to go! -------------------------------------------------------------------------------- /examples/random_agent.exs: -------------------------------------------------------------------------------- 1 | # Create new Alex interface 2 | interface = Alex.new() 3 | 4 | # Set Initialization Options 5 | interface = 6 | interface 7 | |> Alex.set_option(:display_screen, true) 8 | |> Alex.set_option(:sound, true) 9 | |> Alex.set_option(:random_seed, 123) 10 | 11 | # Load the ROM 12 | tetris = Alex.load(interface, "priv/tetris.bin") 13 | 14 | # Define an Episode 15 | episode = 16 | fn game, episode -> 17 | if Alex.game_over?(game) do 18 | game 19 | else 20 | game = Alex.step(game, Enum.random(game.legal_actions)) 21 | episode.(game, episode) 22 | end 23 | end 24 | 25 | # Run the Game and Store Object 26 | tetris = episode.(tetris, episode) 27 | 28 | # Take a Screenshot of Final Screen 29 | Alex.screenshot(tetris) 30 | 31 | # Output Result 32 | IO.write("\nEpisode ended with score: #{tetris.reward}\n") -------------------------------------------------------------------------------- /src/ale/src/environment/stella_environment_wrapper.cpp: -------------------------------------------------------------------------------- 1 | #include "stella_environment_wrapper.hpp" 2 | 3 | #include "stella_environment.hpp" 4 | 5 | namespace ale { 6 | 7 | StellaEnvironmentWrapper::StellaEnvironmentWrapper( 8 | StellaEnvironment& environment) 9 | : m_environment(environment) {} 10 | 11 | reward_t StellaEnvironmentWrapper::act(Action player_a_action, 12 | Action player_b_action) { 13 | return m_environment.act(player_a_action, player_b_action); 14 | } 15 | 16 | void StellaEnvironmentWrapper::softReset() { m_environment.softReset(); } 17 | 18 | void StellaEnvironmentWrapper::pressSelect(size_t num_steps) { 19 | m_environment.pressSelect(num_steps); 20 | } 21 | 22 | Random& StellaEnvironmentWrapper::getSystemRng() { 23 | return m_environment.getSystemRng(); 24 | } 25 | 26 | } // namespace ale 27 | -------------------------------------------------------------------------------- /lib/alex/ram.ex: -------------------------------------------------------------------------------- 1 | defmodule Alex.RAM do 2 | alias Alex.Interface 3 | alias __MODULE__, as: RAM 4 | @moduledoc """ 5 | Convenience functions for working with ALE RAM. 6 | """ 7 | 8 | @typedoc """ 9 | Abstraction around ALE RAM. 10 | 11 | ## Fields 12 | 13 | - `:contents`: RAM contents. 14 | - `:size`: RAM size. 15 | """ 16 | @type t :: %__MODULE__{ 17 | contents: Enum.t(), 18 | size: integer() 19 | } 20 | defstruct [:contents, :size] 21 | 22 | @doc """ 23 | Creates a new RAM struct. 24 | 25 | Returns `%Alex.RAM{}`. 26 | 27 | # Parameters 28 | 29 | - `interface`: `%Alex.Interface{}`. 30 | """ 31 | def new(%Interface{} = interface) do 32 | ale_ref = interface.ref 33 | with {:ok, ram} <- Interface.get_ram(ale_ref), 34 | {:ok, ram_size} <- Interface.get_ram_size(ale_ref) do 35 | {:ok, %RAM{contents: ram, size: ram_size}} 36 | else 37 | err -> raise err 38 | end 39 | end 40 | end -------------------------------------------------------------------------------- /src/ale/src/games/Roms.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __ROMS_HPP__ 14 | #define __ROMS_HPP__ 15 | 16 | #include 17 | 18 | #include "RomSettings.hpp" 19 | 20 | namespace ale { 21 | 22 | // looks for the RL wrapper corresponding to a particular rom title 23 | RomSettings* buildRomRLWrapper(const std::string& rom); 24 | 25 | } // namespace ale 26 | 27 | #endif // __ROMS_HPP__ 28 | -------------------------------------------------------------------------------- /src/ale/src/common/Log.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __LOG_HPP__ 2 | #define __LOG_HPP__ 3 | 4 | #include 5 | 6 | namespace ale { 7 | 8 | class Logger { 9 | public: 10 | enum mode { Info = 0, Warning = 1, Error = 2 }; 11 | /** @brief Allow to change the level of verbosity 12 | * @param m Info will print all the messages, Warning only the important ones 13 | * and Error the critical ones 14 | */ 15 | static void setMode(mode m); 16 | 17 | private: 18 | static mode current_mode; 19 | friend mode operator<<(mode, std::ostream& (*manip)(std::ostream&)); 20 | template friend mode operator<<(mode, const T&); 21 | }; 22 | 23 | Logger::mode operator<<(Logger::mode log, 24 | std::ostream& (*manip)(std::ostream&)); 25 | 26 | template Logger::mode operator<<(Logger::mode log, const T& val) { 27 | if (log >= Logger::current_mode) std::cerr << val; 28 | return log; 29 | } 30 | 31 | } // namespace ale 32 | 33 | #endif // __LOG_HPP__ 34 | -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/phfeat.h: -------------------------------------------------------------------------------- 1 | #ifndef __PHFEAT_H 2 | #define __PHFEAT_H 3 | 4 | #define unr 0x00000000 5 | #define rnd 0x00000001 6 | #define low 0x00000002 7 | #define lmd 0x00000004 8 | #define mdl 0x00000008 9 | #define smh 0x00000010 10 | #define lax 0x00000020 11 | #define hgh 0x00000040 12 | #define bck 0x00000080 13 | #define cnt 0x00000100 14 | #define fnt 0x00000200 15 | #define vwl 0x00000400 16 | #define dip 0x00000800 17 | #define blb 0x00001000 18 | #define stl 0x00002000 19 | #define vls 0x00004000 20 | #define stp 0x00008000 21 | #define vcd 0x00010000 22 | #define alv 0x00020000 23 | #define vel 0x00040000 24 | #define glt 0x00080000 25 | #define nas 0x00100000 26 | #define tap 0x00200000 27 | #define apr 0x00400000 28 | #define rzd 0x00800000 29 | #define frc 0x01000000 30 | #define lbd 0x02000000 31 | #define dnt 0x04000000 32 | #define pla 0x08000000 33 | #define lat 0x10000000 34 | #define gld 0x20000000 35 | #define lbv 0x40000000 36 | #define pal 0x80000000 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/ale/src/common/Version.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Version.hxx,v 1.29 2007/08/27 13:58:41 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef VERSION_HXX 20 | #define VERSION_HXX 21 | 22 | #define STELLA_BASE_VERSION "2.4.2" 23 | 24 | #ifdef NIGHTLY_BUILD 25 | #define STELLA_VERSION STELLA_BASE_VERSION "pre-" NIGHTLY_BUILD 26 | #else 27 | #define STELLA_VERSION STELLA_BASE_VERSION 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/alex/state.ex: -------------------------------------------------------------------------------- 1 | defmodule Alex.State do 2 | alias Alex.Interface 3 | alias __MODULE__, as: State 4 | 5 | @moduledoc """ 6 | Convenience functions for working with state. 7 | """ 8 | 9 | @typedoc """ 10 | Abstraction around ALE state. 11 | 12 | ## Fields 13 | 14 | - `:ref`: Reference to ALE state. 15 | - `:encoded`: Encoded version of ALE state. 16 | - `:length`: Length of encoded state. 17 | """ 18 | @type t :: %__MODULE__{ 19 | ref: reference(), 20 | encoded: Enum.t(), 21 | length: integer() 22 | } 23 | defstruct ref: nil, encoded: nil, length: 0 24 | 25 | @doc """ 26 | Create a new state struct from provided state reference. 27 | 28 | Returns `%State{}`. 29 | 30 | # Parameters 31 | 32 | - `state`: Reference to state. 33 | """ 34 | def new(%Interface{} = interface) do 35 | ale_ref = interface.ref 36 | 37 | with {:ok, state} <- Interface.clone_state(ale_ref), 38 | {:ok, encoded} <- Interface.encode_state(state), 39 | {:ok, length} <- Interface.encode_state_len(state) do 40 | {:ok, %State{ref: state, encoded: encoded, length: length}} 41 | else 42 | err -> raise err 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /guides/configuration.md: -------------------------------------------------------------------------------- 1 | # Configuration 2 | 3 | The ALE has a number of configuration options you can set to change the runtime experience. 4 | 5 | ## Initialization Options 6 | 7 | When you first create your an Interface with `Alex.new/1`, you can add the following options: 8 | 9 | - `:display_screen`: `true` or `false` to display screen. Defaults to `false`. 10 | - `:random_seed`: `Integer` ALE random seed. Defaults to current time. 11 | - `:sound`: `true` or `false` to play sound. Defaults to `false`. 12 | 13 | ## Environment Options 14 | 15 | Once you've loaded a ROM, you can set a number of environment options: 16 | 17 | - `:repeat_action_probability`: `Float` probability that agent will repeat action in next frame regardless of it's choice. Defaults to 0. 18 | - `:color_averaging`: `true` or `false` to enable color averaging. Defaults to `false`. 19 | - `:max_num_frames`: `Integer` maximum frames to run. Defaults to `0` or no max. 20 | - `:max_num_frames_per_episode`: maximum frames to run per episode. Defaults to `0` or no max. 21 | - `:frame_skip`: `Integer` frame skipping rate. Defaults to `1` or no skip. 22 | - `:difficulty`: `Integer` game difficulty. Defaults to `0`. 23 | - `:mode`: `Integer` game mode. Defaults to `0`. 24 | 25 | -------------------------------------------------------------------------------- /src/ale/common.rules: -------------------------------------------------------------------------------- 1 | # Common build rules, used by the sub modules and their module.mk files 2 | 3 | # Copy the list of objects to a new variable. The name of the new variable 4 | # contains the module name, a trick we use so we can keep multiple different 5 | # module object lists, one for each module. 6 | MODULE_OBJS-$(MODULE) := $(MODULE_OBJS) 7 | 8 | MODULE_LIB-$(MODULE) := $(MODULE)/lib$(notdir $(MODULE)).a 9 | 10 | # If not building as a plugin, add the object files to the main OBJS list 11 | #OBJS += $(MODULE_LIB-$(MODULE)) 12 | OBJS += $(MODULE_OBJS) 13 | 14 | # Convenience library target 15 | #$(MODULE_LIB-$(MODULE)): $(MODULE_OBJS) 16 | # -$(RM) $@ 17 | # $(AR) $@ $+ 18 | # $(RANLIB) $@ 19 | 20 | # Pseudo target for comfort, allows for "make common", "make gui" etc. 21 | #$(MODULE): $(MODULE_LIB-$(MODULE)) 22 | 23 | 24 | # Clean target, removes all object files. This looks a bit hackish, as we have to 25 | # copy the content of MODULE_OBJS to another unique variable (the next module.mk 26 | # will overwrite it after all). The same for the libMODULE.a library file. 27 | clean: clean-$(MODULE) 28 | clean-$(MODULE): clean-% : 29 | -$(RM) $(MODULE_OBJS-$*) $(MODULE_LIB-$*) $(PLUGIN-$*) 30 | 31 | .PHONY: clean-$(MODULE) $(MODULE) 32 | -------------------------------------------------------------------------------- /src/ale/src/emucore/MD5.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: MD5.hxx,v 1.5 2007/01/01 18:04:48 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef MD5_HXX 20 | #define MD5_HXX 21 | 22 | #include "m6502/src/bspf/src/bspf.hxx" 23 | 24 | /** 25 | Get the MD5 Message-Digest of the specified message with the 26 | given length. The digest consists of 32 hexadecimal digits. 27 | 28 | @param buffer The message to compute the digest of 29 | @param length The length of the message 30 | @return The message-digest 31 | */ 32 | std::string MD5(const uInt8* buffer, uInt32 length); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/ale/src/os_dependent/SettingsWin32.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: SettingsWin32.hxx,v 1.8 2007/01/01 18:04:56 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef SETTINGS_WIN32_HXX 20 | #define SETTINGS_WIN32_HXX 21 | 22 | class OSystem; 23 | 24 | #include "../emucore/m6502/src/bspf/src/bspf.hxx" 25 | 26 | 27 | class SettingsWin32 : public Settings 28 | { 29 | public: 30 | /** 31 | Create a new UNIX settings object 32 | */ 33 | SettingsWin32(OSystem* osystem); 34 | 35 | /** 36 | Destructor 37 | */ 38 | virtual ~SettingsWin32(); 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/ale/src/emucore/m6502/src/Device.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // MM MM 6666 555555 0000 2222 4 | // MMMM MMMM 66 66 55 00 00 22 22 5 | // MM MMM MM 66 55 00 00 22 6 | // MM M MM 66666 55555 00 00 22222 -- "A 6502 Microprocessor Emulator" 7 | // MM MM 66 66 55 00 00 22 8 | // MM MM 66 66 55 55 00 00 22 9 | // MM MM 6666 5555 0000 222222 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Device.cxx,v 1.4 2007/01/01 18:04:50 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include "Device.hxx" 20 | 21 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 22 | Device::Device() 23 | : mySystem(0) 24 | { 25 | } 26 | 27 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 28 | Device::~Device() 29 | { 30 | } 31 | 32 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 33 | void Device::systemCyclesReset() 34 | { 35 | // By default I do nothing when my system resets its cycle counter 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/trie.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 1994,2001-2003 Nick Ing-Simmons. All rights reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Library General Public 6 | License as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public 15 | License along with this library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 | MA 02111-1307, USA 18 | 19 | */ 20 | /* $Id: trie.h,v 1.1 2006/06/11 07:13:27 urchlay Exp $ 21 | */ 22 | #ifndef TRIE_H 23 | #define TRIE_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | typedef struct trie_s *trie_ptr; 30 | 31 | extern void trie_insert(trie_ptr *r,char *s,void *value); 32 | extern void *trie_lookup(trie_ptr *r,char **sp); 33 | extern void trie_free(trie_ptr *r,void (*func)(void *)); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | 40 | #endif /* TRIE_H */ 41 | -------------------------------------------------------------------------------- /lib/alex/screen.ex: -------------------------------------------------------------------------------- 1 | defmodule Alex.Screen do 2 | alias Alex.Interface 3 | alias __MODULE__, as: Screen 4 | 5 | @moduledoc """ 6 | Convenience functions for working with the Screen. 7 | """ 8 | 9 | @typedoc """ 10 | Abstraction around ALE screen. 11 | 12 | ## Fields 13 | 14 | - `:data`: Screen data. 15 | - `:dim`: Tuple screen dimension. 16 | - `:rgb`: RGB Screen data. 17 | - `:grayscale`: Grayscale screen data. 18 | """ 19 | @type t :: %__MODULE__{ 20 | data: Enum.t(), 21 | dim: {integer(), integer()}, 22 | rgb: Enum.t(), 23 | grayscale: Enum.t() 24 | } 25 | defstruct [:data, :dim, :rgb, :grayscale] 26 | 27 | @doc """ 28 | Creates a new `Screen` struct. 29 | 30 | Returns `%Screen{}`. 31 | 32 | # Parameters 33 | 34 | - `interface`: `%Interface{}`. 35 | """ 36 | def new(%Interface{} = interface) do 37 | ale_ref = interface.ref 38 | 39 | with {:ok, screen} <- Interface.get_screen(ale_ref), 40 | {:ok, rgb} <- Interface.get_screen_rgb(ale_ref), 41 | {:ok, grayscale} <- Interface.get_screen_grayscale(ale_ref), 42 | {:ok, height} <- Interface.get_screen_height(ale_ref), 43 | {:ok, width} <- Interface.get_screen_width(ale_ref) do 44 | {:ok, %Screen{data: screen, dim: {width, height}, rgb: rgb, grayscale: grayscale}} 45 | else 46 | err -> raise err 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /src/ale/src/os_dependent/SettingsUNIX.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: SettingsUNIX.cxx,v 1.23 2007/07/27 13:49:16 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include "bspf.hxx" 20 | #include "Settings.hxx" 21 | #include "SettingsUNIX.hxx" 22 | 23 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 24 | SettingsUNIX::SettingsUNIX(OSystem* osystem) 25 | : Settings(osystem) 26 | { 27 | setInternal("gl_lib", "libGL.so"); 28 | // Most Linux GL implementations don't support this yet 29 | setInternal("gl_vsync", "false"); 30 | } 31 | 32 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 33 | SettingsUNIX::~SettingsUNIX() 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /src/ale/src/common/stella.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static const char * stella_icon[] = { 3 | "32 32 3 1", 4 | " c None", 5 | ". c #000000", 6 | "+ c #FFFFFF", 7 | " ", 8 | " ", 9 | " ", 10 | " ", 11 | " .............. ", 12 | " .............. ", 13 | " ..++..++..++.. ", 14 | " ..++..++..++.. ", 15 | " ..++..++..++.. ", 16 | " ..++..++..++.. ", 17 | " ..++..++..++.. ", 18 | " ..++..++..++.. ", 19 | " ..++..++..++.. ", 20 | " ..++..++..++.. ", 21 | " ....++..++..++.... ", 22 | " ....++..++..++.... ", 23 | " ....++++..++..++++.... ", 24 | " ....++++..++..++++.... ", 25 | " ..++++....++....++++.. ", 26 | " ..++++....++....++++.. ", 27 | " ......++......++......++...... ", 28 | " ......++......++......++...... ", 29 | " ..++++++.. ..++.. ..++++++.. ", 30 | " ..++++++.. ..++.. ..++++++.. ", 31 | " ..++++.... ..++.. ....++++.. ", 32 | " ..++++.... ..++.. ....++++.. ", 33 | " ........ ...... ........ ", 34 | " ........ ...... ........ ", 35 | " ", 36 | " ", 37 | " ", 38 | " "}; 39 | -------------------------------------------------------------------------------- /src/ale/src/os_dependent/SettingsUNIX.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: SettingsUNIX.hxx,v 1.8 2007/01/01 18:04:55 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef SETTINGS_UNIX_HXX 20 | #define SETTINGS_UNIX_HXX 21 | 22 | class OSystem; 23 | 24 | #include "../emucore/m6502/src/bspf/src/bspf.hxx" 25 | 26 | /** 27 | This class defines UNIX-like OS's (Linux) system specific settings. 28 | 29 | @author Stephen Anthony 30 | @version $Id: SettingsUNIX.hxx,v 1.8 2007/01/01 18:04:55 stephena Exp $ 31 | */ 32 | class SettingsUNIX : public Settings 33 | { 34 | public: 35 | /** 36 | Create a new UNIX settings object 37 | */ 38 | SettingsUNIX(OSystem* osystem); 39 | 40 | /** 41 | Destructor 42 | */ 43 | virtual ~SettingsUNIX(); 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/ale/src/os_dependent/SettingsWin32.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: SettingsWin32.cxx,v 1.26 2007/01/01 18:04:56 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include "bspf.hxx" 20 | #include "Settings.hxx" 21 | #include "SettingsWin32.hxx" 22 | 23 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 24 | SettingsWin32::SettingsWin32(OSystem* osystem) 25 | : Settings(osystem) 26 | { 27 | // Anything less than this usually causes sound skipping 28 | setInternal("fragsize", "2048"); 29 | // Most Windows systems work better without this 30 | setInternal("dirtyrects", "false"); 31 | setInternal("romdir", "c:\\"); 32 | } 33 | 34 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 35 | SettingsWin32::~SettingsWin32() 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /src/ale/src/emucore/MediaSrc.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: MediaSrc.cxx,v 1.4 2007/01/01 18:04:49 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include 20 | #include "MediaSrc.hxx" 21 | 22 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 23 | MediaSource::MediaSource() 24 | { 25 | } 26 | 27 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 28 | MediaSource::~MediaSource() 29 | { 30 | } 31 | 32 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 33 | MediaSource::MediaSource(const MediaSource&) 34 | { 35 | } 36 | 37 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 38 | MediaSource& MediaSource::operator = (const MediaSource&) 39 | { 40 | assert(false); 41 | 42 | return *this; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/phones.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 1994,2001-2002 Nick Ing-Simmons. All rights reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Library General Public 6 | License as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public 15 | License along with this library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 | MA 02111-1307, USA 18 | 19 | */ 20 | #include 21 | #include 22 | #include "phones.h" 23 | 24 | #if 0 25 | #ifdef __STDC__ 26 | #define PHONE(nm,br,am,ex) #nm, 27 | #else 28 | #define PHONE(nm,br,am,ex) "nm", 29 | #endif 30 | #endif 31 | 32 | #define PHONE(nm,st,br,am,ex) st 33 | 34 | char *ph_name[] = 35 | {" ", 36 | #include "phones.def" 37 | NULL}; 38 | #undef PHONE 39 | 40 | #define PHONE(nm,st,br,am,ex) br 41 | char *ph_br[] = 42 | {" ", 43 | #include "phones.def" 44 | NULL}; 45 | #undef PHONE 46 | 47 | #define PHONE(nm,st,br,am,ex) am 48 | char *ph_am[] = 49 | {" ", 50 | #include "phones.def" 51 | NULL}; 52 | #undef PHONE 53 | -------------------------------------------------------------------------------- /src/ale/src/games/RomUtils.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | * 12 | * RomUtils.hpp 13 | * 14 | * Additional utilities to operate on RAM. 15 | * ***************************************************************************** 16 | */ 17 | 18 | #ifndef __ROMUTILS_HPP__ 19 | #define __ROMUTILS_HPP__ 20 | 21 | class System; 22 | 23 | namespace ale { 24 | 25 | // reads a byte at a RAM location between 0 and 0x7f also mapped to [0x80, 0xff] 26 | extern int readRam(const System* system, int offset); 27 | 28 | // reads a byte from anywhere in the memory map between 0x0000 and 0xffff. 29 | extern int readMappedRam(const System* system, int offset); 30 | 31 | // extracts a decimal value from 1, 2, and 3 bytes respectively 32 | extern int getDecimalScore(int idx, const System* system); 33 | extern int getDecimalScore(int lo, int hi, const System* system); 34 | extern int getDecimalScore(int lo, int mid, int hi, const System* system); 35 | 36 | } // namespace ale 37 | 38 | #endif // __ROMUTILS_HPP__ 39 | -------------------------------------------------------------------------------- /src/ale/src/emucore/module.mk: -------------------------------------------------------------------------------- 1 | MODULE := src/emucore 2 | 3 | MODULE_OBJS := \ 4 | src/emucore/AtariVox.o \ 5 | src/emucore/Booster.o \ 6 | src/emucore/Cart2K.o \ 7 | src/emucore/Cart3F.o \ 8 | src/emucore/Cart3E.o \ 9 | src/emucore/Cart4A50.o \ 10 | src/emucore/Cart4K.o \ 11 | src/emucore/CartAR.o \ 12 | src/emucore/CartCV.o \ 13 | src/emucore/Cart.o \ 14 | src/emucore/CartDPC.o \ 15 | src/emucore/CartE0.o \ 16 | src/emucore/CartE7.o \ 17 | src/emucore/CartF4.o \ 18 | src/emucore/CartF4SC.o \ 19 | src/emucore/CartF6.o \ 20 | src/emucore/CartF6SC.o \ 21 | src/emucore/CartF8.o \ 22 | src/emucore/CartF8SC.o \ 23 | src/emucore/CartFASC.o \ 24 | src/emucore/CartFE.o \ 25 | src/emucore/CartMB.o \ 26 | src/emucore/CartMC.o \ 27 | src/emucore/CartUA.o \ 28 | src/emucore/Cart0840.o \ 29 | src/emucore/Console.o \ 30 | src/emucore/Control.o \ 31 | src/emucore/Deserializer.o \ 32 | src/emucore/Driving.o \ 33 | src/emucore/Event.o \ 34 | src/emucore/FSNode.o \ 35 | src/emucore/Joystick.o \ 36 | src/emucore/Keyboard.o \ 37 | src/emucore/M6532.o \ 38 | src/emucore/MD5.o \ 39 | src/emucore/MediaSrc.o \ 40 | src/emucore/OSystem.o \ 41 | src/emucore/Paddles.o \ 42 | src/emucore/Props.o \ 43 | src/emucore/PropsSet.o \ 44 | src/emucore/Random.o \ 45 | src/emucore/Serializer.o \ 46 | src/emucore/Settings.o \ 47 | src/emucore/SpeakJet.o \ 48 | src/emucore/Switches.o \ 49 | src/emucore/TIA.o \ 50 | src/emucore/TIASnd.o \ 51 | 52 | MODULE_DIRS += \ 53 | src/emucore 54 | 55 | # Include common rules 56 | include $(srcdir)/common.rules 57 | -------------------------------------------------------------------------------- /src/ale/src/environment/phosphor_blend.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | * phosphor_blend.hpp 12 | * 13 | * Methods for performing colour averaging over the screen. 14 | * 15 | **************************************************************************** */ 16 | 17 | #ifndef __PHOSPHOR_BLEND_HPP__ 18 | #define __PHOSPHOR_BLEND_HPP__ 19 | 20 | #include "../emucore/OSystem.hxx" 21 | #include "ale_screen.hpp" 22 | 23 | namespace ale { 24 | 25 | class PhosphorBlend { 26 | public: 27 | PhosphorBlend(OSystem*); 28 | 29 | void process(ALEScreen& screen); 30 | 31 | private: 32 | void makeAveragePalette(); 33 | uInt8 getPhosphor(uInt8 v1, uInt8 v2); 34 | uInt32 makeRGB(uInt8 r, uInt8 g, uInt8 b); 35 | /** Converts a RGB value to an 8-bit format */ 36 | uInt8 rgbToNTSC(uInt32 rgb); 37 | 38 | private: 39 | OSystem* m_osystem; 40 | 41 | uInt8 m_rgb_ntsc[64][64][64]; 42 | 43 | uInt32 m_avg_palette[256][256]; 44 | uInt8 m_phosphor_blend_ratio; 45 | }; 46 | 47 | } // namespace ale 48 | 49 | #endif // __PHOSPHOR_BLEND_HPP__ 50 | -------------------------------------------------------------------------------- /src/ale/src/os_dependent/OSystemUNIX.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: OSystemUNIX.hxx,v 1.16 2007/07/19 16:21:39 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef OSYSTEM_UNIX_HXX 20 | #define OSYSTEM_UNIX_HXX 21 | 22 | #include "../emucore/m6502/src/bspf/src/bspf.hxx" 23 | 24 | /** 25 | This class defines UNIX-like OS's (Linux) system specific settings. 26 | 27 | @author Stephen Anthony 28 | @version $Id: OSystemUNIX.hxx,v 1.16 2007/07/19 16:21:39 stephena Exp $ 29 | */ 30 | class OSystemUNIX : public OSystem 31 | { 32 | public: 33 | /** 34 | Create a new UNIX-specific operating system object 35 | */ 36 | OSystemUNIX(); 37 | 38 | /** 39 | Destructor 40 | */ 41 | virtual ~OSystemUNIX(); 42 | 43 | /** 44 | This method returns number of ticks in microseconds. 45 | 46 | @return Current time in microseconds. 47 | */ 48 | uInt32 getTicks(); 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/ale/src/os_dependent/OSystemWin32.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: OSystemWin32.hxx,v 1.11 2007/07/19 16:21:39 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef OSYSTEM_WIN32_HXX 20 | #define OSYSTEM_WIN32_HXX 21 | 22 | #include "../emucore/m6502/src/bspf/src/bspf.hxx" 23 | 24 | /** 25 | This class defines Windows system specific settings. 26 | 27 | @author Stephen Anthony 28 | @version $Id: OSystemWin32.hxx,v 1.11 2007/07/19 16:21:39 stephena Exp $ 29 | */ 30 | class OSystemWin32 : public OSystem 31 | { 32 | public: 33 | /** 34 | Create a new Win32 operating system object 35 | */ 36 | OSystemWin32(); 37 | 38 | /** 39 | Destructor 40 | */ 41 | virtual ~OSystemWin32(); 42 | 43 | public: 44 | /** 45 | This method returns number of ticks in microseconds. 46 | 47 | @return Current time in microseconds. 48 | */ 49 | virtual uInt32 getTicks(); 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/ale/src/environment/stella_environment_wrapper.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | * stella_environment_wrapper.hpp 12 | * 13 | * Method wrapper for StellaEnvironment. 14 | * 15 | **************************************************************************** */ 16 | 17 | #ifndef __STELLA_ENVIRONMENT_WRAPPER_HPP__ 18 | #define __STELLA_ENVIRONMENT_WRAPPER_HPP__ 19 | 20 | #include "../common/Constants.h" 21 | #include "../emucore/Random.hxx" 22 | 23 | namespace ale { 24 | 25 | class StellaEnvironment; 26 | 27 | class StellaEnvironmentWrapper { 28 | // A wrapper for actions within the StellaEnvironment. 29 | // Allows us to call environment methods without requiring to #include 30 | // stella_environment.hpp. 31 | public: 32 | StellaEnvironmentWrapper(StellaEnvironment& environment); 33 | reward_t act(Action player_a_action, Action player_b_action); 34 | void softReset(); 35 | void pressSelect(size_t num_steps = 1); 36 | Random& getSystemRng(); 37 | 38 | StellaEnvironment& m_environment; 39 | }; 40 | 41 | } // namespace ale 42 | 43 | #endif // __STELLA_ENVIRONMENT_WRAPPER_HPP__ 44 | -------------------------------------------------------------------------------- /src/ale/src/external/TinyMT/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Mutsuo Saito, Makoto Matsumoto, Hiroshima 2 | University and The University of Tokyo. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following 12 | disclaimer in the documentation and/or other materials provided 13 | with the distribution. 14 | * Neither the name of the Hiroshima University nor the names of 15 | its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written 17 | permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/kmap: -------------------------------------------------------------------------------- 1 | # Klatt symbol mappings to CMU's and our SAMPA via dlookup of example word(s) shown. 2 | # 3 | 4 | # Vowels 5 | AA bob AA1 [A] 6 | AX about AX [@] 7 | EXR bear A [e@R] 8 | IY beet IY [i] 9 | UW boot UW [u] 10 | AE bat AE [{] 11 | AXR bar AA [A] 12 | EY bait EY [eI] 13 | OW boat OW [@U] 14 | UXR poor UA [U@R] 15 | AH but AH [V] 16 | AY bite AY [aI] 17 | IH bit IH [I] 18 | OXR boar AO [OR] 19 | YU beauty Y UW1 [ju] 20 | AO bought AO [O] 21 | EH bet EH [e] 22 | IX impunity IH [I] 23 | OY boy AO IY [Oi] 24 | AW bout AW [aU] 25 | ER bird ER [3`] 26 | IXR beer IA [I@R] 27 | UH book UH [U] 28 | # Sonorants 29 | RR rent R [r] 30 | RX fire AX [@`] # Rhotic 31 | HH hat HH [h] 32 | HX hurrah HH [h] # Allophone ? 33 | WW wet W [w] 34 | WH which W [W] # [hw] sound ? 35 | LL let L [l] # Allophone before vowel 36 | LX bill L [5] # Allophone after vowel 37 | EL bottle L [l=] # Syllabic l 38 | YY yet Y [j] 39 | # Nasals 40 | EM 'em M [m=] # syllabic m 41 | EN button N [n=] # syllabic n 42 | MM met M [m] 43 | NN net N [n] 44 | NG sing NG [N] 45 | # Fricatives 46 | DH that DH [D] 47 | VV vat V [v] 48 | FF fin F [f] 49 | ZZ zoo Z [z] 50 | SS sat S [s] 51 | ZH azure ZH [Z] 52 | SH shin SH [S] 53 | TH thin TH [T] 54 | # Plosives 55 | BB bet B [b] 56 | KK core K [k] # allophone before back vowel? 57 | KP keen K [k] # allophone before front vowel? 58 | GG gore G [g] # allophone before back vowel? 59 | GP give G [g] # allophone before front vowel? 60 | DD debt D [d] 61 | PP pet P [p] 62 | TT ten T [t] # 63 | DX butter T [4] # allophone beween vowels 64 | TQ at Alan T [t] # allophone before stressed vowel? 65 | # Affricates 66 | CH chin CH [tS] 67 | JJ gin G [g] 68 | # Plosive release 69 | AXP ship P [p] # artifact of terminal plosive? 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Koolaid.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __KOOLAID_HPP__ 14 | #define __KOOLAID_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for Koolaid */ 21 | class KoolaidSettings : public RomSettings { 22 | public: 23 | KoolaidSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | const char* rom() const override { return "koolaid"; } 36 | 37 | // create a new instance of the rom 38 | RomSettings* clone() const override; 39 | 40 | // is an action part of the minimal set? 41 | bool isMinimal(const Action& a) const override; 42 | 43 | // process the latest information from ALE 44 | void step(const System& system) override; 45 | 46 | // saves the state of the rom settings 47 | void saveState(Serializer& ser) override; 48 | 49 | // loads the state of the rom settings 50 | void loadState(Deserializer& ser) override; 51 | 52 | int lives() override { return 0; } 53 | 54 | private: 55 | bool m_terminal; 56 | reward_t m_reward; 57 | reward_t m_score; 58 | }; 59 | 60 | } // namespace ale 61 | 62 | #endif // __KOOLAID_HPP__ 63 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Kaboom.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __KABOOM_HPP__ 14 | #define __KABOOM_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for Kaboom settings */ 21 | class KaboomSettings : public RomSettings { 22 | public: 23 | KaboomSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | const char* rom() const override { return "kaboom"; } 36 | 37 | // create a new instance of the rom 38 | RomSettings* clone() const override; 39 | 40 | // is an action part of the minimal set? 41 | bool isMinimal(const Action& a) const override; 42 | 43 | // process the latest information from ALE 44 | void step(const System& system) override; 45 | 46 | // saves the state of the rom settings 47 | void saveState(Serializer& ser) override; 48 | 49 | // loads the state of the rom settings 50 | void loadState(Deserializer& ser) override; 51 | 52 | ActionVect getStartingActions() override; 53 | 54 | private: 55 | bool m_terminal; 56 | reward_t m_reward; 57 | reward_t m_score; 58 | }; 59 | 60 | } // namespace ale 61 | 62 | #endif // __KABOOM__ 63 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Switches.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Switches.hxx,v 1.4 2007/01/01 18:04:50 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef SWITCHES_HXX 20 | #define SWITCHES_HXX 21 | 22 | class Event; 23 | class Properties; 24 | class Switches; 25 | 26 | #include "m6502/src/bspf/src/bspf.hxx" 27 | 28 | /** 29 | This class represents the console switches of the game console. 30 | 31 | @author Bradford W. Mott 32 | @version $Id: Switches.hxx,v 1.4 2007/01/01 18:04:50 stephena Exp $ 33 | */ 34 | class Switches 35 | { 36 | public: 37 | /** 38 | Create a new set of switches using the specified events and 39 | properties 40 | 41 | @param event The event object to use for events 42 | */ 43 | Switches(const Event& event, const Properties& properties); 44 | 45 | /** 46 | Destructor 47 | */ 48 | virtual ~Switches(); 49 | 50 | public: 51 | /** 52 | Get the value of the console switches 53 | 54 | @return The 8 bits which represent the state of the console switches 55 | */ 56 | uInt8 read(); 57 | 58 | private: 59 | // Reference to the event object to use 60 | const Event& myEvent; 61 | 62 | // State of the console switches 63 | uInt8 mySwitches; 64 | }; 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /src/ale/src/emucore/m6502/src/bspf/Copyright.txt: -------------------------------------------------------------------------------- 1 | =============================================================================== 2 | 3 | BBBBB SSSS PPPPP FFFFFF 4 | BB BB SS SS PP PP FF 5 | BB BB SS PP PP FF 6 | BBBBB SSSS PPPPP FFFF -- "Brad's Simple Portability Framework" 7 | BB BB SS PP FF 8 | BB BB SS SS PP FF 9 | BBBBB SSSS PP FF 10 | 11 | =============================================================================== 12 | License Information and Copyright Notice 13 | =============================================================================== 14 | 15 | Copyright (C) 1995-2002 Bradford W. Mott 16 | 17 | This program is free software; you can redistribute it and/or modify it under 18 | the terms of the GNU General Public License as published by the Free Software 19 | Foundation; either version 2 of the License, or any later version. 20 | 21 | You should have received a copy of the GNU General Public License version 2 22 | along with this program (License.txt); if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 24 | 25 | This program is distributed in the hope that it will be useful, but WITHOUT 26 | ANY WARRANTY. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY 27 | PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 28 | ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES 29 | THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH 30 | DAMAGE. 31 | 32 | THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, 33 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 34 | PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN 35 | "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE 36 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 37 | 38 | -------------------------------------------------------------------------------- /src/ale/src/controllers/ale_controller.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | * ale_controller.hpp 12 | * 13 | * Superclass defining a variety of controllers -- main loops interfacing with 14 | * an agent in a particular way. This superclass handles work common to all 15 | * controllers, e.g. loading ROM settings and constructing the environment 16 | * wrapper. 17 | **************************************************************************** */ 18 | 19 | #ifndef __ALE_CONTROLLER_HPP__ 20 | #define __ALE_CONTROLLER_HPP__ 21 | 22 | #include 23 | 24 | #include "../emucore/OSystem.hxx" 25 | #include "../emucore/m6502/src/System.hxx" 26 | #include "../environment/stella_environment.hpp" 27 | 28 | namespace ale { 29 | 30 | class ALEController { 31 | public: 32 | ALEController(OSystem* osystem); 33 | virtual ~ALEController() {} 34 | 35 | /** Main loop. Returns once ALE terminates. */ 36 | virtual void run() = 0; 37 | 38 | protected: 39 | friend class ALEInterface; 40 | 41 | /** Applies the given action to the environment (e.g. by emulating or resetting) */ 42 | reward_t applyActions(Action a, Action b); 43 | /** Support for SDL display... available to all controllers. Simply call it from run(). */ 44 | void display(); 45 | 46 | protected: 47 | OSystem* m_osystem; 48 | std::unique_ptr m_settings; 49 | StellaEnvironment m_environment; 50 | }; 51 | 52 | } // namespace ale 53 | 54 | #endif // __ALE_CONTROLLER_HPP__ 55 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/DonkeyKong.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __DONKEYKONG_HPP__ 14 | #define __DONKEYKONG_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for DonkeyKong */ 21 | class DonkeyKongSettings : public RomSettings { 22 | public: 23 | DonkeyKongSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | // MD5 36b20c427975760cb9cf4a47e41369e4 36 | const char* rom() const override { return "donkey_kong"; } 37 | 38 | // create a new instance of the rom 39 | RomSettings* clone() const override; 40 | 41 | // is an action part of the minimal set? 42 | bool isMinimal(const Action& a) const override; 43 | 44 | // process the latest information from ALE 45 | void step(const System& system) override; 46 | 47 | // saves the state of the rom settings 48 | void saveState(Serializer& ser) override; 49 | 50 | // loads the state of the rom settings 51 | void loadState(Deserializer& ser) override; 52 | 53 | int lives() override { return isTerminal() ? 0 : m_lives; } 54 | 55 | private: 56 | bool m_terminal; 57 | reward_t m_reward; 58 | reward_t m_score; 59 | int m_lives; 60 | }; 61 | 62 | } // namespace ale 63 | 64 | #endif // __DONKEYKONG_HPP__ 65 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Trondead.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __TRONDEAD_HPP__ 14 | #define __TRONDEAD_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for Trondead */ 21 | class TrondeadSettings : public RomSettings { 22 | public: 23 | TrondeadSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | const char* rom() const override { return "trondead"; } 36 | 37 | // create a new instance of the rom 38 | RomSettings* clone() const override; 39 | 40 | // is an action part of the minimal set? 41 | bool isMinimal(const Action& a) const override; 42 | 43 | // process the latest information from ALE 44 | void step(const System& system) override; 45 | 46 | // saves the state of the rom settings 47 | void saveState(Serializer& ser) override; 48 | 49 | // loads the state of the rom settings 50 | void loadState(Deserializer& ser) override; 51 | 52 | int lives() override { return isTerminal() ? 0 : m_lives; } 53 | 54 | DifficultyVect getAvailableDifficulties() override; 55 | 56 | private: 57 | bool m_terminal; 58 | reward_t m_reward; 59 | reward_t m_score; 60 | int m_lives; 61 | }; 62 | 63 | } // namespace ale 64 | 65 | #endif // __TRONDEAD_HPP__ 66 | -------------------------------------------------------------------------------- /src/ale/src/emucore/m6502/Copyright.txt: -------------------------------------------------------------------------------- 1 | =============================================================================== 2 | 3 | MM MM 6666 555555 0000 2222 4 | MMMM MMMM 66 66 55 00 00 22 22 5 | MM MMM MM 66 55 00 00 22 6 | MM M MM 66666 55555 00 00 22222 -- "A 6502 Microprocessor Emulator" 7 | MM MM 66 66 55 00 00 22 8 | MM MM 66 66 55 55 00 00 22 9 | MM MM 6666 5555 0000 222222 10 | 11 | =============================================================================== 12 | License Information and Copyright Notice 13 | =============================================================================== 14 | 15 | Copyright (C) 1995-2002 Bradford W. Mott 16 | 17 | This program is free software; you can redistribute it and/or modify it under 18 | the terms of the GNU General Public License as published by the Free Software 19 | Foundation; either version 2 of the License, or any later version. 20 | 21 | You should have received a copy of the GNU General Public License version 2 22 | along with this program (License.txt); if not, write to the Free Software 23 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 24 | 25 | This program is distributed in the hope that it will be useful, but WITHOUT 26 | ANY WARRANTY. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY 27 | PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 28 | ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES 29 | THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH 30 | DAMAGE. 31 | 32 | THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, 33 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 34 | PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN 35 | "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE 36 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 37 | 38 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/LaserGates.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __LASERGATES_HPP__ 14 | #define __LASERGATES_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for Laser Gates */ 21 | class LaserGatesSettings : public RomSettings { 22 | public: 23 | LaserGatesSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | // MD5 1fa58679d4a39052bd9db059e8cda4ad 36 | const char* rom() const override { return "laser_gates"; } 37 | 38 | // create a new instance of the rom 39 | RomSettings* clone() const override; 40 | 41 | // is an action part of the minimal set? 42 | bool isMinimal(const Action& a) const override; 43 | 44 | // process the latest information from ALE 45 | void step(const System& system) override; 46 | 47 | // saves the state of the rom settings 48 | void saveState(Serializer& ser) override; 49 | 50 | // loads the state of the rom settings 51 | void loadState(Deserializer& ser) override; 52 | 53 | // LaserGates requires the fire action to start the game 54 | ActionVect getStartingActions() override; 55 | 56 | int lives() override { return 0; } 57 | 58 | private: 59 | bool m_terminal; 60 | reward_t m_reward; 61 | reward_t m_score; 62 | }; 63 | 64 | } // namespace ale 65 | 66 | #endif // __LASERGATES_HPP__ 67 | -------------------------------------------------------------------------------- /src/ale/src/environment/ale_ram.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | * ale_ram.hpp 12 | * 13 | * A class that encapsulates the Atari 2600 RAM. Code is provided inline for 14 | * efficiency reasonss. 15 | * 16 | **************************************************************************** */ 17 | 18 | #ifndef __ALE_RAM_HPP__ 19 | #define __ALE_RAM_HPP__ 20 | 21 | #include 22 | #include 23 | 24 | namespace ale { 25 | 26 | using byte_t = unsigned char; 27 | 28 | /** A simple wrapper around the Atari RAM. */ 29 | class ALERAM { 30 | static constexpr std::size_t kRamSize = 128; 31 | 32 | public: 33 | /** Byte accessors: x is wrapped to [0, 128). */ 34 | byte_t get(unsigned int x) const; 35 | byte_t* byte(unsigned int x); 36 | 37 | /** Returns a pointer to the first element of the entire 38 | array (equivalent to &byte[0]). */ 39 | const byte_t* array() const { return m_ram; } 40 | 41 | std::size_t size() const { return sizeof(m_ram); } 42 | 43 | /** Returns whether two copies of the RAM are equal */ 44 | bool equals(const ALERAM& rhs) const { 45 | return std::memcmp(m_ram, rhs.m_ram, size()) == 0; 46 | } 47 | 48 | protected: 49 | byte_t m_ram[kRamSize]; 50 | }; 51 | 52 | // Byte accessors 53 | inline byte_t ALERAM::get(unsigned int x) const { 54 | // Wrap RAM around the first 128 bytes 55 | return m_ram[x & 0x7F]; 56 | } 57 | 58 | inline byte_t* ALERAM::byte(unsigned int x) { 59 | // Wrap RAM around the first 128 bytes 60 | return &m_ram[x & 0x7F]; 61 | } 62 | 63 | } // namespace ale 64 | 65 | #endif // __ALE_RAM_HPP__ 66 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/SirLancelot.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __SIRLANCELOT_HPP__ 14 | #define __SIRLANCELOT_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for Up N Down */ 21 | class SirLancelotSettings : public RomSettings { 22 | public: 23 | SirLancelotSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | // MD5 7ead257e8b5a44cac538f5f54c7a0023 36 | const char* rom() const override { return "sir_lancelot"; } 37 | 38 | // create a new instance of the rom 39 | RomSettings* clone() const override; 40 | 41 | // is an action part of the minimal set? 42 | bool isMinimal(const Action& a) const override; 43 | 44 | // process the latest information from ALE 45 | void step(const System& system) override; 46 | 47 | // saves the state of the rom settings 48 | void saveState(Serializer& ser) override; 49 | 50 | // loads the state of the rom settings 51 | void loadState(Deserializer& ser) override; 52 | 53 | // SirLancelot requires the reset+left action to start the game 54 | ActionVect getStartingActions() override; 55 | 56 | int lives() override { return isTerminal() ? 0 : m_lives; } 57 | 58 | private: 59 | bool m_terminal; 60 | reward_t m_reward; 61 | reward_t m_score; 62 | int m_lives; 63 | }; 64 | 65 | } // namespace ale 66 | 67 | #endif // __SIRLANCELOT_HPP__ 68 | -------------------------------------------------------------------------------- /src/ale/src/common/ScreenExporter.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | * ScreenExporter.hpp 12 | * 13 | * A class for exporting Atari 2600 frames as PNGs. 14 | * 15 | **************************************************************************** */ 16 | 17 | #ifndef __SCREEN_EXPORTER_HPP__ 18 | #define __SCREEN_EXPORTER_HPP__ 19 | 20 | #include 21 | 22 | #include "display_screen.h" 23 | #include "../environment/ale_screen.hpp" 24 | 25 | namespace ale { 26 | 27 | class ScreenExporter { 28 | public: 29 | /** Creates a new ScreenExporter which can be used to save screens using save(filename). */ 30 | ScreenExporter(ColourPalette& palette); 31 | 32 | /** Creates a new ScreenExporter which will save frames successively in the directory provided. 33 | * Frames are sequentially named with 6 digits, starting at 000000. */ 34 | ScreenExporter(ColourPalette& palette, const std::string& path); 35 | 36 | /** Save the given screen to the given filename. No paths are created. */ 37 | void save(const ALEScreen& screen, const std::string& filename) const; 38 | 39 | /** Save the given screen according to our own internal numbering. */ 40 | void saveNext(const ALEScreen& screen); 41 | 42 | private: 43 | ColourPalette& m_palette; 44 | 45 | /** The next frame number. */ 46 | int m_frame_number; 47 | 48 | /** The width of the frame number when constructing filenames (set to 6). */ 49 | int m_frame_field_width; 50 | 51 | /** The directory where we save successive frames. */ 52 | std::string m_path; 53 | }; 54 | 55 | } // namespace ale 56 | 57 | #endif // __SCREEN_EXPORTER_HPP__ 58 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/KeystoneKapers.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __KEYSTONEKAPERS_HPP__ 14 | #define __KEYSTONEKAPERS_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for KeystoneKapers */ 21 | class KeystoneKapersSettings : public RomSettings { 22 | public: 23 | KeystoneKapersSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | // MD5 be929419902e21bd7830a7a7d746195d 36 | const char* rom() const override { return "keystone_kapers"; } 37 | 38 | // create a new instance of the rom 39 | RomSettings* clone() const override; 40 | 41 | // is an action part of the minimal set? 42 | bool isMinimal(const Action& a) const override; 43 | 44 | // process the latest information from ALE 45 | void step(const System& system) override; 46 | 47 | // saves the state of the rom settings 48 | void saveState(Serializer& ser) override; 49 | 50 | // loads the state of the rom settings 51 | void loadState(Deserializer& ser) override; 52 | 53 | // Keystone Kapers requires the reset button to start the game 54 | ActionVect getStartingActions() override; 55 | 56 | int lives() override { return isTerminal() ? 0 : m_lives; } 57 | 58 | private: 59 | bool m_terminal; 60 | reward_t m_reward; 61 | reward_t m_score; 62 | int m_lives; 63 | }; 64 | 65 | } // namespace ale 66 | 67 | #endif // __KEYSTONEKAPERS_HPP__ 68 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Control.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Control.cxx,v 1.6 2007/01/05 17:54:09 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include 20 | #include "Control.hxx" 21 | 22 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 23 | Controller::Controller(Jack jack, const Event& event, Type type) 24 | : myJack(jack), 25 | myEvent(event), 26 | myType(type) 27 | { 28 | } 29 | 30 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 31 | Controller::~Controller() 32 | { 33 | } 34 | 35 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 36 | Controller::Type Controller::type() 37 | { 38 | return myType; 39 | } 40 | 41 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 42 | const Int32 Controller::maximumResistance = 0x7FFFFFFF; 43 | 44 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 45 | const Int32 Controller::minimumResistance = 0x00000000; 46 | 47 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 48 | Controller::Controller(const Controller& c) 49 | : myJack(c.myJack), 50 | myEvent(c.myEvent), 51 | myType(c.myType) 52 | { 53 | assert(false); 54 | } 55 | 56 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 57 | Controller& Controller::operator = (const Controller&) 58 | { 59 | assert(false); 60 | return *this; 61 | } 62 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Event.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Event.cxx,v 1.11 2007/01/01 18:04:47 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include "Event.hxx" 20 | 21 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 22 | Event::Event() 23 | : myNumberOfTypes(Event::LastType) 24 | { 25 | // Set all of the events to 0 / false to start with, 26 | // including analog paddle events. Doing it this way 27 | // is a bit of a hack ... 28 | clear(); 29 | 30 | myValues[PaddleZeroResistance] = 31 | myValues[PaddleOneResistance] = 32 | myValues[PaddleTwoResistance] = 33 | myValues[PaddleThreeResistance] = 0; 34 | } 35 | 36 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 37 | Event::~Event() 38 | { 39 | } 40 | 41 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 42 | Int32 Event::get(Type type) const 43 | { 44 | return myValues[type]; 45 | } 46 | 47 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 48 | void Event::set(Type type, Int32 value) 49 | { 50 | myValues[type] = value; 51 | } 52 | 53 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 54 | void Event::clear() 55 | { 56 | for(int i = 0; i < myNumberOfTypes; ++i) 57 | { 58 | if(i != PaddleZeroResistance && i != PaddleOneResistance && 59 | i != PaddleTwoResistance && i != PaddleThreeResistance) 60 | myValues[i] = 0; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/ale/src/controllers/fifo_controller.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | * fifo_controller.hpp 12 | * 13 | * The FIFOController class implements an Agent/ALE interface via stdin/stdout 14 | * or named pipes. 15 | **************************************************************************** */ 16 | 17 | #ifndef __FIFO_CONTROLLER_HPP__ 18 | #define __FIFO_CONTROLLER_HPP__ 19 | 20 | #include "ale_controller.hpp" 21 | 22 | namespace ale { 23 | 24 | class FIFOController : public ALEController { 25 | public: 26 | FIFOController(OSystem* osystem, bool named_pipes = false); 27 | virtual ~FIFOController(); 28 | 29 | virtual void run(); 30 | 31 | private: 32 | void handshake(); // Perform handshaking 33 | void openNamedPipes(); 34 | 35 | bool isDone(); 36 | void sendData(); 37 | void readAction(Action& action_a, Action& action_b); 38 | 39 | void sendScreen(); 40 | int stringScreenRLE(const ALEScreen& screen, char* buffer); 41 | int stringScreenFull(const ALEScreen& screen, char* buffer); 42 | void sendRAM(); 43 | void sendRL(); 44 | 45 | private: 46 | bool m_named_pipes; // Whether to use named pipes 47 | 48 | int m_max_num_frames; // Maximum number of total frames before we stop 49 | bool 50 | m_run_length_encoding; // Whether to encode the data in a run-length fashion 51 | 52 | bool m_send_screen; // Agent requested screen data 53 | bool m_send_ram; // Agent requested RAM data 54 | bool m_send_rl; // Agent requested RL data 55 | 56 | FILE* m_fout; 57 | FILE* m_fin; 58 | 59 | reward_t latest_reward; // Most recent reward 60 | }; 61 | 62 | } // namespace ale 63 | 64 | #endif // __FIFO_CONTROLLER_HPP__ 65 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/MrDo.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __MRDO_HPP__ 14 | #define __MRDO_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for MrDo */ 21 | class MrDoSettings : public RomSettings { 22 | public: 23 | MrDoSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | const char* rom() const override { return "mr_do"; } 36 | 37 | // create a new instance of the rom 38 | RomSettings* clone() const override; 39 | 40 | // is an action part of the minimal set? 41 | bool isMinimal(const Action& a) const override; 42 | 43 | // process the latest information from ALE 44 | void step(const System& system) override; 45 | 46 | // saves the state of the rom settings 47 | void saveState(Serializer& ser) override; 48 | 49 | // loads the state of the rom settings 50 | void loadState(Deserializer& ser) override; 51 | 52 | // Mr. Do requires the fire action to start the game 53 | ActionVect getStartingActions() override; 54 | 55 | int lives() override { return isTerminal() ? 0 : m_lives; } 56 | 57 | ModeVect getAvailableModes() override; 58 | 59 | void setMode(game_mode_t m, System& system, 60 | std::unique_ptr environment) override; 61 | 62 | private: 63 | bool m_terminal; 64 | reward_t m_reward; 65 | reward_t m_score; 66 | int m_lives; 67 | }; 68 | 69 | } // namespace ale 70 | 71 | #endif // __MRDO_HPP__ 72 | -------------------------------------------------------------------------------- /src/ale/src/os_dependent/OSystemWin32.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: OSystemWin32.cxx,v 1.20 2007/08/04 20:32:54 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "bspf.hxx" 24 | #include "OSystem.hxx" 25 | #include "OSystemWin32.hxx" 26 | 27 | using namespace std; 28 | 29 | /** 30 | Each derived class is responsible for calling the following methods 31 | in its constructor: 32 | 33 | setBaseDir() 34 | setConfigFile() 35 | 36 | See OSystem.hxx for a further explanation 37 | */ 38 | 39 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 40 | OSystemWin32::OSystemWin32() 41 | : OSystem() 42 | { 43 | // TODO - there really should be code here to determine which version 44 | // of Windows is being used. 45 | // If using a version which supports multiple users (NT and above), 46 | // the relevant directories should be created in per-user locations. 47 | // For now, we just put it in the same directory as the executable. 48 | const string& basedir = "."; 49 | setBaseDir(basedir); 50 | setConfigFile(basedir + "\\ale.cfg"); 51 | } 52 | 53 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 54 | OSystemWin32::~OSystemWin32() 55 | { 56 | } 57 | 58 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 59 | uInt32 OSystemWin32::getTicks() 60 | { 61 | //return (uInt32) SDL_GetTicks() * 1000; 62 | return static_cast(GetTickCount() * 1000); 63 | } 64 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Frogger.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __FROGGER_HPP__ 14 | #define __FROGGER_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for Frogger */ 21 | class FroggerSettings : public RomSettings { 22 | public: 23 | FroggerSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | // MD5 081e2c114c9c20b61acf25fc95c71bf4 36 | const char* rom() const override { return "frogger"; } 37 | 38 | // create a new instance of the rom 39 | RomSettings* clone() const override; 40 | 41 | // is an action part of the minimal set? 42 | bool isMinimal(const Action& a) const override; 43 | 44 | // process the latest information from ALE 45 | void step(const System& system) override; 46 | 47 | // saves the state of the rom settings 48 | void saveState(Serializer& ser) override; 49 | 50 | // loads the state of the rom settings 51 | void loadState(Deserializer& ser) override; 52 | 53 | int lives() override { return isTerminal() ? 0 : m_lives; } 54 | 55 | ModeVect getAvailableModes() override; 56 | 57 | void setMode(game_mode_t m, System& system, 58 | std::unique_ptr environment) override; 59 | 60 | DifficultyVect getAvailableDifficulties() override; 61 | 62 | private: 63 | bool m_terminal; 64 | reward_t m_reward; 65 | reward_t m_score; 66 | int m_lives; 67 | }; 68 | 69 | } // namespace ale 70 | 71 | #endif // __FROGGER_HPP__ 72 | -------------------------------------------------------------------------------- /src/ale/src/common/SoundExporter.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare, 4 | * Matthew Hausknecht and the Reinforcement Learning and Artificial Intelligence 5 | * Laboratory 6 | * Released under the GNU General Public License; see License.txt for details. 7 | * 8 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 9 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 10 | * 11 | * ***************************************************************************** 12 | * SoundExporter.hpp 13 | * 14 | * A class for writing Atari 2600 sound to a WAV file. 15 | * 16 | * Parts of this code were taken from 17 | * 18 | * http://stackoverflow.com/questions/22226872/two-problems-when-writing-to-wav-c 19 | * 20 | **************************************************************************** */ 21 | 22 | #ifndef __SOUND_EXPORTER_HPP__ 23 | #define __SOUND_EXPORTER_HPP__ 24 | 25 | #include 26 | #include 27 | 28 | #include "../emucore/m6502/src/bspf/src/bspf.hxx" 29 | 30 | namespace ale { 31 | namespace sound { 32 | 33 | template void write(std::ofstream& stream, const T& t) { 34 | stream.write((const char*)&t, sizeof(T)); 35 | } 36 | 37 | class SoundExporter { 38 | public: 39 | static const int SamplesPerFrame = 512; 40 | 41 | using SampleType = uInt8; 42 | 43 | /** Create a new sound exporter which, on program termination, will write out a wav file. */ 44 | SoundExporter(const std::string& filename, int channels); 45 | ~SoundExporter(); 46 | 47 | /** Adds a buffer of samples. */ 48 | void addSamples(SampleType* s, int len); 49 | 50 | private: 51 | /** Writes the data to disk. */ 52 | void writeWAVData(); 53 | 54 | /** The file to save our audio to. */ 55 | std::string m_filename; 56 | 57 | /** Number of channels. */ 58 | int m_channels; 59 | 60 | /** The sound data. */ 61 | std::vector m_data; 62 | 63 | /** Keep track of how many samples have been written since the last write to disk */ 64 | size_t m_samples_since_write; 65 | }; 66 | 67 | } // namespace sound 68 | } // namespace ale 69 | 70 | #endif // __SOUND_EXPORTER_HPP__ 71 | -------------------------------------------------------------------------------- /src/ale/src/os_dependent/OSystemUNIX.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: OSystemUNIX.cxx,v 1.27 2007/07/19 16:21:39 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "bspf.hxx" 28 | #include "OSystem.hxx" 29 | #include "OSystemUNIX.hxx" 30 | using namespace std; 31 | 32 | //ALE #ifdef HAVE_GETTIMEOFDAY 33 | #include 34 | #include 35 | //ALE #endif 36 | 37 | /** 38 | Each derived class is responsible for calling the following methods 39 | in its constructor: 40 | 41 | setBaseDir() 42 | setConfigFile() 43 | 44 | See OSystem.hxx for a further explanation 45 | */ 46 | 47 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 48 | OSystemUNIX::OSystemUNIX() 49 | : OSystem() 50 | { 51 | //ALE const string& basedir = string(getenv("HOME")) + "/.stella"; 52 | string basedir = string("."); //ALE 53 | setBaseDir(basedir); 54 | setConfigFile(basedir + "/ale.cfg"); 55 | } 56 | 57 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 58 | OSystemUNIX::~OSystemUNIX() 59 | { 60 | } 61 | 62 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 63 | uInt32 OSystemUNIX::getTicks() { 64 | //ALE #ifdef HAVE_GETTIMEOFDAY 65 | timeval now; 66 | gettimeofday(&now, 0); 67 | return (uInt32) (now.tv_sec * 1000000 + now.tv_usec); 68 | //ALE #else 69 | //ALE return (uInt32) SDL_GetTicks() * 1000; 70 | //ALE #endif 71 | } 72 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Serializer.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Serializer.cxx,v 1.11 2007/01/01 18:04:49 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include "Serializer.hxx" 20 | using namespace std; 21 | 22 | 23 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 24 | Serializer::Serializer(void) { 25 | myStream.clear(); 26 | 27 | } 28 | 29 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 30 | Serializer::~Serializer(void) 31 | { 32 | close(); 33 | } 34 | 35 | 36 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 37 | void Serializer::close(void) 38 | { 39 | myStream.clear(); 40 | } 41 | 42 | 43 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 44 | void Serializer::putInt(int value) 45 | { 46 | unsigned char buf[4]; 47 | for(int i = 0; i < 4; ++i) 48 | buf[i] = (value >> (i<<3)) & 0xff; 49 | 50 | myStream.write((char*)buf, 4); 51 | if(myStream.bad()) 52 | throw "Serializer: file write failed"; 53 | } 54 | 55 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 56 | void Serializer::putString(const string& str) 57 | { 58 | int len = str.length(); 59 | putInt(len); 60 | myStream.write(str.data(), (streamsize)len); 61 | 62 | if(myStream.bad()) 63 | throw "Serializer: file write failed"; 64 | } 65 | 66 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 67 | void Serializer::putBool(bool b) 68 | { 69 | putInt(b ? TruePattern: FalsePattern); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Turmoil.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __TURMOIL_HPP__ 14 | #define __TURMOIL_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for Turmoil */ 21 | class TurmoilSettings : public RomSettings { 22 | public: 23 | TurmoilSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | // MD5 sum of ROM file: 36 | // 7a5463545dfb2dcfdafa6074b2f2c15e Turmoil.bin 37 | const char* rom() const override { return "turmoil"; } 38 | 39 | // create a new instance of the rom 40 | RomSettings* clone() const override; 41 | 42 | // is an action part of the minimal set? 43 | bool isMinimal(const Action& a) const override; 44 | 45 | // process the latest information from ALE 46 | void step(const System& system) override; 47 | 48 | // saves the state of the rom settings 49 | void saveState(Serializer& ser) override; 50 | 51 | // loads the state of the rom settings 52 | void loadState(Deserializer& ser) override; 53 | 54 | // Turmoil requires the fire action to start the game 55 | ActionVect getStartingActions() override; 56 | 57 | int lives() override { return isTerminal() ? 0 : m_lives; } 58 | 59 | ModeVect getAvailableModes() override; 60 | 61 | void setMode(game_mode_t m, System& system, 62 | std::unique_ptr environment) override; 63 | 64 | private: 65 | bool m_terminal; 66 | reward_t m_reward; 67 | reward_t m_score; 68 | int m_lives; 69 | }; 70 | 71 | } // namespace ale 72 | 73 | #endif // __TURMOIL_HPP__ 74 | -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/elements.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 1994,2001-2003 Nick Ing-Simmons. All rights reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Library General Public 6 | License as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public 15 | License along with this library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 | MA 02111-1307, USA 18 | 19 | */ 20 | #include 21 | /* $Id: elements.c,v 1.1 2006/06/11 07:13:24 urchlay Exp $ 22 | */ 23 | char *elements_id = "$Id: elements.c,v 1.1 2006/06/11 07:13:24 urchlay Exp $"; 24 | #include 25 | #include 26 | #include "rsynth.h" 27 | #include "phfeat.h" 28 | 29 | 30 | Elm_t Elements[] = { 31 | #include "Elements.def" 32 | }; 33 | 34 | unsigned num_Elements = (sizeof(Elements) / sizeof(Elm_t)); 35 | 36 | char *Ep_name[nEparm] = { 37 | "fn", "f1", "f2", "f3", 38 | "b1", "b2", "b3", "pn", 39 | "a2", "a3", "a4", 40 | "a5", "a6", "ab", "av", 41 | "avc", "asp", "af" 42 | }; 43 | 44 | speaker_t * 45 | rsynth_speaker(float F0Hz, float gain, Elm_t * e) 46 | { 47 | static speaker_t pars; 48 | // memset(&pars,-1,sizeof(pars)); 49 | pars.F0Hz = F0Hz; 50 | 51 | /* Quasi fixed parameters */ 52 | pars.Gain0 = gain; 53 | pars.F4hz = 3900; 54 | pars.B4hz = 400; 55 | pars.F5hz = 4700; 56 | pars.B5hz = 150; 57 | pars.F6hz = 4900; 58 | pars.B6hz = 150; 59 | 60 | pars.B4phz = 500; 61 | pars.B5phz = 600; 62 | pars.B6phz = 800; 63 | 64 | pars.BNhz = 500; 65 | 66 | /* Set the _fixed_ nasal pole to nasal zero frequency of the 0th element 67 | (which should NOT be a nasal!) as a typical example of the zero 68 | we wish to cancel 69 | 70 | */ 71 | pars.FNPhz = (long) e->p[fn].stdy; 72 | return &pars; 73 | } 74 | -------------------------------------------------------------------------------- /src/ale/src/common/Constants.cpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Atari 2600 Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf 4 | * Released under GNU General Public License www.gnu.org/licenses/gpl-3.0.txt 5 | * 6 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 7 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 8 | * 9 | * ***************************************************************************** 10 | * Constants.cpp 11 | * 12 | * Defines a set of constants used by various parts of the player agent code 13 | * 14 | **************************************************************************** */ 15 | 16 | #include "Constants.h" 17 | 18 | #include 19 | #include 20 | 21 | namespace ale { 22 | 23 | std::string action_to_string(Action a) { 24 | static std::string tmp_action_to_string[] = { 25 | "PLAYER_A_NOOP", 26 | "PLAYER_A_FIRE", 27 | "PLAYER_A_UP", 28 | "PLAYER_A_RIGHT", 29 | "PLAYER_A_LEFT", 30 | "PLAYER_A_DOWN", 31 | "PLAYER_A_UPRIGHT", 32 | "PLAYER_A_UPLEFT", 33 | "PLAYER_A_DOWNRIGHT", 34 | "PLAYER_A_DOWNLEFT", 35 | "PLAYER_A_UPFIRE", 36 | "PLAYER_A_RIGHTFIRE", 37 | "PLAYER_A_LEFTFIRE", 38 | "PLAYER_A_DOWNFIRE", 39 | "PLAYER_A_UPRIGHTFIRE", 40 | "PLAYER_A_UPLEFTFIRE", 41 | "PLAYER_A_DOWNRIGHTFIRE", 42 | "PLAYER_A_DOWNLEFTFIRE", 43 | "PLAYER_B_NOOP", 44 | "PLAYER_B_FIRE", 45 | "PLAYER_B_UP", 46 | "PLAYER_B_RIGHT", 47 | "PLAYER_B_LEFT", 48 | "PLAYER_B_DOWN", 49 | "PLAYER_B_UPRIGHT", 50 | "PLAYER_B_UPLEFT", 51 | "PLAYER_B_DOWNRIGHT", 52 | "PLAYER_B_DOWNLEFT", 53 | "PLAYER_B_UPFIRE", 54 | "PLAYER_B_RIGHTFIRE", 55 | "PLAYER_B_LEFTFIRE", 56 | "PLAYER_B_DOWNFIRE", 57 | "PLAYER_B_UPRIGHTFIRE", 58 | "PLAYER_B_UPLEFTFIRE", 59 | "PLAYER_B_DOWNRIGHTFIRE", 60 | "PLAYER_B_DOWNLEFTFIRE", 61 | "__invalid__", // 36 62 | "__invalid__", // 37 63 | "__invalid__", // 38 64 | "__invalid__", // 39 65 | "RESET", // 40 66 | "UNDEFINED", // 41 67 | "RANDOM", // 42 68 | }; 69 | assert(a >= 0 && a <= 42); 70 | return tmp_action_to_string[a]; 71 | } 72 | 73 | } // namespace ale 74 | -------------------------------------------------------------------------------- /src/ale/src/games/RomSettings.cpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | * 12 | * RomSettings.cpp 13 | * 14 | * The interface to describe games as RL environments. It provides terminal and 15 | * reward information. 16 | * ***************************************************************************** 17 | */ 18 | 19 | #include "RomSettings.hpp" 20 | 21 | #include 22 | 23 | namespace ale { 24 | 25 | RomSettings::RomSettings() {} 26 | 27 | bool RomSettings::isLegal(const Action& a) const { 28 | return true; 29 | } 30 | 31 | ActionVect RomSettings::getMinimalActionSet() { 32 | ActionVect actions; 33 | for (int a = 0; a < PLAYER_B_NOOP; a++) { 34 | if (isMinimal((Action)a) && isLegal((Action)a)) { 35 | actions.push_back((Action)a); 36 | } 37 | } 38 | return actions; 39 | } 40 | 41 | ActionVect RomSettings::getAllActions() { 42 | ActionVect actions; 43 | for (int a = 0; a < PLAYER_B_NOOP; a++) { 44 | if (isLegal((Action)a)) { 45 | actions.push_back((Action)a); 46 | } 47 | } 48 | return actions; 49 | } 50 | 51 | ActionVect RomSettings::getStartingActions() { 52 | return ActionVect(); 53 | } 54 | 55 | ModeVect RomSettings::getAvailableModes() { 56 | return ModeVect(1, 0); 57 | } 58 | 59 | void RomSettings::setMode(game_mode_t m, System&, std::unique_ptr) { 60 | // By default, 0 is the only available mode 61 | if (m != 0) { 62 | throw std::runtime_error("This mode is not currently available for this game"); 63 | } 64 | } 65 | 66 | DifficultyVect RomSettings::getAvailableDifficulties() { 67 | return DifficultyVect(1, 0); 68 | } 69 | 70 | bool RomSettings::isModeSupported(game_mode_t m) { 71 | auto modes = getAvailableModes(); 72 | return std::find(modes.begin(), modes.end(), m) != modes.end(); 73 | } 74 | 75 | } // namespace ale 76 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Random.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Random.hxx,v 1.4 2007/01/01 18:04:49 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef RANDOM_HXX 20 | #define RANDOM_HXX 21 | 22 | #include "m6502/src/bspf/src/bspf.hxx" 23 | 24 | class Serializer; 25 | class Deserializer; 26 | 27 | /** 28 | This Random class uses a Mersenne Twister to provide pseudorandom numbers. 29 | The class itself is derived from the original 'Random' class by Bradford W. Mott. 30 | */ 31 | class Random 32 | { 33 | public: 34 | 35 | /** 36 | Class method which allows you to set the seed that'll be used 37 | for created new instances of this class 38 | 39 | @param value The value to seed the random number generator with 40 | */ 41 | void seed(uInt32 value); 42 | 43 | /** 44 | Create a new random number generator 45 | */ 46 | Random(); 47 | 48 | ~Random(); 49 | 50 | /** 51 | Answer the next random number from the random number generator 52 | 53 | @return A random number 54 | */ 55 | uInt32 next(); 56 | 57 | /** 58 | Answer the next random number between 0 and 1 from the random number generator 59 | 60 | @return A random number between 0 and 1 61 | */ 62 | double nextDouble(); 63 | 64 | /** 65 | Serializes the RNG state. 66 | */ 67 | bool saveState(Serializer& out); 68 | 69 | /** 70 | Deserializes the RNG state. 71 | */ 72 | bool loadState(Deserializer& in); 73 | 74 | private: 75 | 76 | // Actual rng (implementation hidden away from the header to avoid depending on rng libraries). 77 | class Impl; 78 | Impl *m_pimpl; 79 | }; 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /src/ale/Copyright.txt: -------------------------------------------------------------------------------- 1 | =========================================================================== 2 | 3 | SSSS tt lll lll 4 | SS SS tt ll ll 5 | SS tttttt eeee ll ll aaaa 6 | SSSS tt ee ee ll ll aa 7 | SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | SS SS tt ee ll ll aa aa 9 | SSSS ttt eeeee llll llll aaaaa 10 | 11 | =========================================================================== 12 | License Information and Copyright Notice 13 | =========================================================================== 14 | 15 | Copyright (C) 1995-2012 Bradford W. Mott, Stephen Anthony and the 16 | Stella Team 17 | 18 | =========================================================================== 19 | The Arcade Learning Environment 20 | =========================================================================== 21 | 22 | Copyright (C) 2009-2012 Yavar Naddaf, Marc G. Bellemare, Joel Veness and the 23 | Artificial Intelligence Laboratory at the University of Alberta 24 | 25 | 26 | This program is free software; you can redistribute it and/or modify it 27 | under the terms of the GNU General Public License as published by the Free 28 | Software Foundation; either version 2 of the License, or any later version. 29 | 30 | You should have received a copy of the GNU General Public License version 2 31 | along with this program (License.txt); if not, write to the Free Software 32 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 33 | 34 | This program is distributed in the hope that it will be useful, but WITHOUT 35 | ANY WARRANTY. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO 36 | ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL 37 | DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY 38 | DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE 39 | POSSIBILITY OF SUCH DAMAGE. 40 | 41 | THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, 42 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS 44 | PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO 45 | OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 46 | MODIFICATIONS. 47 | -------------------------------------------------------------------------------- /test/alex_test.exs: -------------------------------------------------------------------------------- 1 | defmodule AlexTest do 2 | alias Alex.Interface 3 | use ExUnit.Case 4 | doctest Alex 5 | 6 | describe "Alex" do 7 | test "new/0" do 8 | assert %Interface{} = Alex.new() 9 | assert %Interface{display_screen: true} = Alex.new(display_screen: true) 10 | assert %Interface{random_seed: 123} = Alex.new(random_seed: 123) 11 | end 12 | 13 | test "load/2" do 14 | tetris = "priv/tetris.bin" 15 | interface = Alex.new() 16 | 17 | assert_raise RuntimeError, "Unsupported ROM: `priv/unsupported.bin`.", fn -> 18 | Alex.load(interface, "priv/unsupported.bin") 19 | end 20 | 21 | assert_raise RuntimeError, "Could not find ROM File: `bad/path/rom`.", fn -> 22 | Alex.load(interface, "bad/path/rom") 23 | end 24 | 25 | assert %Interface{rom: tetris} = Alex.load(interface, tetris) 26 | end 27 | 28 | test "step/2" do 29 | interface = Alex.new() 30 | interface = Alex.load(interface, "priv/tetris.bin") 31 | assert %Interface{frame: 1, episode_frame: 1} = Alex.step(interface, 2) 32 | end 33 | 34 | test "set_option/3" do 35 | interface = Alex.new() 36 | assert %Interface{display_screen: true} = Alex.set_option(interface, :display_screen, true) 37 | assert %Interface{display_screen: true} = Alex.set_option(interface, "display_screen", true) 38 | assert %Interface{random_seed: 123} = Alex.set_option(interface, :random_seed, 123) 39 | end 40 | 41 | test "set_state/2" do 42 | interface = Alex.new() 43 | interface = Alex.load(interface, "priv/tetris.bin") 44 | state1 = interface.state 45 | interface = Alex.step(interface, 1) 46 | state2 = interface.state 47 | interface = Alex.set_state(interface, state1) 48 | assert state1.encoded == interface.state.encoded 49 | interface = Alex.set_state(interface, state2) 50 | assert state2.encoded == interface.state.encoded 51 | end 52 | 53 | test "game_over?/1" do 54 | interface = Alex.new() 55 | interface = Alex.load(interface, "priv/tetris.bin") 56 | assert Alex.game_over?(interface) == false 57 | end 58 | 59 | test "reset/1" do 60 | interface = Alex.load(Alex.new(), "priv/tetris.bin") 61 | interface = Alex.step(interface, 1) 62 | assert %Interface{episode_frame: 0} = Alex.reset(interface) 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/AirRaid.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __AIRRAID_HPP__ 14 | #define __AIRRAID_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for Air Raid settings */ 21 | class AirRaidSettings : public RomSettings { 22 | public: 23 | AirRaidSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | const char* rom() const override { return "air_raid"; } 36 | 37 | // get the available number of modes 38 | unsigned int getNumModes() const { return 8; } 39 | 40 | // create a new instance of the rom 41 | RomSettings* clone() const override; 42 | 43 | // is an action part of the minimal set? 44 | bool isMinimal(const Action& a) const override; 45 | 46 | // process the latest information from ALE 47 | void step(const System& system) override; 48 | 49 | // saves the state of the rom settings 50 | void saveState(Serializer& ser) override; 51 | 52 | // loads the state of the rom settings 53 | void loadState(Deserializer& ser) override; 54 | 55 | ActionVect getStartingActions() override; 56 | 57 | // returns a list of mode that the game can be played in 58 | // in this game, there are 8 available modes 59 | ModeVect getAvailableModes() override; 60 | 61 | // set the mode of the game 62 | // the given mode must be one returned by the previous function 63 | void setMode(game_mode_t, System& system, 64 | std::unique_ptr environment) override; 65 | 66 | private: 67 | bool m_terminal; 68 | reward_t m_reward; 69 | reward_t m_score; 70 | }; 71 | 72 | } // namespace ale 73 | 74 | #endif // __AIRRAID_HPP__ 75 | -------------------------------------------------------------------------------- /src/ale/src/common/SoundNull.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: SoundNull.cxx,v 1.6 2007/01/01 18:04:40 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include "Serializer.hxx" 20 | #include "Deserializer.hxx" 21 | 22 | #include "bspf.hxx" 23 | 24 | #include "OSystem.hxx" 25 | #include "Settings.hxx" 26 | #include "SoundNull.hxx" 27 | 28 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 29 | SoundNull::SoundNull(OSystem* osystem) 30 | : Sound(osystem) 31 | { 32 | // Show some info 33 | if(myOSystem->settings().getBool("showinfo")) 34 | std::cerr << "Sound disabled." << std::endl << std::endl; 35 | } 36 | 37 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 38 | SoundNull::~SoundNull() 39 | { 40 | } 41 | 42 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 43 | bool SoundNull::load(Deserializer& in) 44 | { 45 | std::string soundDevice = "TIASound"; 46 | if(in.getString() != soundDevice) 47 | return false; 48 | 49 | uInt8 reg; 50 | reg = (uInt8) in.getInt(); 51 | reg = (uInt8) in.getInt(); 52 | reg = (uInt8) in.getInt(); 53 | reg = (uInt8) in.getInt(); 54 | reg = (uInt8) in.getInt(); 55 | reg = (uInt8) in.getInt(); 56 | 57 | // myLastRegisterSetCycle 58 | in.getInt(); 59 | 60 | return true; 61 | } 62 | 63 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 64 | bool SoundNull::save(Serializer& out) 65 | { 66 | out.putString("TIASound"); 67 | 68 | uInt8 reg = 0; 69 | out.putInt(reg); 70 | out.putInt(reg); 71 | out.putInt(reg); 72 | out.putInt(reg); 73 | out.putInt(reg); 74 | out.putInt(reg); 75 | 76 | // myLastRegisterSetCycle 77 | out.putInt(0); 78 | 79 | return true; 80 | } 81 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Deserializer.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Deserializer.cxx,v 1.12 2007/01/01 18:04:47 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include "Deserializer.hxx" 20 | #include 21 | using namespace std; 22 | 23 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 24 | Deserializer::Deserializer(const string stream_str): 25 | myStream(stream_str) { 26 | 27 | } 28 | 29 | 30 | 31 | 32 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 33 | void Deserializer::close(void) 34 | { 35 | myStream.clear(); 36 | } 37 | 38 | 39 | 40 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 41 | int Deserializer::getInt(void) 42 | { 43 | if(myStream.eof()) 44 | throw "Deserializer: end of file"; 45 | 46 | int val = 0; 47 | unsigned char buf[4]; 48 | myStream.read((char*)buf, 4); 49 | for(int i = 0; i < 4; ++i) 50 | val += (int)(buf[i]) << (i<<3); 51 | 52 | return val; 53 | } 54 | 55 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 56 | string Deserializer::getString(void) 57 | { 58 | int len = getInt(); 59 | string str; 60 | str.resize((string::size_type)len); 61 | myStream.read(&str[0], (streamsize)len); 62 | 63 | if(myStream.bad()) 64 | throw "Deserializer: file read failed"; 65 | 66 | return str; 67 | } 68 | 69 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 70 | bool Deserializer::getBool(void) 71 | { 72 | bool result = false; 73 | 74 | int b = getInt(); 75 | if(b == (int)TruePattern) 76 | result = true; 77 | else if(b == (int)FalsePattern) 78 | result = false; 79 | else 80 | throw "Deserializer: data corruption"; 81 | 82 | return result; 83 | } 84 | -------------------------------------------------------------------------------- /src/ale/src/emucore/m6502/src/NullDev.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // MM MM 6666 555555 0000 2222 4 | // MMMM MMMM 66 66 55 00 00 22 22 5 | // MM MMM MM 66 55 00 00 22 6 | // MM M MM 66666 55555 00 00 22222 -- "A 6502 Microprocessor Emulator" 7 | // MM MM 66 66 55 00 00 22 8 | // MM MM 66 66 55 55 00 00 22 9 | // MM MM 6666 5555 0000 222222 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: NullDev.cxx,v 1.5 2007/01/01 18:04:51 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include "NullDev.hxx" 20 | #include "Serializer.hxx" 21 | #include "Deserializer.hxx" 22 | using namespace std; 23 | 24 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 25 | NullDevice::NullDevice() 26 | { 27 | } 28 | 29 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 30 | NullDevice::~NullDevice() 31 | { 32 | } 33 | 34 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 35 | const char* NullDevice::name() const 36 | { 37 | return "NULL"; 38 | } 39 | 40 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 41 | void NullDevice::reset() 42 | { 43 | } 44 | 45 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 46 | void NullDevice::install(System& system) 47 | { 48 | mySystem = &system; 49 | } 50 | 51 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 52 | uInt8 NullDevice::peek(uInt16 address) 53 | { 54 | cerr << hex << "NullDevice: peek(" << address << ")" << endl; 55 | return 0; 56 | } 57 | 58 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 59 | void NullDevice::poke(uInt16 address, uInt8 value) 60 | { 61 | cerr << hex << "NullDevice: poke(" << address << "," << value << ")" << endl; 62 | } 63 | 64 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 65 | bool NullDevice::save(Serializer& out) 66 | { 67 | return true; 68 | } 69 | 70 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 71 | bool NullDevice::load(Deserializer& in) 72 | { 73 | return true; 74 | } 75 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/LostLuggage.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #ifndef __LOSTLUGGAGE_HPP__ 14 | #define __LOSTLUGGAGE_HPP__ 15 | 16 | #include "../RomSettings.hpp" 17 | 18 | namespace ale { 19 | 20 | /* RL wrapper for Lost Luggage */ 21 | class LostLuggageSettings : public RomSettings { 22 | public: 23 | LostLuggageSettings(); 24 | 25 | // reset 26 | void reset() override; 27 | 28 | // is end of game 29 | bool isTerminal() const override; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const override; 33 | 34 | // the rom-name 35 | // MD5 7c00e7a205d3fda98eb20da7c9c50a55 36 | const char* rom() const override { return "lost_luggage"; } 37 | 38 | // create a new instance of the rom 39 | RomSettings* clone() const override; 40 | 41 | // is an action part of the minimal set? 42 | bool isMinimal(const Action& a) const override; 43 | 44 | // FIRE resets the game, prevent this 45 | bool isLegal(const Action& a) const override; 46 | 47 | // process the latest information from ALE 48 | void step(const System& system) override; 49 | 50 | // saves the state of the rom settings 51 | void saveState(Serializer& ser) override; 52 | 53 | // loads the state of the rom settings 54 | void loadState(Deserializer& ser) override; 55 | 56 | // LostLuggage requires the fire action to start the game 57 | ActionVect getStartingActions() override; 58 | 59 | int lives() override { return isTerminal() ? 0 : m_lives; } 60 | 61 | ModeVect getAvailableModes() override; 62 | 63 | void setMode(game_mode_t m, System& system, 64 | std::unique_ptr environment) override; 65 | 66 | DifficultyVect getAvailableDifficulties() override; 67 | 68 | private: 69 | bool m_terminal; 70 | reward_t m_reward; 71 | reward_t m_score; 72 | int m_lives; 73 | }; 74 | 75 | } // namespace ale 76 | 77 | #endif // __LOSTLUGGAGE_HPP__ 78 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Carnival.cpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #include "Carnival.hpp" 14 | 15 | #include "../RomUtils.hpp" 16 | 17 | namespace ale { 18 | 19 | CarnivalSettings::CarnivalSettings() { reset(); } 20 | 21 | /* create a new instance of the rom */ 22 | RomSettings* CarnivalSettings::clone() const { 23 | return new CarnivalSettings(*this); 24 | } 25 | 26 | /* process the latest information from ALE */ 27 | void CarnivalSettings::step(const System& system) { 28 | // update the reward 29 | reward_t score = getDecimalScore(0xAE, 0xAD, &system); 30 | score *= 10; 31 | m_reward = score - m_score; 32 | m_score = score; 33 | 34 | // update terminal status 35 | int ammo = readRam(&system, 0x83); 36 | m_terminal = ammo < 1; 37 | } 38 | 39 | /* is end of game */ 40 | bool CarnivalSettings::isTerminal() const { return m_terminal; }; 41 | 42 | /* get the most recently observed reward */ 43 | reward_t CarnivalSettings::getReward() const { return m_reward; } 44 | 45 | /* is an action part of the minimal set? */ 46 | bool CarnivalSettings::isMinimal(const Action& a) const { 47 | switch (a) { 48 | case PLAYER_A_NOOP: 49 | case PLAYER_A_FIRE: 50 | case PLAYER_A_RIGHT: 51 | case PLAYER_A_LEFT: 52 | case PLAYER_A_RIGHTFIRE: 53 | case PLAYER_A_LEFTFIRE: 54 | return true; 55 | default: 56 | return false; 57 | } 58 | } 59 | 60 | /* reset the state of the game */ 61 | void CarnivalSettings::reset() { 62 | m_reward = 0; 63 | m_score = 0; 64 | m_terminal = false; 65 | } 66 | 67 | /* saves the state of the rom settings */ 68 | void CarnivalSettings::saveState(Serializer& ser) { 69 | ser.putInt(m_reward); 70 | ser.putInt(m_score); 71 | ser.putBool(m_terminal); 72 | } 73 | 74 | // loads the state of the rom settings 75 | void CarnivalSettings::loadState(Deserializer& ser) { 76 | m_reward = ser.getInt(); 77 | m_score = ser.getInt(); 78 | m_terminal = ser.getBool(); 79 | } 80 | 81 | } // namespace ale 82 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Kaboom.cpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #include "Kaboom.hpp" 14 | 15 | #include 16 | 17 | #include "../RomUtils.hpp" 18 | 19 | namespace ale { 20 | 21 | KaboomSettings::KaboomSettings() { reset(); } 22 | 23 | /* create a new instance of the rom */ 24 | RomSettings* KaboomSettings::clone() const { 25 | return new KaboomSettings(*this); 26 | } 27 | 28 | /* process the latest information from ALE */ 29 | void KaboomSettings::step(const System& system) { 30 | // update the reward 31 | reward_t score = getDecimalScore(0xA5, 0xA4, 0xA3, &system); 32 | m_reward = score - m_score; 33 | m_score = score; 34 | 35 | // update terminal status 36 | int lives = readRam(&system, 0xA1); 37 | m_terminal = lives == 0x0 || m_score == 999999; 38 | } 39 | 40 | /* is end of game */ 41 | bool KaboomSettings::isTerminal() const { return m_terminal; }; 42 | 43 | /* get the most recently observed reward */ 44 | reward_t KaboomSettings::getReward() const { return m_reward; } 45 | 46 | /* is an action part of the minimal set? */ 47 | bool KaboomSettings::isMinimal(const Action& a) const { 48 | switch (a) { 49 | case PLAYER_A_NOOP: 50 | case PLAYER_A_FIRE: 51 | case PLAYER_A_RIGHT: 52 | case PLAYER_A_LEFT: 53 | return true; 54 | default: 55 | return false; 56 | } 57 | } 58 | 59 | /* reset the state of the game */ 60 | void KaboomSettings::reset() { 61 | m_reward = 0; 62 | m_score = 0; 63 | m_terminal = false; 64 | } 65 | 66 | /* saves the state of the rom settings */ 67 | void KaboomSettings::saveState(Serializer& ser) { 68 | ser.putInt(m_reward); 69 | ser.putInt(m_score); 70 | ser.putBool(m_terminal); 71 | } 72 | 73 | // loads the state of the rom settings 74 | void KaboomSettings::loadState(Deserializer& ser) { 75 | m_reward = ser.getInt(); 76 | m_score = ser.getInt(); 77 | m_terminal = ser.getBool(); 78 | } 79 | 80 | ActionVect KaboomSettings::getStartingActions() { 81 | return {PLAYER_A_FIRE}; 82 | } 83 | 84 | } // namespace ale 85 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Koolaid.cpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #include "Koolaid.hpp" 14 | 15 | #include "../RomUtils.hpp" 16 | 17 | namespace ale { 18 | 19 | KoolaidSettings::KoolaidSettings() { reset(); } 20 | 21 | /* create a new instance of the rom */ 22 | RomSettings* KoolaidSettings::clone() const { 23 | return new KoolaidSettings(*this); 24 | } 25 | 26 | /* process the latest information from ALE */ 27 | void KoolaidSettings::step(const System& system) { 28 | // update the reward 29 | int score = getDecimalScore(0x81, 0x80, &system); 30 | score *= 100; 31 | int reward = score - m_score; 32 | m_reward = reward; 33 | m_score = score; 34 | 35 | m_terminal = readRam(&system, 0xD1) == 0x80; 36 | } 37 | 38 | /* is end of game */ 39 | bool KoolaidSettings::isTerminal() const { return m_terminal; }; 40 | 41 | /* get the most recently observed reward */ 42 | reward_t KoolaidSettings::getReward() const { return m_reward; } 43 | 44 | /* is an action part of the minimal set? */ 45 | bool KoolaidSettings::isMinimal(const Action& a) const { 46 | switch (a) { 47 | case PLAYER_A_NOOP: 48 | case PLAYER_A_UP: 49 | case PLAYER_A_RIGHT: 50 | case PLAYER_A_LEFT: 51 | case PLAYER_A_DOWN: 52 | case PLAYER_A_UPRIGHT: 53 | case PLAYER_A_UPLEFT: 54 | case PLAYER_A_DOWNRIGHT: 55 | case PLAYER_A_DOWNLEFT: 56 | return true; 57 | default: 58 | return false; 59 | } 60 | } 61 | 62 | /* reset the state of the game */ 63 | void KoolaidSettings::reset() { 64 | m_reward = 0; 65 | m_score = 0; 66 | m_terminal = false; 67 | } 68 | 69 | /* saves the state of the rom settings */ 70 | void KoolaidSettings::saveState(Serializer& ser) { 71 | ser.putInt(m_reward); 72 | ser.putInt(m_score); 73 | ser.putBool(m_terminal); 74 | } 75 | 76 | // loads the state of the rom settings 77 | void KoolaidSettings::loadState(Deserializer& ser) { 78 | m_reward = ser.getInt(); 79 | m_score = ser.getInt(); 80 | m_terminal = ser.getBool(); 81 | } 82 | 83 | } // namespace ale 84 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Joystick.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Joystick.hxx,v 1.6 2007/01/01 18:04:48 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef JOYSTICK_HXX 20 | #define JOYSTICK_HXX 21 | 22 | #include "m6502/src/bspf/src/bspf.hxx" 23 | #include "Control.hxx" 24 | 25 | /** 26 | The standard Atari 2600 joystick controller. 27 | 28 | @author Bradford W. Mott 29 | @version $Id: Joystick.hxx,v 1.6 2007/01/01 18:04:48 stephena Exp $ 30 | */ 31 | class Joystick : public Controller 32 | { 33 | public: 34 | /** 35 | Create a new joystick controller plugged into the specified jack 36 | 37 | @param jack The jack the controller is plugged into 38 | @param event The event object to use for events 39 | */ 40 | Joystick(Jack jack, const Event& event); 41 | 42 | /** 43 | Destructor 44 | */ 45 | virtual ~Joystick(); 46 | 47 | public: 48 | /** 49 | Read the value of the specified digital pin for this controller. 50 | 51 | @param pin The pin of the controller jack to read 52 | @return The state of the pin 53 | */ 54 | virtual bool read(DigitalPin pin); 55 | 56 | /** 57 | Read the resistance at the specified analog pin for this controller. 58 | The returned value is the resistance measured in ohms. 59 | 60 | @param pin The pin of the controller jack to read 61 | @return The resistance at the specified pin 62 | */ 63 | virtual Int32 read(AnalogPin pin); 64 | 65 | /** 66 | Write the given value to the specified digital pin for this 67 | controller. Writing is only allowed to the pins associated 68 | with the PIA. Therefore you cannot write to pin six. 69 | 70 | @param pin The pin of the controller jack to write to 71 | @param value The value to write to the pin 72 | */ 73 | virtual void write(DigitalPin pin, bool value); 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/PORTING: -------------------------------------------------------------------------------- 1 | Hopefully most of unix/compiler variant issues should be handled by configure 2 | process. Thus porting issues should reduce (for UNIX-ish machines at least) 3 | to writing the audio driver. 4 | 5 | The interface to the driver is defined in hplay.h. 6 | There are three routines: 7 | 8 | extern int audio_init PROTO((int argc, char *argv[])); 9 | 10 | Do what ever is necessary to initialize audio. 11 | You can process any command line arguments to influence the 12 | behaviour. Use getargs() function to make this easy. 13 | Where it make sense copy options from other drivers e.g. -r for 14 | sample rate. 15 | 16 | This routine should also define the global variable samp_rate 17 | to define sample rate to the core synth. 18 | 19 | Sample rates in 8 - 12kHz range work best due to as yet unresolved 20 | problems with some of the digital filters. 21 | 22 | extern void audio_play PROTO((int n, short *data)); 23 | 24 | Send a block of 'n' 16 bit signed linear samples to the 25 | audio device. If your device requires uLaw samples (US telephone standard) 26 | then l2u.h defines routines which may help (example is Sun driver). 27 | 28 | extern void audio_term PROTO((void)); 29 | Close down audio device, probably waiting for buffer(s) to empty. 30 | 31 | To test your driver (which should be called xxxxplay.c where xxxx describes 32 | the system/hardware), link it to hplay.c, and "make". 33 | 34 | The brave/experienced might like to obtain and install GNU autoconf-2.0 (or 35 | latter?) and the GNU m4 it needs (m4-1.3 or latter), and try and get the new 36 | driver auto configured. 37 | 38 | When you have written your driver please contact me (nick@ing-simmons.net) 39 | if you are willing to let others use it. Please let me know the output of 40 | config.guess script to assist in merging into autoconf. 41 | 42 | ------------------------------------------------------------------------ 43 | 44 | Perfomance issues. 45 | 46 | For best speed in DSP is done in "float", 47 | but with strict IEEE-754 compliance turned off where possible. 48 | This is fastest because in general for modern RISC processors 49 | (e.g. SPARCs or at least some of them ...) 50 | 51 | - There is no integer multiply hardware 52 | - There IS floating point multiply hardware 53 | - Floating point multiply hardware cannot handle "double" in one pass. 54 | - Some of IEEE-754 options (e.g. denormals) are handled via software traps. 55 | 56 | Modern x86 (Athlon/P4 do okay with float as well.) 57 | 58 | The computations in opsynth.c should dominate the cpu requirements 59 | of the other levels. 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/ale/src/common/SoundExporter.cpp: -------------------------------------------------------------------------------- 1 | #include "SoundExporter.hpp" 2 | 3 | #include 4 | 5 | namespace ale { 6 | namespace sound { 7 | 8 | // Sample rate is 60Hz x SamplesPerFrame bytes 9 | // TODO(mgb): in reality this should be 31,400 Hz, but currently we are just short of this 10 | static const unsigned int SampleRate = 60 * SoundExporter::SamplesPerFrame; 11 | 12 | // Save wav file every 30 seconds 13 | static const unsigned int WriteInterval = SampleRate * 30; 14 | 15 | SoundExporter::SoundExporter(const std::string& filename, int channels) 16 | : m_filename(filename), m_channels(channels), m_samples_since_write(0) {} 17 | 18 | SoundExporter::~SoundExporter() { writeWAVData(); } 19 | 20 | void SoundExporter::addSamples(SampleType* s, int len) { 21 | // @todo -- currently we only support mono recording 22 | assert(m_channels == 1); 23 | 24 | for (int i = 0; i < len; i++) 25 | m_data.push_back(s[i]); 26 | 27 | // Periodically flush to disk (to avoid cases where the destructor is not called) 28 | m_samples_since_write += len; 29 | if (m_samples_since_write >= WriteInterval) { 30 | writeWAVData(); 31 | m_samples_since_write = 0; 32 | } 33 | } 34 | 35 | void SoundExporter::writeWAVData() { 36 | // Taken from http://stackoverflow.com/questions/22226872/two-problems-when-writing-to-wav-c 37 | // Open file stream 38 | std::ofstream stream(m_filename.c_str(), std::ios::binary); 39 | 40 | // Cast size into a 32-bit integer 41 | int bufSize = m_data.size(); 42 | 43 | // Header 44 | stream.write("RIFF", 4); // sGroupID (RIFF = Resource Interchange File Format) 45 | write(stream, 36 + bufSize); // dwFileLength 46 | stream.write("WAVE", 4); // sRiffType 47 | 48 | // Format chunk 49 | stream.write("fmt ", 4); // sGroupID (fmt = format) 50 | write(stream, 16); // Chunk size (of Format Chunk) 51 | write(stream, 1); // Format (1 = PCM) 52 | write(stream, m_channels); // Channels 53 | write(stream, SampleRate); // Sample Rate 54 | write(stream, SampleRate * m_channels * sizeof(SampleType)); // Byterate 55 | write(stream, m_channels * sizeof(SampleType)); // Frame size aka Block align 56 | write(stream, 8 * sizeof(SampleType)); // Bits per sample 57 | 58 | // Data chunk 59 | stream.write("data", 4); // sGroupID (data) 60 | stream.write((const char*)&bufSize, 4); // Chunk size (of Data, and thus of bufferSize) 61 | stream.write((const char*)&m_data[0], bufSize); // The samples DATA!!! 62 | } 63 | 64 | } // namespace sound 65 | } // namespace ale 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ALEx 2 | 3 | > (A)rcade (L)earning (E)nvironment for Eli(x)ir. 4 | 5 | [![Hex.pm](https://img.shields.io/hexpm/v/alex)](https://hex.pm/packages/alex) 6 | 7 | ![Tetris GIF](assets/alex.gif) 8 | 9 | ## Documentation 10 | 11 | * [ALEx Documentation](https://hexdocs.pm/alex/getting-started.html) 12 | * [Arcade Learning Environment Manual](https://github.com/mgbellemare/Arcade-Learning-Environment/blob/master/doc/manual/manual.pdf) 13 | * [Arcade Learning Environment: An Evaluation Platform for General Agents](https://arxiv.org/abs/1207.4708) 14 | 15 | ## Overview 16 | 17 | ALEx is an implementation of the [Arcade Learning Environment](https://github.com/mgbellemare/Arcade-Learning-Environment) for Elixir. 18 | 19 | > The Arcade Learning Environment (ALE) is a simple object-oriented framework that allows researchers and hobbyists to develop AI agents for Atari 2600 games. It is built on top of the Atari 2600 emulator [Stella](https://stella-emu.github.io/) and separates the details of emulation from agent design. 20 | 21 | ALEx exposes the ALE Interface through NIFs. It adds an additional abstraction around the interface that makes it easy to develop on top of the ALE in Elixir. 22 | 23 | You can interact with the ALE from the lower-level NIF interface, or you can use the higher level abstraction. 24 | 25 | ## Installation 26 | 27 | First, install ALE dependencies: 28 | 29 | ### Linux 30 | 31 | ```shell 32 | $ sudo apt-get install libsdl1.2-dev libsdl-gfx1.2-dev libsdl-image1.2-dev cmake 33 | ``` 34 | 35 | ### Mac 36 | 37 | ```shell 38 | $ brew install sdl 39 | $ brew install cmake 40 | ``` 41 | 42 | ### Windows 43 | 44 | I haven't tested this with Windows yet, but I assume it should be straightforward to run. If anybody gets it working please open a pull request with your instructions. 45 | 46 | ### Mix 47 | 48 | Then, add `alex` to your dependencies in `mix.exs`: 49 | 50 | ```elixir 51 | def deps do 52 | [ 53 | {:alex, "~> 0.3.1"} 54 | ] 55 | end 56 | ``` 57 | 58 | Finally, run `mix do deps.get, deps.compile`. The first compilation will take quite a bit of time. 59 | 60 | ## Examples 61 | 62 | ALEx comes with a Tetris agent example. To run, ensure you have the required dependencies installed and clone the repo. Then run: `mix run examples/random_agent.exs`. 63 | 64 | The agent will make random actions over the course of a Tetris game. 65 | 66 | ## ROMs 67 | 68 | ALEx supports all ROMs supported by ALE. ROMs are easy to find online. This Repo comes with a Tetris ROM. 69 | 70 | See [Supported ROMs](https://hexdocs.pm/alex/supported-roms.html#content). 71 | 72 | ## Contributing 73 | 74 | To contribute, please either create a pull request or open an issue. 75 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Keyboard.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Keyboard.hxx,v 1.6 2007/01/01 18:04:48 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef KEYBOARD_HXX 20 | #define KEYBOARD_HXX 21 | 22 | #include "m6502/src/bspf/src/bspf.hxx" 23 | #include "Control.hxx" 24 | 25 | /** 26 | The standard Atari 2600 keyboard controller 27 | 28 | @author Bradford W. Mott 29 | @version $Id: Keyboard.hxx,v 1.6 2007/01/01 18:04:48 stephena Exp $ 30 | */ 31 | class Keyboard : public Controller 32 | { 33 | public: 34 | /** 35 | Create a new keyboard controller plugged into the specified jack 36 | 37 | @param jack The jack the controller is plugged into 38 | @param event The event object to use for events 39 | */ 40 | Keyboard(Jack jack, const Event& event); 41 | 42 | /** 43 | Destructor 44 | */ 45 | virtual ~Keyboard(); 46 | 47 | public: 48 | /** 49 | Read the value of the specified digital pin for this controller. 50 | 51 | @param pin The pin of the controller jack to read 52 | @return The state of the pin 53 | */ 54 | virtual bool read(DigitalPin pin); 55 | 56 | /** 57 | Read the resistance at the specified analog pin for this controller. 58 | The returned value is the resistance measured in ohms. 59 | 60 | @param pin The pin of the controller jack to read 61 | @return The resistance at the specified pin 62 | */ 63 | virtual Int32 read(AnalogPin pin); 64 | 65 | /** 66 | Write the given value to the specified digital pin for this 67 | controller. Writing is only allowed to the pins associated 68 | with the PIA. Therefore you cannot write to pin six. 69 | 70 | @param pin The pin of the controller jack to write to 71 | @param value The value to write to the pin 72 | */ 73 | virtual void write(DigitalPin pin, bool value); 74 | 75 | private: 76 | // State of the output pins 77 | uInt8 myPinState; 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /guides/getting-started.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | ALEx is an implementation of the Arcade Learning Environment for Elixir. 4 | 5 | ## Install ALEx 6 | 7 | See the [Installation Guide](installation.html). 8 | 9 | ## Creating a Random Agent 10 | 11 | Interaction with ALEx is easy. First, create a new interface and set your confgiuration options: 12 | 13 | ``` 14 | # Create ALEx interface 15 | interface = Alex.new() 16 | 17 | # Set options 18 | interface = 19 | interface 20 | |> Alex.set_option(:display_screen, true) 21 | |> Alex.set_option(:random_seed, 123) 22 | ``` 23 | 24 | You can also pass options as a `Keyword` to `Alex.new/1`: 25 | 26 | ``` 27 | interface = Alex.new(display_screen: true, random_seed: 123) 28 | ``` 29 | 30 | Next, load a ROM: 31 | 32 | ``` 33 | # Load Tetris 34 | tetris = Alex.load(interface, "priv/tetris.bin") 35 | ``` 36 | 37 | Finally, play an episode: 38 | 39 | ``` 40 | episode = 41 | fn game, episode -> 42 | # If the game is over, return the score 43 | if Alex.game_over?(game) do 44 | game.reward 45 | else 46 | # Take a random action 47 | game = Alex.step(game, Enum.random(game.legal_actions)) 48 | episode.(game, episode) 49 | end 50 | end 51 | 52 | # Run an episode 53 | tetris = episode.(tetris, episode) 54 | ``` 55 | 56 | ## Starting Over 57 | 58 | You can easily restart an episode with `Alex.reset/1`: 59 | 60 | ``` 61 | tetris = episode.(tetris, episode) 62 | 63 | # Run it back from the start 64 | tetris = Alex.reset(tetris) 65 | tetris = episode.(tetris, episode) 66 | ``` 67 | 68 | ## Taking a Screenshot 69 | 70 | ALEx allows you to take a screenshot of the current screen at any time using `Alex.screenshot/2`: 71 | 72 | ``` 73 | # Run an episode 74 | tetris = episode(tetris, episode) 75 | 76 | # See how it ended 77 | Alex.screenshot(tetris) 78 | ``` 79 | 80 | You can provide a path. The default path is the current directory with the current UTC time. 81 | 82 | ## Supported ROMs 83 | 84 | ALEx supports all ROMS supported by the ALE. ROMs can be easily found on repositories online. ALEx will verify the checksum of a ROM automatically before loading it. 85 | 86 | [Supported ROMs](supported-roms.html) has a list of all supported ROMs and their MD5 checksums. 87 | 88 | ## Configuring ALEx 89 | 90 | See the [Configuration Guide](configuration.html). 91 | 92 | ## More Information 93 | 94 | You'll want to check out the [Arcade Learning Environment](https://github.com/mgbellemare/Arcade-Learning-Environment) to learn more. 95 | 96 | Additionally, you can check out the [manual](https://github.com/mgbellemare/Arcade-Learning-Environment/blob/master/doc/manual/manual.pdf). -------------------------------------------------------------------------------- /src/ale/src/emucore/rsynth/trie.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 1994,2001-2002 Nick Ing-Simmons. All rights reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Library General Public 6 | License as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public 15 | License along with this library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 | MA 02111-1307, USA 18 | 19 | */ 20 | 21 | #include "config.h" 22 | /* $Id: trie.c,v 1.1 2006/06/11 07:13:27 urchlay Exp $ 23 | */ 24 | char *trie_id = "$Id: trie.c,v 1.1 2006/06/11 07:13:27 urchlay Exp $"; 25 | #include "useconfig.h" 26 | #include 27 | #include "trie.h" 28 | 29 | struct trie_s { 30 | struct trie_s *otherwise; 31 | struct trie_s *more; 32 | void *value; 33 | char ch; 34 | }; 35 | 36 | void 37 | trie_free(trie_ptr * r, void (*func) (void *)) 38 | { 39 | trie_ptr p; 40 | while ((p = *r)) { 41 | trie_free(&p->more, func); 42 | *r = p->otherwise; 43 | if (func) 44 | (*func) (p->value); 45 | free(p); 46 | } 47 | } 48 | 49 | void 50 | trie_insert(trie_ptr * r, char *s, void *value) 51 | { 52 | trie_ptr p = NULL; 53 | char ch; 54 | while ((ch = *s++)) { 55 | while ((p = *r)) { 56 | if (p->ch == ch) 57 | break; 58 | else 59 | r = &p->otherwise; 60 | } 61 | if (!p) { 62 | p = (trie_ptr) malloc(sizeof(*p)); 63 | memset(p, 0, sizeof(*p)); 64 | p->ch = ch; 65 | *r = p; 66 | } 67 | r = &p->more; 68 | } 69 | p->value = value; 70 | } 71 | 72 | void * 73 | trie_lookup(trie_ptr * r, char **sp) 74 | { 75 | char *s = *sp; 76 | char *value = NULL; 77 | char ch; 78 | while ((ch = *s)) { 79 | trie_ptr *l = r; 80 | trie_ptr p; 81 | while ((p = *l)) { 82 | if (p->ch == ch) 83 | break; 84 | else 85 | l = &p->otherwise; 86 | } 87 | if (p) { 88 | *l = p->otherwise; 89 | p->otherwise = *r; 90 | *r = p; 91 | r = &p->more; 92 | value = (char *) p->value; 93 | s++; 94 | } 95 | else 96 | break; 97 | } 98 | *sp = s; 99 | return value; 100 | } 101 | -------------------------------------------------------------------------------- /src/ale/src/common/misc_tools.h: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | * misc_tools.h 12 | * 13 | * A set of miscellaneous tools used in various places. 14 | **************************************************************************** */ 15 | #ifndef __MISC_TOOLS_H__ 16 | #define __MISC_TOOLS_H__ 17 | 18 | #include "Constants.h" 19 | 20 | #if (defined(WIN32) || defined(__MINGW32__)) 21 | #include 22 | #endif 23 | 24 | namespace ale { 25 | 26 | /* ***************************************************************************** 27 | Inline C++ integer exponentiation routines 28 | Version 1.01 29 | Copyright (C) 1999-2004 John C. Bowman 30 | **************************************************************************** */ 31 | inline int pow(int x, int p) { 32 | if (p == 0) 33 | return 1; 34 | if (x == 0 && p > 0) 35 | return 0; 36 | if (p < 0) { 37 | assert(x == 1 || x == -1); 38 | return (-p % 2) ? x : 1; 39 | } 40 | 41 | int r = 1; 42 | for (;;) { 43 | if (p & 1) 44 | r *= x; 45 | if ((p >>= 1) == 0) 46 | return r; 47 | x *= x; 48 | } 49 | } 50 | 51 | /* ***************************************************************************** 52 | Makes x fit within the [uper, lower] bounds 53 | **************************************************************************** */ 54 | inline void bound(int& x, int lower_bound, int upper_bound) { 55 | if (x > upper_bound) { 56 | x = upper_bound; 57 | } 58 | if (x < lower_bound) { 59 | x = lower_bound; 60 | } 61 | } 62 | 63 | /* ***************************************************************************** 64 | Return time in milliseconds. 65 | **************************************************************************** */ 66 | #if (defined(WIN32) || defined(__MINGW32__)) 67 | 68 | #include 69 | 70 | inline long timeMillis() { return GetTickCount(); } 71 | 72 | #else 73 | 74 | inline long timeMillis() { 75 | struct timeval ts; 76 | gettimeofday(&ts, NULL); 77 | return ts.tv_sec * 1000 + ts.tv_usec / 1000; 78 | } 79 | 80 | #endif 81 | 82 | } // namespace ale 83 | 84 | #endif // __MISC_TOOLS_H__ 85 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Booster.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Booster.hxx,v 1.7 2007/01/01 18:04:45 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef BOOSTERGRIP_HXX 20 | #define BOOSTERGRIP_HXX 21 | 22 | #include "m6502/src/bspf/src/bspf.hxx" 23 | #include "Control.hxx" 24 | 25 | /** 26 | The standard Atari 2600 joystick controller fitted with the 27 | CBS Booster grip. The Booster grip has two more fire buttons 28 | on it (a booster and a trigger). 29 | 30 | @author Bradford W. Mott 31 | @version $Id: Booster.hxx,v 1.7 2007/01/01 18:04:45 stephena Exp $ 32 | */ 33 | class BoosterGrip : public Controller 34 | { 35 | public: 36 | /** 37 | Create a new booster grip joystick plugged into the specified jack 38 | 39 | @param jack The jack the controller is plugged into 40 | @param event The event object to use for events 41 | */ 42 | BoosterGrip(Jack jack, const Event& event); 43 | 44 | /** 45 | Destructor 46 | */ 47 | virtual ~BoosterGrip(); 48 | 49 | public: 50 | /** 51 | Read the value of the specified digital pin for this controller. 52 | 53 | @param pin The pin of the controller jack to read 54 | @return The state of the pin 55 | */ 56 | virtual bool read(DigitalPin pin); 57 | 58 | /** 59 | Read the resistance at the specified analog pin for this controller. 60 | The returned value is the resistance measured in ohms. 61 | 62 | @param pin The pin of the controller jack to read 63 | @return The resistance at the specified pin 64 | */ 65 | virtual Int32 read(AnalogPin pin); 66 | 67 | /** 68 | Write the given value to the specified digital pin for this 69 | controller. Writing is only allowed to the pins associated 70 | with the PIA. Therefore you cannot write to pin six. 71 | 72 | @param pin The pin of the controller jack to write to 73 | @param value The value to write to the pin 74 | */ 75 | virtual void write(DigitalPin pin, bool value); 76 | }; 77 | #endif 78 | 79 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Joystick.cxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Joystick.cxx,v 1.7 2007/01/05 17:54:23 stephena Exp $ 17 | //============================================================================ 18 | 19 | #include 20 | #include "Event.hxx" 21 | #include "Joystick.hxx" 22 | 23 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 24 | Joystick::Joystick(Jack jack, const Event& event) 25 | : Controller(jack, event, Controller::Joystick) 26 | { 27 | } 28 | 29 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 30 | Joystick::~Joystick() 31 | { 32 | } 33 | 34 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 35 | bool Joystick::read(DigitalPin pin) 36 | { 37 | switch(pin) 38 | { 39 | case One: 40 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroUp) == 0) : 41 | (myEvent.get(Event::JoystickOneUp) == 0); 42 | 43 | case Two: 44 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroDown) == 0) : 45 | (myEvent.get(Event::JoystickOneDown) == 0); 46 | 47 | case Three: 48 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroLeft) == 0) : 49 | (myEvent.get(Event::JoystickOneLeft) == 0); 50 | 51 | case Four: 52 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroRight) == 0) : 53 | (myEvent.get(Event::JoystickOneRight) == 0); 54 | 55 | case Six: 56 | return (myJack == Left) ? (myEvent.get(Event::JoystickZeroFire) == 0) : 57 | (myEvent.get(Event::JoystickOneFire) == 0); 58 | 59 | default: 60 | return true; 61 | } 62 | } 63 | 64 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 65 | Int32 Joystick::read(AnalogPin) 66 | { 67 | // Analog pins are not connect in joystick so we have infinite resistance 68 | return maximumResistance; 69 | } 70 | 71 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 72 | void Joystick::write(DigitalPin, bool) 73 | { 74 | // Writing doesn't do anything to the joystick... 75 | } 76 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Deserializer.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Deserializer.hxx,v 1.11 2007/01/01 18:04:47 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef DESERIALIZER_HXX 20 | #define DESERIALIZER_HXX 21 | 22 | #include 23 | #include "m6502/src/bspf/src/bspf.hxx" 24 | 25 | /** 26 | This class implements a Deserializer device, whereby data is 27 | deserialized from an input binary file in a system-independent 28 | way. 29 | 30 | All ints should be cast to their appropriate data type upon method 31 | return. 32 | 33 | @author Stephen Anthony 34 | @version $Id: Deserializer.hxx,v 1.11 2007/01/01 18:04:47 stephena Exp $ 35 | 36 | Revised for ALE on Sep 20, 2009 37 | The new version uses a stringstream (not a file stream) 38 | 39 | TODO: don't copy the whole streams. 40 | */ 41 | class Deserializer { 42 | public: 43 | /** 44 | Creates a new Deserializer device. 45 | */ 46 | Deserializer(const std::string stream_str); 47 | 48 | void close(void); 49 | 50 | /** 51 | Reads an int value from the current input stream. 52 | 53 | @result The int value which has been read from the stream. 54 | */ 55 | int getInt(void); 56 | 57 | /** 58 | Reads a string from the current input stream. 59 | 60 | @result The string which has been read from the stream. 61 | */ 62 | std::string getString(void); 63 | 64 | /** 65 | Reads a boolean value from the current input stream. 66 | 67 | @result The boolean value which has been read from the stream. 68 | */ 69 | bool getBool(void); 70 | 71 | bool isOpen(void) {return true;} 72 | private: 73 | // The stream to get the deserialized data from. 74 | std::stringstream myStream; 75 | 76 | enum { 77 | TruePattern = 0xfab1fab2, 78 | FalsePattern = 0xbad1bad2 79 | }; 80 | }; 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Tetris.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public License version 2 4 | * as published by the Free Software Foundation. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License 12 | * along with this program; if not, write to the Free Software 13 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | * ***************************************************************************** 15 | * A.L.E (Arcade Learning Environment) 16 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 17 | * the Reinforcement Learning and Artificial Intelligence Laboratory 18 | * Released under the GNU General Public License; see License.txt for details. 19 | * 20 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 21 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 22 | * 23 | * ***************************************************************************** 24 | */ 25 | 26 | #ifndef __TETRIS_HPP__ 27 | #define __TETRIS_HPP__ 28 | 29 | #include "../RomSettings.hpp" 30 | 31 | namespace ale { 32 | 33 | /* RL wrapper for Tetris */ 34 | class TetrisSettings : public RomSettings { 35 | public: 36 | TetrisSettings(); 37 | 38 | // reset 39 | void reset() override; 40 | 41 | // is end of game 42 | bool isTerminal() const override; 43 | 44 | // get the most recently observed reward 45 | reward_t getReward() const override; 46 | 47 | // the rom-name 48 | const char* rom() const override { return "tetris"; } 49 | 50 | // create a new instance of the rom 51 | RomSettings* clone() const override; 52 | 53 | // is an action part of the minimal set? 54 | bool isMinimal(const Action& a) const override; 55 | 56 | // process the latest information from ALE 57 | void step(const System& system) override; 58 | 59 | // saves the state of the rom settings 60 | void saveState(Serializer& ser) override; 61 | 62 | // loads the state of the rom settings 63 | void loadState(Deserializer& ser) override; 64 | 65 | // remaining lives 66 | int lives() override { return isTerminal() ? 0 : m_lives; } 67 | 68 | private: 69 | bool m_terminal; 70 | bool m_started; 71 | reward_t m_reward; 72 | reward_t m_score; 73 | int m_lives; 74 | }; 75 | 76 | } // namespace ale 77 | 78 | #endif // __TETRIS_HPP__ 79 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Driving.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Driving.hxx,v 1.6 2007/01/01 18:04:47 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef DRIVING_HXX 20 | #define DRIVING_HXX 21 | 22 | class Driving; 23 | class System; 24 | 25 | #include "m6502/src/bspf/src/bspf.hxx" 26 | #include "Control.hxx" 27 | 28 | /** 29 | The standard Atari 2600 Indy 500 driving controller. 30 | 31 | @author Bradford W. Mott 32 | @version $Id: Driving.hxx,v 1.6 2007/01/01 18:04:47 stephena Exp $ 33 | */ 34 | class Driving : public Controller 35 | { 36 | public: 37 | /** 38 | Create a new Indy 500 driving controller plugged into 39 | the specified jack 40 | 41 | @param jack The jack the controller is plugged into 42 | @param event The event object to use for events 43 | */ 44 | Driving(Jack jack, const Event& event); 45 | 46 | /** 47 | Destructor 48 | */ 49 | virtual ~Driving(); 50 | 51 | public: 52 | /** 53 | Read the value of the specified digital pin for this controller. 54 | 55 | @param pin The pin of the controller jack to read 56 | @return The state of the pin 57 | */ 58 | virtual bool read(DigitalPin pin); 59 | 60 | /** 61 | Read the resistance at the specified analog pin for this controller. 62 | The returned value is the resistance measured in ohms. 63 | 64 | @param pin The pin of the controller jack to read 65 | @return The resistance at the specified pin 66 | */ 67 | virtual Int32 read(AnalogPin pin); 68 | 69 | /** 70 | Write the given value to the specified digital pin for this 71 | controller. Writing is only allowed to the pins associated 72 | with the PIA. Therefore you cannot write to pin six. 73 | 74 | @param pin The pin of the controller jack to write to 75 | @param value The value to write to the pin 76 | */ 77 | virtual void write(DigitalPin pin, bool value); 78 | 79 | private: 80 | // Counter to iterate through the gray codes 81 | uInt32 myCounter; 82 | }; 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Carnival.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The line 67 is based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __CARNIVAL_HPP__ 29 | #define __CARNIVAL_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Carnival settings */ 36 | class CarnivalSettings : public RomSettings { 37 | public: 38 | CarnivalSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "carnival"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | int lives() override { return 0; } 68 | 69 | private: 70 | bool m_terminal; 71 | reward_t m_reward; 72 | reward_t m_score; 73 | }; 74 | 75 | } // namespace ale 76 | 77 | #endif // __CARNIVAL_HPP__ 78 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Krull.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 67 and 74 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __KRULL_HPP__ 29 | #define __KRULL_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Krull */ 36 | class KrullSettings : public RomSettings { 37 | public: 38 | KrullSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "krull"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | int lives() override { return isTerminal() ? 0 : m_lives; } 68 | 69 | private: 70 | bool m_terminal; 71 | reward_t m_reward; 72 | reward_t m_score; 73 | int m_lives; 74 | }; 75 | 76 | } // namespace ale 77 | 78 | #endif // __KRULL_HPP__ 79 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Phoenix.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 67 and 74 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __PHOENIX_HPP__ 29 | #define __PHOENIX_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Phoenix */ 36 | class PhoenixSettings : public RomSettings { 37 | public: 38 | PhoenixSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "phoenix"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | int lives() override { return isTerminal() ? 0 : m_lives; } 68 | 69 | private: 70 | bool m_terminal; 71 | reward_t m_reward; 72 | reward_t m_score; 73 | int m_lives; 74 | }; 75 | 76 | } // namespace ale 77 | 78 | #endif // __PHOENIX_HPP__ 79 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Solaris.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 67 and 74 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __SOLARIS_HPP__ 29 | #define __SOLARIS_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Solaris */ 36 | class SolarisSettings : public RomSettings { 37 | public: 38 | SolarisSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "solaris"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | int lives() override { return isTerminal() ? 0 : m_lives; } 68 | 69 | private: 70 | bool m_terminal; 71 | reward_t m_reward; 72 | reward_t m_score; 73 | int m_lives; 74 | }; 75 | 76 | } // namespace ale 77 | 78 | #endif // __SOLARIS_HPP__ 79 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Enduro.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The line 69 is based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __ENDURO_HPP__ 29 | #define __ENDURO_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Enduro settings */ 36 | class EnduroSettings : public RomSettings { 37 | public: 38 | EnduroSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "enduro"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | ActionVect getStartingActions() override; 68 | 69 | int lives() override { return 0; } 70 | 71 | private: 72 | bool m_terminal; 73 | reward_t m_reward; 74 | reward_t m_score; 75 | }; 76 | 77 | } // namespace ale 78 | 79 | #endif // __ENDURO_HPP__ 80 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/SirLancelot.cpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | */ 12 | 13 | #include "SirLancelot.hpp" 14 | 15 | #include "../RomUtils.hpp" 16 | 17 | namespace ale { 18 | 19 | SirLancelotSettings::SirLancelotSettings() { reset(); } 20 | 21 | /* create a new instance of the rom */ 22 | RomSettings* SirLancelotSettings::clone() const { 23 | return new SirLancelotSettings(*this); 24 | } 25 | 26 | /* process the latest information from ALE */ 27 | void SirLancelotSettings::step(const System& system) { 28 | // update the reward 29 | int score = getDecimalScore(0xA0, 0x9F, 0x9E, &system); 30 | int reward = score - m_score; 31 | m_reward = reward; 32 | m_score = score; 33 | 34 | // update terminal status 35 | m_lives = readRam(&system, 0xA9); 36 | m_terminal = (m_lives == 0) && readRam(&system, 0xA7) == 0xA0; 37 | } 38 | 39 | /* is end of game */ 40 | bool SirLancelotSettings::isTerminal() const { return m_terminal; }; 41 | 42 | /* get the most recently observed reward */ 43 | reward_t SirLancelotSettings::getReward() const { return m_reward; } 44 | 45 | /* is an action part of the minimal set? */ 46 | bool SirLancelotSettings::isMinimal(const Action& a) const { 47 | switch (a) { 48 | case PLAYER_A_NOOP: 49 | case PLAYER_A_FIRE: 50 | case PLAYER_A_RIGHT: 51 | case PLAYER_A_LEFT: 52 | case PLAYER_A_RIGHTFIRE: 53 | case PLAYER_A_LEFTFIRE: 54 | return true; 55 | default: 56 | return false; 57 | } 58 | } 59 | 60 | /* reset the state of the game */ 61 | void SirLancelotSettings::reset() { 62 | m_reward = 0; 63 | m_score = 0; 64 | m_terminal = false; 65 | m_lives = 3; 66 | } 67 | 68 | /* saves the state of the rom settings */ 69 | void SirLancelotSettings::saveState(Serializer& ser) { 70 | ser.putInt(m_reward); 71 | ser.putInt(m_score); 72 | ser.putBool(m_terminal); 73 | ser.putInt(m_lives); 74 | } 75 | 76 | // loads the state of the rom settings 77 | void SirLancelotSettings::loadState(Deserializer& ser) { 78 | m_reward = ser.getInt(); 79 | m_score = ser.getInt(); 80 | m_terminal = ser.getBool(); 81 | m_lives = ser.getInt(); 82 | } 83 | 84 | ActionVect SirLancelotSettings::getStartingActions() { 85 | return {RESET, PLAYER_A_LEFT}; 86 | } 87 | 88 | } // namespace ale 89 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Assault.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 67 and 74 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __ASSAULT_HPP__ 29 | #define __ASSAULT_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Assault settings */ 36 | class AssaultSettings : public RomSettings { 37 | public: 38 | AssaultSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "assault"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | int lives() override { return isTerminal() ? 0 : m_lives; } 68 | 69 | private: 70 | bool m_terminal; 71 | reward_t m_reward; 72 | reward_t m_score; 73 | int m_lives; 74 | }; 75 | 76 | } // namespace ale 77 | 78 | #endif // __ASSAULT_HPP__ 79 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/RoboTank.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 67 and 74 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __ROBOTANK_HPP__ 29 | #define __ROBOTANK_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for RoboTank */ 36 | class RoboTankSettings : public RomSettings { 37 | public: 38 | RoboTankSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "robotank"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | int lives() override { return isTerminal() ? 0 : m_lives; } 68 | 69 | private: 70 | bool m_terminal; 71 | reward_t m_reward; 72 | reward_t m_score; 73 | int m_lives; 74 | }; 75 | 76 | } // namespace ale 77 | 78 | #endif // __ROBOTANK_HPP__ 79 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/RoadRunner.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 67 and 74 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __ROADRUNNER_HPP__ 29 | #define __ROADRUNNER_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Road Runner */ 36 | class RoadRunnerSettings : public RomSettings { 37 | public: 38 | RoadRunnerSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "road_runner"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | int lives() override { return isTerminal() ? 0 : m_lives; } 68 | 69 | private: 70 | bool m_terminal; 71 | reward_t m_reward; 72 | reward_t m_score; 73 | int m_lives; 74 | }; 75 | 76 | } // namespace ale 77 | 78 | #endif // __ROADRUNNER_HPP__ 79 | -------------------------------------------------------------------------------- /src/ale/src/common/display_screen.h: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare, 4 | * Matthew Hausknecht, and the Reinforcement Learning and Artificial Intelligence 5 | * Laboratory 6 | * Released under the GNU General Public License; see License.txt for details. 7 | * 8 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 9 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 10 | * 11 | * ***************************************************************************** 12 | * diplay_screen.cpp 13 | * 14 | * Supports displaying the screen via SDL. 15 | **************************************************************************** */ 16 | 17 | #ifndef DISPLAY_SCREEN_H 18 | #define DISPLAY_SCREEN_H 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include "Constants.h" 26 | #include "ColourPalette.hpp" 27 | #include "../emucore/MediaSrc.hxx" 28 | 29 | #ifdef __USE_SDL 30 | 31 | #include "SDL.h" 32 | 33 | namespace ale { 34 | 35 | class DisplayScreen { 36 | public: 37 | DisplayScreen(MediaSource* mediaSource, Sound* sound, ColourPalette& palette); 38 | virtual ~DisplayScreen(); 39 | 40 | // Displays the current frame buffer from the mediasource. 41 | void display_screen(); 42 | 43 | // Has the user engaged manual control mode? 44 | bool manual_control_engaged() { return manual_control_active; } 45 | 46 | // Captures the keypress of a user in manual control mode. 47 | Action getUserAction(); 48 | 49 | protected: 50 | // Checks for SDL events. 51 | void poll(); 52 | 53 | // Handle the SDL_Event. 54 | void handleSDLEvent(const SDL_Event& event); 55 | 56 | protected: 57 | // Dimensions of the SDL window (4:3 aspect ratio) 58 | static const int window_height = 321; 59 | static const int window_width = 428; 60 | // Maintains the paused/unpaused state of the game 61 | bool manual_control_active; 62 | MediaSource* media_source; 63 | Sound* my_sound; 64 | ColourPalette& colour_palette; 65 | int screen_height, screen_width; 66 | SDL_Surface *screen, *image; 67 | float yratio, xratio; 68 | Uint32 delay_msec; 69 | // Used to calibrate delay between frames 70 | Uint32 last_frame_time; 71 | }; 72 | 73 | } // namespace ale 74 | 75 | #else 76 | 77 | namespace ale { 78 | 79 | /** A dummy class that simply ignores display events. */ 80 | class DisplayScreen { 81 | public: 82 | DisplayScreen(MediaSource*, Sound*, ColourPalette&) {} 83 | void display_screen() {} 84 | bool manual_control_engaged() { return false; } 85 | Action getUserAction() { return UNDEFINED; } 86 | }; 87 | 88 | } // namespace ale 89 | 90 | #endif // __USE_SDL 91 | 92 | #endif // DISPLAY_SCREEN 93 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/KungFuMaster.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 67 and 74 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __KUNGFUMASTER_HPP__ 29 | #define __KUNGFUMASTER_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Kung Fu Master */ 36 | class KungFuMasterSettings : public RomSettings { 37 | public: 38 | KungFuMasterSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "kung_fu_master"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | int lives() override { return isTerminal() ? 0 : m_lives; } 68 | 69 | private: 70 | bool m_terminal; 71 | reward_t m_reward; 72 | reward_t m_score; 73 | int m_lives; 74 | }; 75 | 76 | } // namespace ale 77 | 78 | #endif // __KUNGFUMASTER_HPP__ 79 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Pitfall.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 69 and 76 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __PITFALL_HPP__ 29 | #define __PITFALL_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Phoenix */ 36 | class PitfallSettings : public RomSettings { 37 | public: 38 | PitfallSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "pitfall"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | ActionVect getStartingActions() override; 68 | 69 | int lives() override { return isTerminal() ? 0 : m_lives; } 70 | 71 | private: 72 | bool m_terminal; 73 | reward_t m_reward; 74 | reward_t m_score; 75 | int m_lives; 76 | }; 77 | 78 | } // namespace ale 79 | 80 | #endif // __PITFALL_HPP__ 81 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Skiing.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The line 71 is based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __SKIING_HPP__ 29 | #define __SKIING_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Skiing */ 36 | class SkiingSettings : public RomSettings { 37 | public: 38 | SkiingSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "skiing"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | bool isLegal(const Action& a) const override; 59 | 60 | // process the latest information from ALE 61 | void step(const System& system) override; 62 | 63 | // saves the state of the rom settings 64 | void saveState(Serializer& ser) override; 65 | 66 | // loads the state of the rom settings 67 | void loadState(Deserializer& ser) override; 68 | 69 | ActionVect getStartingActions() override; 70 | 71 | int lives() override { return 0; } 72 | 73 | private: 74 | bool m_terminal; 75 | reward_t m_reward; 76 | reward_t m_score; 77 | }; 78 | 79 | } // namespace ale 80 | 81 | #endif // __SKIING_HPP__ 82 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/MontezumaRevenge.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 67 and 74 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __MONTEZUMAREVENGE_HPP__ 29 | #define __MONTEZUMAREVENGE_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Montezuma Revenge */ 36 | class MontezumaRevengeSettings : public RomSettings { 37 | public: 38 | MontezumaRevengeSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "montezuma_revenge"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | int lives() override { return isTerminal() ? 0 : m_lives; } 68 | 69 | private: 70 | bool m_terminal; 71 | reward_t m_reward; 72 | reward_t m_score; 73 | int m_lives; 74 | }; 75 | 76 | } // namespace ale 77 | 78 | #endif // __MONTEZUMAREVENGE_HPP__ 79 | -------------------------------------------------------------------------------- /src/ale/src/emucore/Paddles.hxx: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // 3 | // SSSS tt lll lll 4 | // SS SS tt ll ll 5 | // SS tttttt eeee ll ll aaaa 6 | // SSSS tt ee ee ll ll aa 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 | // SS SS tt ee ll ll aa aa 9 | // SSSS ttt eeeee llll llll aaaaa 10 | // 11 | // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 12 | // 13 | // See the file "license" for information on usage and redistribution of 14 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. 15 | // 16 | // $Id: Paddles.hxx,v 1.7 2007/01/01 18:04:49 stephena Exp $ 17 | //============================================================================ 18 | 19 | #ifndef PADDLES_HXX 20 | #define PADDLES_HXX 21 | 22 | #include "m6502/src/bspf/src/bspf.hxx" 23 | #include "Control.hxx" 24 | #include "Event.hxx" 25 | 26 | /** 27 | The standard Atari 2600 pair of paddle controllers. 28 | 29 | @author Bradford W. Mott 30 | @version $Id: Paddles.hxx,v 1.7 2007/01/01 18:04:49 stephena Exp $ 31 | */ 32 | class Paddles : public Controller 33 | { 34 | public: 35 | /** 36 | Create a new pair of paddle controllers plugged into the specified jack 37 | 38 | @param jack The jack the controller is plugged into 39 | @param event The event object to use for events 40 | @param swap Whether to swap the paddles plugged into this jack 41 | */ 42 | Paddles(Jack jack, const Event& event, bool swap); 43 | 44 | /** 45 | Destructor 46 | */ 47 | virtual ~Paddles(); 48 | 49 | public: 50 | /** 51 | Read the value of the specified digital pin for this controller. 52 | 53 | @param pin The pin of the controller jack to read 54 | @return The state of the pin 55 | */ 56 | virtual bool read(DigitalPin pin); 57 | 58 | /** 59 | Read the resistance at the specified analog pin for this controller. 60 | The returned value is the resistance measured in ohms. 61 | 62 | @param pin The pin of the controller jack to read 63 | @return The resistance at the specified pin 64 | */ 65 | virtual Int32 read(AnalogPin pin); 66 | 67 | /** 68 | Write the given value to the specified digital pin for this 69 | controller. Writing is only allowed to the pins associated 70 | with the PIA. Therefore you cannot write to pin six. 71 | 72 | @param pin The pin of the controller jack to write to 73 | @param value The value to write to the pin 74 | */ 75 | virtual void write(DigitalPin pin, bool value); 76 | 77 | private: 78 | // Used to implement paddle swapping efficiently, and eliminate 79 | // testing at runtime 80 | Event::Type myPinEvents[4][2]; 81 | }; 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /src/ale/src/controllers/ale_controller.cpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * A.L.E (Arcade Learning Environment) 3 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 4 | * the Reinforcement Learning and Artificial Intelligence Laboratory 5 | * Released under the GNU General Public License; see License.txt for details. 6 | * 7 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 8 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 9 | * 10 | * ***************************************************************************** 11 | * controller.hpp 12 | * 13 | * Superclass defining a variety of controllers -- main loops interfacing with 14 | * an agent in a particular way. This superclass handles work common to all 15 | * controllers, e.g. loading ROM settings and constructing the environment 16 | * wrapper. 17 | **************************************************************************** */ 18 | 19 | #include "ale_controller.hpp" 20 | 21 | #include "../games/Roms.hpp" 22 | #include "../common/display_screen.h" 23 | #include "../common/Log.hpp" 24 | 25 | namespace ale { 26 | 27 | ALEController::ALEController(OSystem* osystem) 28 | : m_osystem(osystem), m_settings(buildRomRLWrapper( 29 | m_osystem->settings().getString("rom_file"))), 30 | m_environment(m_osystem, m_settings.get()) { 31 | if (m_settings.get() == NULL) { 32 | ale::Logger::Warning << "Unsupported ROM file: " << std::endl; 33 | exit(1); 34 | } else { 35 | m_environment.reset(); 36 | } 37 | } 38 | 39 | void ALEController::display() { 40 | // Display the screen if applicable 41 | DisplayScreen* display = m_osystem->p_display_screen; 42 | if (display) { 43 | display->display_screen(); 44 | while (display->manual_control_engaged()) { 45 | Action user_action = display->getUserAction(); 46 | applyActions(user_action, PLAYER_B_NOOP); 47 | display->display_screen(); 48 | } 49 | } 50 | } 51 | 52 | reward_t ALEController::applyActions(Action player_a, Action player_b) { 53 | reward_t sum_rewards = 0; 54 | // Perform different operations based on the first player's action 55 | switch (player_a) { 56 | case LOAD_STATE: // Load system state 57 | // Note - this does not reset the game screen; so that the subsequent screen 58 | // is incorrect (in fact, two screens, due to colour averaging) 59 | m_environment.load(); 60 | break; 61 | case SAVE_STATE: // Save system state 62 | m_environment.save(); 63 | break; 64 | case SYSTEM_RESET: 65 | m_environment.reset(); 66 | break; 67 | default: 68 | // Pass action to emulator! 69 | sum_rewards = m_environment.act(player_a, player_b); 70 | break; 71 | } 72 | return sum_rewards; 73 | } 74 | 75 | } // namespace ale 76 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Asterix.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 70 and 77 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __ASTERIX_HPP__ 29 | #define __ASTERIX_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Asterix */ 36 | class AsterixSettings : public RomSettings { 37 | public: 38 | AsterixSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "asterix"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | // Asterix requires the fire action to start the game 68 | ActionVect getStartingActions() override; 69 | 70 | int lives() override { return isTerminal() ? 0 : m_lives; } 71 | 72 | private: 73 | bool m_terminal; 74 | reward_t m_reward; 75 | reward_t m_score; 76 | int m_lives; 77 | }; 78 | 79 | } // namespace ale 80 | 81 | #endif // __ASTERIX_HPP__ 82 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/ElevatorAction.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The lines 69 and 76 are based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __ELEVATORACTION_HPP__ 29 | #define __ELEVATORACTION_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Elevator Action settings */ 36 | class ElevatorActionSettings : public RomSettings { 37 | public: 38 | ElevatorActionSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "elevator_action"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | ActionVect getStartingActions() override; 68 | 69 | int lives() override { return isTerminal() ? 0 : m_lives; } 70 | 71 | private: 72 | bool m_terminal; 73 | reward_t m_reward; 74 | reward_t m_score; 75 | int m_lives; 76 | }; 77 | 78 | } // namespace ale 79 | 80 | #endif // __ELEVATORACTION_HPP__ 81 | -------------------------------------------------------------------------------- /src/ale/src/games/supported/Boxing.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The method lives() is based on Xitari's code, from Google Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | * ***************************************************************************** 17 | * A.L.E (Arcade Learning Environment) 18 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 19 | * the Reinforcement Learning and Artificial Intelligence Laboratory 20 | * Released under the GNU General Public License; see License.txt for details. 21 | * 22 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 23 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 24 | * 25 | * ***************************************************************************** 26 | */ 27 | 28 | #ifndef __BOXING_HPP__ 29 | #define __BOXING_HPP__ 30 | 31 | #include "../RomSettings.hpp" 32 | 33 | namespace ale { 34 | 35 | /* RL wrapper for Boxing settings */ 36 | class BoxingSettings : public RomSettings { 37 | public: 38 | BoxingSettings(); 39 | 40 | // reset 41 | void reset() override; 42 | 43 | // is end of game 44 | bool isTerminal() const override; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const override; 48 | 49 | // the rom-name 50 | const char* rom() const override { return "boxing"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const override; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const override; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system) override; 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer& ser) override; 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer& ser) override; 66 | 67 | int lives() override { return 0; } 68 | 69 | // returns a list of difficulties that the game can be played in 70 | // in this game, there are 4 available difficulties 71 | DifficultyVect getAvailableDifficulties() override; 72 | 73 | private: 74 | bool m_terminal; 75 | reward_t m_reward; 76 | reward_t m_score; 77 | }; 78 | 79 | } // namespace ale 80 | 81 | #endif // __BOXING_HPP__ 82 | --------------------------------------------------------------------------------