├── .appveyor.yml ├── .gitignore ├── .travis.yml ├── Copyright.txt ├── License.txt ├── README-SDL.txt ├── README-ale.md ├── README.md ├── atari_py ├── __init__.py ├── ale_c_wrapper.cpp ├── ale_c_wrapper.h ├── ale_interface │ ├── CMakeLists.txt │ └── src │ │ ├── ale_interface.cpp │ │ ├── ale_interface.hpp │ │ ├── common │ │ ├── Array.hxx │ │ ├── ColourPalette.cpp │ │ ├── ColourPalette.hpp │ │ ├── Constants.cpp │ │ ├── Constants.h │ │ ├── Log.cpp │ │ ├── Log.hpp │ │ ├── Palettes.hpp │ │ ├── SoundExporter.cpp │ │ ├── SoundExporter.hpp │ │ ├── SoundNull.cxx │ │ ├── SoundNull.hxx │ │ ├── SoundSDL.cxx │ │ ├── SoundSDL.hxx │ │ ├── Version.hxx │ │ ├── VideoModeList.hxx │ │ ├── display_screen.cpp │ │ ├── display_screen.h │ │ ├── misc_tools.h │ │ ├── module.mk │ │ ├── mt19937.hpp │ │ ├── scoped_ptr.hpp │ │ ├── stella.png │ │ └── stella.xpm │ │ ├── controllers │ │ ├── ale_controller.cpp │ │ ├── ale_controller.hpp │ │ ├── fifo_controller.cpp │ │ ├── fifo_controller.hpp │ │ ├── module.mk │ │ ├── rlglue_controller.cpp │ │ └── rlglue_controller.hpp │ │ ├── emucore │ │ ├── AtariVox.cxx │ │ ├── AtariVox.hxx │ │ ├── Booster.cxx │ │ ├── Booster.hxx │ │ ├── Cart.cxx │ │ ├── Cart.hxx │ │ ├── Cart0840.cxx │ │ ├── Cart0840.hxx │ │ ├── Cart2K.cxx │ │ ├── Cart2K.hxx │ │ ├── Cart3E.cxx │ │ ├── Cart3E.hxx │ │ ├── Cart3F.cxx │ │ ├── Cart3F.hxx │ │ ├── Cart4A50.cxx │ │ ├── Cart4A50.hxx │ │ ├── Cart4K.cxx │ │ ├── Cart4K.hxx │ │ ├── CartAR.cxx │ │ ├── CartAR.hxx │ │ ├── CartCV.cxx │ │ ├── CartCV.hxx │ │ ├── CartDPC.cxx │ │ ├── CartDPC.hxx │ │ ├── CartE0.cxx │ │ ├── CartE0.hxx │ │ ├── CartE7.cxx │ │ ├── CartE7.hxx │ │ ├── CartF4.cxx │ │ ├── CartF4.hxx │ │ ├── CartF4SC.cxx │ │ ├── CartF4SC.hxx │ │ ├── CartF6.cxx │ │ ├── CartF6.hxx │ │ ├── CartF6SC.cxx │ │ ├── CartF6SC.hxx │ │ ├── CartF8.cxx │ │ ├── CartF8.hxx │ │ ├── CartF8SC.cxx │ │ ├── CartF8SC.hxx │ │ ├── CartFASC.cxx │ │ ├── CartFASC.hxx │ │ ├── CartFE.cxx │ │ ├── CartFE.hxx │ │ ├── CartMB.cxx │ │ ├── CartMB.hxx │ │ ├── CartMC.cxx │ │ ├── CartMC.hxx │ │ ├── CartUA.cxx │ │ ├── CartUA.hxx │ │ ├── Console.cxx │ │ ├── Console.hxx │ │ ├── Control.cxx │ │ ├── Control.hxx │ │ ├── DefProps.hxx │ │ ├── Deserializer.cxx │ │ ├── Deserializer.hxx │ │ ├── Driving.cxx │ │ ├── Driving.hxx │ │ ├── Event.cxx │ │ ├── Event.hxx │ │ ├── FSNode.cxx │ │ ├── FSNode.hxx │ │ ├── Joystick.cxx │ │ ├── Joystick.hxx │ │ ├── Keyboard.cxx │ │ ├── Keyboard.hxx │ │ ├── M6532.cxx │ │ ├── M6532.hxx │ │ ├── MD5.cxx │ │ ├── MD5.hxx │ │ ├── MediaSrc.cxx │ │ ├── MediaSrc.hxx │ │ ├── OSystem.cxx │ │ ├── OSystem.hxx │ │ ├── Paddles.cxx │ │ ├── Paddles.hxx │ │ ├── Props.cxx │ │ ├── Props.hxx │ │ ├── PropsSet.cxx │ │ ├── PropsSet.hxx │ │ ├── Random.cxx │ │ ├── Random.hxx │ │ ├── Serializer.cxx │ │ ├── Serializer.hxx │ │ ├── Settings.cxx │ │ ├── Settings.hxx │ │ ├── Sound.hxx │ │ ├── SpeakJet.cxx │ │ ├── SpeakJet.hxx │ │ ├── Switches.cxx │ │ ├── Switches.hxx │ │ ├── TIA.cxx │ │ ├── TIA.hxx │ │ ├── TIASnd.cxx │ │ ├── TIASnd.hxx │ │ ├── m6502 │ │ │ ├── Copyright.txt │ │ │ ├── License.txt │ │ │ ├── module.mk │ │ │ └── src │ │ │ │ ├── Device.cxx │ │ │ │ ├── Device.hxx │ │ │ │ ├── M6502.cxx │ │ │ │ ├── M6502.hxx │ │ │ │ ├── M6502.m4 │ │ │ │ ├── M6502Hi.cxx │ │ │ │ ├── M6502Hi.hxx │ │ │ │ ├── M6502Hi.ins │ │ │ │ ├── M6502Hi.m4 │ │ │ │ ├── M6502Low.cxx │ │ │ │ ├── M6502Low.hxx │ │ │ │ ├── M6502Low.ins │ │ │ │ ├── M6502Low.m4 │ │ │ │ ├── NullDev.cxx │ │ │ │ ├── NullDev.hxx │ │ │ │ ├── System.cxx │ │ │ │ ├── System.hxx │ │ │ │ └── bspf │ │ │ │ ├── Copyright.txt │ │ │ │ ├── License.txt │ │ │ │ └── src │ │ │ │ └── bspf.hxx │ │ ├── module.mk │ │ ├── rsynth │ │ │ ├── COPYING │ │ │ ├── Elements.def │ │ │ ├── PORTING │ │ │ ├── config.h │ │ │ ├── darray.c │ │ │ ├── darray.h │ │ │ ├── elements.c │ │ │ ├── holmes.c │ │ │ ├── kmap │ │ │ ├── module.mk │ │ │ ├── opsynth.c │ │ │ ├── phfeat.h │ │ │ ├── phones.c │ │ │ ├── phones.def │ │ │ ├── phones.h │ │ │ ├── phtoelm.c │ │ │ ├── phtoelm.def │ │ │ ├── phtoelm.h │ │ │ ├── rsynth.h │ │ │ ├── trie.c │ │ │ ├── trie.h │ │ │ └── useconfig.h │ │ └── stella.pro │ │ ├── environment │ │ ├── ale_ram.hpp │ │ ├── ale_screen.hpp │ │ ├── ale_state.cpp │ │ ├── ale_state.hpp │ │ ├── module.mk │ │ ├── phosphor_blend.cpp │ │ ├── phosphor_blend.hpp │ │ ├── stella_environment.cpp │ │ ├── stella_environment.hpp │ │ ├── stella_environment_wrapper.cpp │ │ └── stella_environment_wrapper.hpp │ │ ├── games │ │ ├── RomSettings.cpp │ │ ├── RomSettings.hpp │ │ ├── RomUtils.cpp │ │ ├── RomUtils.hpp │ │ ├── Roms.cpp │ │ ├── Roms.hpp │ │ ├── module.mk │ │ └── supported │ │ │ ├── Adventure.cpp │ │ │ ├── Adventure.hpp │ │ │ ├── AirRaid.cpp │ │ │ ├── AirRaid.hpp │ │ │ ├── Alien.cpp │ │ │ ├── Alien.hpp │ │ │ ├── Amidar.cpp │ │ │ ├── Amidar.hpp │ │ │ ├── Assault.cpp │ │ │ ├── Assault.hpp │ │ │ ├── Asterix.cpp │ │ │ ├── Asterix.hpp │ │ │ ├── Asteroids.cpp │ │ │ ├── Asteroids.hpp │ │ │ ├── Atlantis.cpp │ │ │ ├── Atlantis.hpp │ │ │ ├── BankHeist.cpp │ │ │ ├── BankHeist.hpp │ │ │ ├── BattleZone.cpp │ │ │ ├── BattleZone.hpp │ │ │ ├── BeamRider.cpp │ │ │ ├── BeamRider.hpp │ │ │ ├── Berzerk.cpp │ │ │ ├── Berzerk.hpp │ │ │ ├── Bowling.cpp │ │ │ ├── Bowling.hpp │ │ │ ├── Boxing.cpp │ │ │ ├── Boxing.hpp │ │ │ ├── Breakout.cpp │ │ │ ├── Breakout.hpp │ │ │ ├── Carnival.cpp │ │ │ ├── Carnival.hpp │ │ │ ├── Centipede.cpp │ │ │ ├── Centipede.hpp │ │ │ ├── ChopperCommand.cpp │ │ │ ├── ChopperCommand.hpp │ │ │ ├── CrazyClimber.cpp │ │ │ ├── CrazyClimber.hpp │ │ │ ├── Defender.cpp │ │ │ ├── Defender.hpp │ │ │ ├── DemonAttack.cpp │ │ │ ├── DemonAttack.hpp │ │ │ ├── DonkeyKong.cpp │ │ │ ├── DonkeyKong.hpp │ │ │ ├── DoubleDunk.cpp │ │ │ ├── DoubleDunk.hpp │ │ │ ├── ElevatorAction.cpp │ │ │ ├── ElevatorAction.hpp │ │ │ ├── Enduro.cpp │ │ │ ├── Enduro.hpp │ │ │ ├── FishingDerby.cpp │ │ │ ├── FishingDerby.hpp │ │ │ ├── Freeway.cpp │ │ │ ├── Freeway.hpp │ │ │ ├── Frogger.cpp │ │ │ ├── Frogger.hpp │ │ │ ├── Frostbite.cpp │ │ │ ├── Frostbite.hpp │ │ │ ├── Galaxian.cpp │ │ │ ├── Galaxian.hpp │ │ │ ├── Gopher.cpp │ │ │ ├── Gopher.hpp │ │ │ ├── Gravitar.cpp │ │ │ ├── Gravitar.hpp │ │ │ ├── Hero.cpp │ │ │ ├── Hero.hpp │ │ │ ├── IceHockey.cpp │ │ │ ├── IceHockey.hpp │ │ │ ├── JamesBond.cpp │ │ │ ├── JamesBond.hpp │ │ │ ├── JourneyEscape.cpp │ │ │ ├── JourneyEscape.hpp │ │ │ ├── Kaboom.cpp │ │ │ ├── Kaboom.hpp │ │ │ ├── Kangaroo.cpp │ │ │ ├── Kangaroo.hpp │ │ │ ├── KeystoneKapers.cpp │ │ │ ├── KeystoneKapers.hpp │ │ │ ├── Kingkong.cpp │ │ │ ├── Kingkong.hpp │ │ │ ├── Koolaid.cpp │ │ │ ├── Koolaid.hpp │ │ │ ├── Krull.cpp │ │ │ ├── Krull.hpp │ │ │ ├── KungFuMaster.cpp │ │ │ ├── KungFuMaster.hpp │ │ │ ├── LaserGates.cpp │ │ │ ├── LaserGates.hpp │ │ │ ├── LostLuggage.cpp │ │ │ ├── LostLuggage.hpp │ │ │ ├── MontezumaRevenge.cpp │ │ │ ├── MontezumaRevenge.hpp │ │ │ ├── MrDo.cpp │ │ │ ├── MrDo.hpp │ │ │ ├── MsPacman.cpp │ │ │ ├── MsPacman.hpp │ │ │ ├── NameThisGame.cpp │ │ │ ├── NameThisGame.hpp │ │ │ ├── Phoenix.cpp │ │ │ ├── Phoenix.hpp │ │ │ ├── Pitfall.cpp │ │ │ ├── Pitfall.hpp │ │ │ ├── Pong.cpp │ │ │ ├── Pong.hpp │ │ │ ├── Pooyan.cpp │ │ │ ├── Pooyan.hpp │ │ │ ├── PrivateEye.cpp │ │ │ ├── PrivateEye.hpp │ │ │ ├── QBert.cpp │ │ │ ├── QBert.hpp │ │ │ ├── RiverRaid.cpp │ │ │ ├── RiverRaid.hpp │ │ │ ├── RoadRunner.cpp │ │ │ ├── RoadRunner.hpp │ │ │ ├── RoboTank.cpp │ │ │ ├── RoboTank.hpp │ │ │ ├── Seaquest.cpp │ │ │ ├── Seaquest.hpp │ │ │ ├── SirLancelot.cpp │ │ │ ├── SirLancelot.hpp │ │ │ ├── Skiing.cpp │ │ │ ├── Skiing.hpp │ │ │ ├── Solaris.cpp │ │ │ ├── Solaris.hpp │ │ │ ├── SpaceInvaders.cpp │ │ │ ├── SpaceInvaders.hpp │ │ │ ├── StarGunner.cpp │ │ │ ├── StarGunner.hpp │ │ │ ├── Tennis.cpp │ │ │ ├── Tennis.hpp │ │ │ ├── Tetris.cpp │ │ │ ├── Tetris.hpp │ │ │ ├── TimePilot.cpp │ │ │ ├── TimePilot.hpp │ │ │ ├── Trondead.cpp │ │ │ ├── Trondead.hpp │ │ │ ├── Turmoil.cpp │ │ │ ├── Turmoil.hpp │ │ │ ├── Tutankham.cpp │ │ │ ├── Tutankham.hpp │ │ │ ├── UpNDown.cpp │ │ │ ├── UpNDown.hpp │ │ │ ├── Venture.cpp │ │ │ ├── Venture.hpp │ │ │ ├── VideoPinball.cpp │ │ │ ├── VideoPinball.hpp │ │ │ ├── WizardOfWor.cpp │ │ │ ├── WizardOfWor.hpp │ │ │ ├── YarsRevenge.cpp │ │ │ ├── YarsRevenge.hpp │ │ │ ├── Zaxxon.cpp │ │ │ └── Zaxxon.hpp │ │ ├── main.cpp │ │ ├── module.mk │ │ └── os_dependent │ │ ├── FSNodePOSIX.cxx │ │ ├── FSNodeWin32.cxx │ │ ├── OSystemUNIX.cxx │ │ ├── OSystemUNIX.hxx │ │ ├── OSystemWin32.cxx │ │ ├── OSystemWin32.hxx │ │ ├── SettingsUNIX.cxx │ │ ├── SettingsUNIX.hxx │ │ ├── SettingsWin32.cxx │ │ ├── SettingsWin32.hxx │ │ └── module.mk ├── ale_python_interface.py ├── atari_ntsc_rgb_palette.h ├── atari_roms │ ├── adventure.bin │ ├── air_raid.bin │ ├── alien.bin │ ├── amidar.bin │ ├── assault.bin │ ├── asterix.bin │ ├── asteroids.bin │ ├── atlantis.bin │ ├── bank_heist.bin │ ├── battle_zone.bin │ ├── beam_rider.bin │ ├── berzerk.bin │ ├── bowling.bin │ ├── boxing.bin │ ├── breakout.bin │ ├── carnival.bin │ ├── centipede.bin │ ├── chopper_command.bin │ ├── crazy_climber.bin │ ├── defender.bin │ ├── demon_attack.bin │ ├── double_dunk.bin │ ├── elevator_action.bin │ ├── enduro.bin │ ├── fishing_derby.bin │ ├── freeway.bin │ ├── frostbite.bin │ ├── gopher.bin │ ├── gravitar.bin │ ├── hero.bin │ ├── ice_hockey.bin │ ├── jamesbond.bin │ ├── journey_escape.bin │ ├── kaboom.bin │ ├── kangaroo.bin │ ├── krull.bin │ ├── kung_fu_master.bin │ ├── montezuma_revenge.bin │ ├── ms_pacman.bin │ ├── name_this_game.bin │ ├── phoenix.bin │ ├── pitfall.bin │ ├── pong.bin │ ├── pooyan.bin │ ├── private_eye.bin │ ├── qbert.bin │ ├── riverraid.bin │ ├── road_runner.bin │ ├── robotank.bin │ ├── seaquest.bin │ ├── skiing.bin │ ├── solaris.bin │ ├── space_invaders.bin │ ├── star_gunner.bin │ ├── tennis.bin │ ├── time_pilot.bin │ ├── tutankham.bin │ ├── up_n_down.bin │ ├── venture.bin │ ├── video_pinball.bin │ ├── wizard_of_wor.bin │ ├── yars_revenge.bin │ └── zaxxon.bin ├── package_data.txt └── tests │ ├── __init__.py │ └── test_smoke.py ├── build.sh ├── config.sh ├── deploy.sh ├── deploy_to_pypi.sh ├── doc ├── examples │ ├── Makefile │ ├── Makefile.fifo │ ├── Makefile.recording │ ├── Makefile.rlglue │ ├── Makefile.sharedlibrary │ ├── RLGlueAgent.c │ ├── RLGlueExperiment.c │ ├── fifoInterfaceExample.cpp │ ├── python_example.py │ ├── sharedLibraryInterfaceExample.cpp │ └── videoRecordingExample.cpp ├── java-agent │ ├── code │ │ ├── build.xml │ │ ├── manifest.mf │ │ ├── nbproject │ │ │ ├── build-impl.xml │ │ │ ├── configs │ │ │ │ ├── Human.properties │ │ │ │ └── RL.properties │ │ │ ├── genfiles.properties │ │ │ ├── project.properties │ │ │ └── project.xml │ │ └── run_agent.perl │ └── manual │ │ ├── Makefile │ │ ├── java-agent.pdf │ │ └── java-agent.tex ├── manual │ ├── Makefile │ ├── figures │ │ └── ale.gif │ ├── manual.pdf │ └── manual.tex └── scripts │ ├── videoRecordingExampleJoinMacOSX.sh │ └── videoRecordingExampleJoinUnix.sh ├── dockerfile.3.6 ├── get_platform.py ├── install_osx.sh ├── installzlib.bat ├── multibuild.sh ├── setup.py ├── tox.ini └── win_build.sh /.appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2019 2 | 3 | environment: 4 | matrix: 5 | - { PYTHON: "C:\\Python27", APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2015" } 6 | - { PYTHON: "C:\\Python35", APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2015" } 7 | - PYTHON: "C:\\Python36" 8 | - PYTHON: "C:\\Python37" 9 | - PYTHON: "C:\\Python38" 10 | - { PYTHON: "C:\\Python27-x64", APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2015" } 11 | - { PYTHON: "C:\\Python35-x64", APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2015" } 12 | - PYTHON: "C:\\Python36-x64" 13 | - PYTHON: "C:\\Python37-x64" 14 | - PYTHON: "C:\\Python38-x64" 15 | 16 | install: 17 | - "%PYTHON%\\python.exe -m pip install wheel" 18 | 19 | build: off 20 | 21 | before_test: 22 | - "%PYTHON%\\python.exe setup.py bdist_wheel" 23 | - "cd dist" 24 | - "%PYTHON%\\python.exe -m pip install --find-links=. atari-py" 25 | - "%PYTHON%\\python.exe -m pip install gym" 26 | 27 | test_script: 28 | - "%PYTHON%\\python.exe -c \"import gym; env = gym.make('Enduro-v0'); env.reset(); [env.step(env.action_space.sample()) for i in range(1000)]\"" 29 | 30 | artifacts: 31 | - path: dist\*.whl 32 | name: Releases 33 | 34 | deploy: 35 | provider: GitHub 36 | auth_token: 37 | secure: "Weh3LepGE4k174U43zSHYAiM1pUCUSlQ+wjwpmUI2X3SsZqTpdRKzDUwkLnHjp23" 38 | artifact: /.*\.whl/ 39 | draft: false 40 | prerelease: false 41 | on: 42 | appveyor_repo_tag: true 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.egg 3 | *.egg-info 4 | dist 5 | *.pyc 6 | .tox 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # atari_py 2 | 3 | An `openai/atari-py` fork with Windows support and removed zlib/libpng dependencies. 4 | 5 | ## Installation 6 | 7 | To simply install [`atari-py` wheels (binaries)](https://github.com/Kojoley/atari-py/releases) use this command: 8 | 9 | ```pip install -f https://github.com/Kojoley/atari-py/releases atari_py``` 10 | 11 | If you have any `distutils` supported compiler you can install from sources: 12 | 13 | ```pip install git+https://github.com/Kojoley/atari-py.git``` 14 | -------------------------------------------------------------------------------- /atari_py/__init__.py: -------------------------------------------------------------------------------- 1 | from .ale_python_interface import * 2 | import os 3 | 4 | def _game_dir(): 5 | return os.path.join(os.path.abspath(os.path.dirname(__file__)), "atari_roms") 6 | 7 | def get_game_path(game_name): 8 | return os.path.join(_game_dir(), game_name) + ".bin" 9 | 10 | def list_games(): 11 | files = os.listdir(_game_dir()) 12 | return [os.path.basename(f).split(".")[0] for f in files] 13 | 14 | # default to only logging errors 15 | ALEInterface.setLoggerMode(ALEInterface.Logger.Error) 16 | -------------------------------------------------------------------------------- /atari_py/ale_c_wrapper.cpp: -------------------------------------------------------------------------------- 1 | #include "ale_c_wrapper.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void encodeState(ALEState *state, char *buf, int buf_len) { 8 | std::string str = state->serialize(); 9 | 10 | if (buf_len < int(str.length())) { 11 | throw new std::runtime_error("Buffer is not big enough to hold serialized ALEState. Please use encodeStateLen to determine the correct buffer size"); 12 | } 13 | 14 | memcpy(buf, str.data(), str.length()); 15 | } 16 | 17 | int encodeStateLen(ALEState *state) { 18 | return state->serialize().length(); 19 | } 20 | 21 | ALEState *decodeState(const char *serialized, int len) { 22 | std::string str(serialized, len); 23 | 24 | return new ALEState(str); 25 | } -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | std::string action_to_string(Action a) { 19 | static std::string tmp_action_to_string[] = { 20 | "PLAYER_A_NOOP" 21 | ,"PLAYER_A_FIRE" 22 | ,"PLAYER_A_UP" 23 | ,"PLAYER_A_RIGHT" 24 | ,"PLAYER_A_LEFT" 25 | ,"PLAYER_A_DOWN" 26 | ,"PLAYER_A_UPRIGHT" 27 | ,"PLAYER_A_UPLEFT" 28 | ,"PLAYER_A_DOWNRIGHT" 29 | ,"PLAYER_A_DOWNLEFT" 30 | ,"PLAYER_A_UPFIRE" 31 | ,"PLAYER_A_RIGHTFIRE" 32 | ,"PLAYER_A_LEFTFIRE" 33 | ,"PLAYER_A_DOWNFIRE" 34 | ,"PLAYER_A_UPRIGHTFIRE" 35 | ,"PLAYER_A_UPLEFTFIRE" 36 | ,"PLAYER_A_DOWNRIGHTFIRE" 37 | ,"PLAYER_A_DOWNLEFTFIRE" 38 | ,"PLAYER_B_NOOP" 39 | ,"PLAYER_B_FIRE" 40 | ,"PLAYER_B_UP" 41 | ,"PLAYER_B_RIGHT" 42 | ,"PLAYER_B_LEFT" 43 | ,"PLAYER_B_DOWN" 44 | ,"PLAYER_B_UPRIGHT" 45 | ,"PLAYER_B_UPLEFT" 46 | ,"PLAYER_B_DOWNRIGHT" 47 | ,"PLAYER_B_DOWNLEFT" 48 | ,"PLAYER_B_UPFIRE" 49 | ,"PLAYER_B_RIGHTFIRE" 50 | ,"PLAYER_B_LEFTFIRE" 51 | ,"PLAYER_B_DOWNFIRE" 52 | ,"PLAYER_B_UPRIGHTFIRE" 53 | ,"PLAYER_B_UPLEFTFIRE" 54 | ,"PLAYER_B_DOWNRIGHTFIRE" 55 | ,"PLAYER_B_DOWNLEFTFIRE" 56 | ,"__invalid__" // 36 57 | ,"__invalid__" // 37 58 | ,"__invalid__" // 38 59 | ,"__invalid__" // 39 60 | ,"RESET" // 40 61 | ,"UNDEFINED" // 41 62 | ,"RANDOM" // 42 63 | }; 64 | assert (a >= 0 && a <= 42); 65 | return tmp_action_to_string[a]; 66 | } 67 | -------------------------------------------------------------------------------- /atari_py/ale_interface/src/common/Log.cpp: -------------------------------------------------------------------------------- 1 | #include "Log.hpp" 2 | #include 3 | using namespace ale; 4 | 5 | Logger::mode Logger::current_mode = Info; 6 | 7 | void Logger::setMode(Logger::mode m){ 8 | current_mode = m; 9 | } 10 | 11 | ale::Logger::mode ale::operator<<(ale::Logger::mode log, std::ostream & (*manip)(std::ostream &)) { 12 | if(log >= Logger::current_mode) 13 | manip(std::cerr); 14 | return log; 15 | } 16 | -------------------------------------------------------------------------------- /atari_py/ale_interface/src/common/Log.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __LOG_HPP__ 2 | #define __LOG_HPP__ 3 | #include 4 | namespace ale 5 | { 6 | class Logger 7 | { 8 | public: 9 | enum mode{ 10 | Info = 0, 11 | Warning = 1, 12 | Error = 2 13 | }; 14 | /** @brief Allow to change the level of verbosity 15 | * @param m Info will print all the messages, Warning only the important ones 16 | * and Error the critical ones 17 | */ 18 | static void setMode(mode m); 19 | private: 20 | static mode current_mode; 21 | friend mode operator<<(mode,std::ostream&(*manip)(std::ostream &)); 22 | template 23 | friend mode operator<<(mode, const T&); 24 | }; 25 | 26 | 27 | Logger::mode operator<<(Logger::mode log, std::ostream & (*manip)(std::ostream &)); 28 | 29 | template 30 | Logger::mode operator << (Logger::mode log, const T& val){ 31 | if(log>=Logger::current_mode) 32 | std::cerr << val; 33 | return log; 34 | } 35 | 36 | 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #include "../emucore/m6502/src/bspf/src/bspf.hxx" 28 | 29 | namespace ale { 30 | namespace sound { 31 | 32 | template 33 | void write(std::ofstream& stream, const T& t) { 34 | stream.write((const char*)&t, sizeof(T)); 35 | } 36 | 37 | class SoundExporter { 38 | 39 | public: 40 | 41 | static const int SamplesPerFrame = 512; 42 | 43 | typedef uInt8 SampleType; 44 | 45 | /** Create a new sound exporter which, on program termination, will write out a wav file. */ 46 | SoundExporter(const std::string &filename, int channels); 47 | ~SoundExporter(); 48 | 49 | /** Adds a buffer of samples. */ 50 | void addSamples(SampleType *s, int len); 51 | 52 | private: 53 | 54 | /** Writes the data to disk. */ 55 | void writeWAVData(); 56 | 57 | /** The file to save our audio to. */ 58 | std::string m_filename; 59 | 60 | /** Number of channels. */ 61 | int m_channels; 62 | 63 | /** The sound data. */ 64 | std::vector m_data; 65 | 66 | /** Keep track of how many samples have been written since the last write to disk */ 67 | size_t m_samples_since_write; 68 | }; 69 | 70 | } // namespace ale::sound 71 | } // namespace ale 72 | 73 | #endif // __SOUND_EXPORTER_HPP__ 74 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #include 22 | 23 | #include "Constants.h" 24 | #include "ColourPalette.hpp" 25 | #include "../emucore/MediaSrc.hxx" 26 | 27 | #ifdef __USE_SDL 28 | #include "SDL.h" 29 | 30 | class DisplayScreen { 31 | public: 32 | DisplayScreen(MediaSource* mediaSource, Sound* sound, ColourPalette &palette); 33 | virtual ~DisplayScreen(); 34 | 35 | // Displays the current frame buffer from the mediasource. 36 | void display_screen(); 37 | 38 | // Has the user engaged manual control mode? 39 | bool manual_control_engaged() { return manual_control_active; } 40 | 41 | // Captures the keypress of a user in manual control mode. 42 | Action getUserAction(); 43 | 44 | protected: 45 | // Checks for SDL events. 46 | void poll(); 47 | 48 | // Handle the SDL_Event. 49 | void handleSDLEvent(const SDL_Event& event); 50 | 51 | protected: 52 | // Dimensions of the SDL window (4:3 aspect ratio) 53 | static const int window_height = 321; 54 | static const int window_width = 428; 55 | // Maintains the paused/unpaused state of the game 56 | bool manual_control_active; 57 | MediaSource* media_source; 58 | Sound* my_sound; 59 | ColourPalette &colour_palette; 60 | int screen_height, screen_width; 61 | SDL_Surface *screen, *image; 62 | float yratio, xratio; 63 | Uint32 delay_msec; 64 | // Used to calibrate delay between frames 65 | Uint32 last_frame_time; 66 | }; 67 | #else 68 | /** A dummy class that simply ignores display events. */ 69 | class DisplayScreen { 70 | public: 71 | DisplayScreen(MediaSource*, Sound*, ColourPalette &) {} 72 | void display_screen() {} 73 | bool manual_control_engaged() { return false; } 74 | Action getUserAction() { return UNDEFINED; } 75 | }; 76 | #endif // __USE_SDL 77 | 78 | #endif // DISPLAY_SCREEN 79 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | /* ***************************************************************************** 25 | Inline C++ integer exponentiation routines 26 | Version 1.01 27 | Copyright (C) 1999-2004 John C. Bowman 28 | **************************************************************************** */ 29 | inline int pow(int x, int p) { 30 | if(p == 0) return 1; 31 | if(x == 0 && p > 0) return 0; 32 | if(p < 0) {assert(x == 1 || x == -1); return (-p % 2) ? x : 1;} 33 | 34 | int r = 1; 35 | for(;;) { 36 | if(p & 1) r *= x; 37 | if((p >>= 1) == 0) return r; 38 | x *= x; 39 | } 40 | } 41 | 42 | /* ***************************************************************************** 43 | Makes x fit within the [uper, lower] bounds 44 | **************************************************************************** */ 45 | inline void bound(int& x, int lower_bound, int upper_bound) { 46 | if (x > upper_bound) { 47 | x = upper_bound; 48 | } 49 | if (x < lower_bound) { 50 | x = lower_bound; 51 | } 52 | } 53 | 54 | /* ***************************************************************************** 55 | Return time in milliseconds. 56 | **************************************************************************** */ 57 | #if (defined(_WIN32) || defined(__MINGW32__)) 58 | 59 | #include 60 | inline long timeMillis() { 61 | return GetTickCount(); 62 | } 63 | 64 | #else 65 | 66 | inline long timeMillis() { 67 | 68 | struct timeval ts; 69 | gettimeofday(&ts, NULL); 70 | return ts.tv_sec * 1000 + ts.tv_usec/1000; 71 | } 72 | 73 | #endif 74 | 75 | #endif // __MISC_TOOLS_H__ 76 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/src/common/scoped_ptr.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019 by Nikita Kniazev 2 | * 3 | * Permission to use, copy, modify, and/or distribute this software for any 4 | * purpose with or without fee is hereby granted. 5 | * 6 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 7 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 8 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 9 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 11 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 12 | * PERFORMANCE OF THIS SOFTWARE. 13 | */ 14 | 15 | #ifndef NK_SCOPED_PTR 16 | #define NK_SCOPED_PTR 17 | 18 | namespace utils { 19 | 20 | struct bool_conversion { int padding; int truth; }; 21 | typedef int bool_conversion::* explicit_bool; 22 | 23 | } 24 | 25 | template 26 | class scoped_ptr { 27 | public: 28 | typedef T* pointer; 29 | typedef T element_type; 30 | 31 | scoped_ptr() throw() : p_() {} 32 | explicit scoped_ptr(pointer p) throw() : p_(p) {} 33 | ~scoped_ptr() { destroy(); } 34 | 35 | element_type& operator*() const { return *get(); } 36 | pointer operator->() const throw() { return get(); } 37 | pointer get() const throw() { return p_; } 38 | operator bool() const throw() { return get() != pointer(); } 39 | operator utils::explicit_bool() const 40 | { 41 | return get() != pointer() ? &utils::bool_conversion::truth 42 | : utils::explicit_bool(0); 43 | } 44 | 45 | pointer release() throw() { pointer p = p_; p_ = pointer(); return p; } 46 | void reset(pointer p = pointer()) throw() { destroy(); p_ = p; } 47 | void swap(scoped_ptr& u) throw() 48 | { 49 | pointer p = release(); 50 | p_ = u.release(); 51 | u.p_ = p; 52 | } 53 | 54 | private: 55 | scoped_ptr(const scoped_ptr&); 56 | scoped_ptr& operator=(const scoped_ptr&); 57 | 58 | void destroy() { delete get(); } 59 | 60 | pointer p_; 61 | }; 62 | 63 | #endif // ALE_SCOPED_PTR 64 | -------------------------------------------------------------------------------- /atari_py/ale_interface/src/common/stella.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/ale_interface/src/common/stella.png -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #include "../games/Roms.hpp" 21 | 22 | #include "../common/display_screen.h" 23 | #include "../common/Log.hpp" 24 | 25 | ALEController::ALEController(OSystem* osystem): 26 | m_osystem(osystem), 27 | m_settings(buildRomRLWrapper(m_osystem->settings().getString("rom_name"))), 28 | m_environment(m_osystem, m_settings.get()) { 29 | 30 | if (m_settings.get() == NULL) { 31 | ale::Logger::Warning << "Unsupported ROM file: " << std::endl; 32 | exit(1); 33 | } 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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __ALE_CONTROLLER_HPP__ 19 | #define __ALE_CONTROLLER_HPP__ 20 | 21 | #include "../emucore/OSystem.hxx" 22 | #include "../emucore/m6502/src/System.hxx" 23 | #include "../environment/stella_environment.hpp" 24 | #include "../common/scoped_ptr.hpp" 25 | 26 | class ALEController { 27 | public: 28 | ALEController(OSystem * osystem); 29 | virtual ~ALEController() {} 30 | 31 | /** Main loop. Returns once ALE terminates. */ 32 | virtual void run() = 0; 33 | 34 | protected: 35 | friend class ALEInterface; 36 | 37 | /** Applies the given action to the environment (e.g. by emulating or resetting) */ 38 | reward_t applyActions(Action a, Action b); 39 | /** Support for SDL display... available to all controllers. Simply call it from run(). */ 40 | void display(); 41 | 42 | protected: 43 | OSystem* m_osystem; 44 | scoped_ptr m_settings; 45 | StellaEnvironment m_environment; 46 | }; 47 | 48 | 49 | #endif // __ALE_CONTROLLER_HPP__ 50 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | class FIFOController : public ALEController { 23 | public: 24 | FIFOController(OSystem* osystem, bool named_pipes = false); 25 | virtual ~FIFOController(); 26 | 27 | virtual void run(); 28 | 29 | private: 30 | void handshake(); // Perform handshaking 31 | void openNamedPipes(); 32 | 33 | bool isDone(); 34 | void sendData(); 35 | void readAction(Action& action_a, Action& action_b); 36 | 37 | void sendScreen(); 38 | int stringScreenRLE(const ALEScreen& screen, char * buffer); 39 | int stringScreenFull(const ALEScreen& screen, char * buffer); 40 | void sendRAM(); 41 | void sendRL(); 42 | 43 | private: 44 | bool m_named_pipes; // Whether to use named pipes 45 | 46 | int m_max_num_frames; // Maximum number of total frames before we stop 47 | bool m_run_length_encoding; // Whether to encode the data in a run-length fashion 48 | 49 | bool m_send_screen; // Agent requested screen data 50 | bool m_send_ram; // Agent requested RAM data 51 | bool m_send_rl; // Agent requested RL data 52 | 53 | FILE* m_fout; 54 | FILE* m_fin; 55 | 56 | reward_t latest_reward; // Most recent reward 57 | }; 58 | 59 | #endif // __FIFO_CONTROLLER_HPP__ 60 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | 25 | /** 26 | The standard Atari 2600 pair of paddle controllers. 27 | 28 | @author Bradford W. Mott 29 | @version $Id: Paddles.hxx,v 1.7 2007/01/01 18:04:49 stephena Exp $ 30 | */ 31 | class Paddles : public Controller 32 | { 33 | public: 34 | /** 35 | Create a new pair of paddle controllers 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 | @param swap Whether to swap the paddles plugged into this jack 40 | */ 41 | Paddles(Jack jack, const Event& event, bool swap); 42 | 43 | /** 44 | Destructor 45 | */ 46 | virtual ~Paddles(); 47 | 48 | public: 49 | /** 50 | Read the value of the specified digital pin for this controller. 51 | 52 | @param pin The pin of the controller jack to read 53 | @return The state of the pin 54 | */ 55 | virtual bool read(DigitalPin pin); 56 | 57 | /** 58 | Read the resistance at the specified analog pin for this controller. 59 | The returned value is the resistance measured in ohms. 60 | 61 | @param pin The pin of the controller jack to read 62 | @return The resistance at the specified pin 63 | */ 64 | virtual Int32 read(AnalogPin pin); 65 | 66 | /** 67 | Write the given value to the specified digital pin for this 68 | controller. Writing is only allowed to the pins associated 69 | with the PIA. Therefore you cannot write to pin six. 70 | 71 | @param pin The pin of the controller jack to write to 72 | @param value The value to write to the pin 73 | */ 74 | virtual void write(DigitalPin pin, bool value); 75 | 76 | private: 77 | // Used to implement paddle swapping efficiently, and eliminate 78 | // testing at runtime 79 | Event::Type myPinEvents[4][2]; 80 | }; 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | // Returns a static Random object. DO NOT USE THIS. This is mostly meant for use by the 65 | // code for the various cartridges. 66 | static Random& getInstance(); 67 | 68 | /** 69 | Serializes the RNG state. 70 | */ 71 | bool saveState(Serializer& out); 72 | 73 | /** 74 | Deserializes the RNG state. 75 | */ 76 | bool loadState(Deserializer& in); 77 | 78 | private: 79 | 80 | // Actual rng (implementation hidden away from the header to avoid depending on rng libraries). 81 | class Impl; 82 | Impl *m_pimpl; 83 | 84 | // A static Random object. Don't use this. 85 | static Random s_random; 86 | }; 87 | #endif 88 | 89 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifdef _WIN32 24 | # include 25 | #else 26 | # if HAVE_UNISTD_H 27 | # include 28 | # endif 29 | #endif 30 | 31 | #if HAVE_LIBC_H 32 | /* From NeXT stuff */ 33 | #include 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | 23 | typedef unsigned char byte_t; 24 | 25 | #define RAM_SIZE (128) 26 | 27 | /** A simple wrapper around the Atari RAM. */ 28 | class ALERAM { 29 | public: 30 | ALERAM(); 31 | ALERAM(const ALERAM &rhs); 32 | 33 | ALERAM& operator=(const ALERAM &rhs); 34 | 35 | /** Byte accessors */ 36 | byte_t get(unsigned int x) const; 37 | byte_t *byte(unsigned int x); 38 | 39 | /** Returns the whole array (equivalent to byte(0)). */ 40 | byte_t *array() const { return (byte_t*)(m_ram); } 41 | 42 | size_t size() const { return sizeof(m_ram); } 43 | /** Returns whether two copies of the RAM are equal */ 44 | bool equals(const ALERAM &rhs) const; 45 | 46 | protected: 47 | byte_t m_ram[RAM_SIZE]; 48 | }; 49 | 50 | inline ALERAM::ALERAM() { 51 | } 52 | 53 | inline ALERAM::ALERAM(const ALERAM &rhs) { 54 | // Copy data over 55 | memcpy(m_ram, rhs.m_ram, sizeof(m_ram)); 56 | } 57 | 58 | inline ALERAM& ALERAM::operator=(const ALERAM &rhs) { 59 | // Copy data over 60 | memcpy(m_ram, rhs.m_ram, sizeof(m_ram)); 61 | 62 | return *this; 63 | } 64 | 65 | inline bool ALERAM::equals(const ALERAM &rhs) const { 66 | return (memcmp(m_ram, rhs.m_ram, size()) == 0); 67 | } 68 | 69 | // Byte accessors 70 | inline byte_t ALERAM::get(unsigned int x) const { 71 | // Wrap RAM around the first 128 bytes 72 | return m_ram[x & 0x7F]; 73 | } 74 | 75 | inline byte_t* ALERAM::byte(unsigned int x) { 76 | return &m_ram[x & 0x7F]; 77 | } 78 | 79 | #endif // __ALE_RAM_HPP__ 80 | 81 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | class PhosphorBlend { 24 | public: 25 | PhosphorBlend(OSystem *); 26 | 27 | void process(ALEScreen& screen); 28 | 29 | private: 30 | void makeAveragePalette(); 31 | uInt8 getPhosphor(uInt8 v1, uInt8 v2); 32 | uInt32 makeRGB(uInt8 r, uInt8 g, uInt8 b); 33 | /** Converts a RGB value to an 8-bit format */ 34 | uInt8 rgbToNTSC(uInt32 rgb); 35 | 36 | private: 37 | OSystem * m_osystem; 38 | 39 | uInt8 m_rgb_ntsc[64][64][64]; 40 | 41 | uInt32 m_avg_palette[256][256]; 42 | uInt8 m_phosphor_blend_ratio; 43 | }; 44 | 45 | #endif // __PHOSPHOR_BLEND_HPP__ 46 | 47 | -------------------------------------------------------------------------------- /atari_py/ale_interface/src/environment/stella_environment_wrapper.cpp: -------------------------------------------------------------------------------- 1 | #include "stella_environment.hpp" 2 | #include "stella_environment_wrapper.hpp" 3 | 4 | StellaEnvironmentWrapper::StellaEnvironmentWrapper(StellaEnvironment &environment) : 5 | m_environment(environment) { 6 | } 7 | 8 | reward_t StellaEnvironmentWrapper::act(Action player_a_action, Action player_b_action) { 9 | return m_environment.act(player_a_action, player_b_action); 10 | } 11 | 12 | void StellaEnvironmentWrapper::softReset() { 13 | m_environment.softReset(); 14 | } 15 | 16 | void StellaEnvironmentWrapper::pressSelect(size_t num_steps) { 17 | m_environment.pressSelect(num_steps); 18 | } 19 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | 22 | class StellaEnvironment; 23 | 24 | class StellaEnvironmentWrapper { 25 | // A wrapper for actions within the StellaEnvironment. 26 | // Allows us to call environment methods without requiring to #include 27 | // stella_environment.hpp. 28 | public: 29 | StellaEnvironmentWrapper(StellaEnvironment &environment); 30 | reward_t act(Action player_a_action, Action player_b_action); 31 | void softReset(); 32 | void pressSelect(size_t num_steps = 1); 33 | 34 | StellaEnvironment &m_environment; 35 | }; 36 | 37 | #endif // __STELLA_ENVIRONMENT_WRAPPER_HPP__ 38 | 39 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #include "RomSettings.hpp" 19 | 20 | RomSettings::RomSettings() {} 21 | 22 | 23 | bool RomSettings::isLegal(const Action& a) const { 24 | return true; 25 | } 26 | 27 | ActionVect RomSettings::getMinimalActionSet() { 28 | ActionVect actions; 29 | for (int a = 0; a < PLAYER_B_NOOP; a++) { 30 | if (isMinimal((Action)a) && isLegal((Action)a)) { 31 | actions.push_back((Action)a); 32 | } 33 | } 34 | return actions; 35 | } 36 | 37 | ActionVect RomSettings::getAllActions() { 38 | ActionVect actions; 39 | for (int a = 0; a < PLAYER_B_NOOP; a++) { 40 | if (isLegal((Action)a)) { 41 | actions.push_back((Action)a); 42 | } 43 | } 44 | return actions; 45 | } 46 | 47 | ActionVect RomSettings::getStartingActions() { 48 | return ActionVect(); 49 | } 50 | 51 | ModeVect RomSettings::getAvailableModes() { 52 | return ModeVect(1, 0); 53 | }; 54 | 55 | void RomSettings::setMode(game_mode_t m, System&, StellaEnvironmentWrapper&) { 56 | //By default, 0 is the only available mode 57 | if(m != 0) { 58 | throw std::runtime_error("This mode is not currently available for this game"); 59 | } 60 | } 61 | 62 | DifficultyVect RomSettings::getAvailableDifficulties() { 63 | return DifficultyVect(1, 0); 64 | }; 65 | -------------------------------------------------------------------------------- /atari_py/ale_interface/src/games/RomUtils.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 | * RomUtils.hpp 13 | * 14 | * Additional utilities to operate on RAM. 15 | * ***************************************************************************** 16 | */ 17 | #include "RomUtils.hpp" 18 | 19 | #include "System.hxx" 20 | 21 | 22 | /* reads a byte at a memory location between 0 and 128 */ 23 | int readRam(const System* system, int offset) { 24 | 25 | // peek modifies data-bus state, but is logically const from 26 | // the point of view of the RL interface 27 | System* sys = const_cast(system); 28 | 29 | return sys->peek((offset & 0x7F) + 0x80); 30 | } 31 | 32 | /* extracts a decimal value from a byte */ 33 | int getDecimalScore(int index, const System* system) { 34 | 35 | int score = 0; 36 | int digits_val = readRam(system, index); 37 | int right_digit = digits_val & 15; 38 | int left_digit = digits_val >> 4; 39 | score += ((10 * left_digit) + right_digit); 40 | 41 | return score; 42 | } 43 | 44 | 45 | /* extracts a decimal value from 2 bytes */ 46 | int getDecimalScore(int lower_index, int higher_index, const System* system) { 47 | 48 | int score = 0; 49 | int lower_digits_val = readRam(system, lower_index); 50 | int lower_right_digit = lower_digits_val & 15; 51 | int lower_left_digit = (lower_digits_val - lower_right_digit) >> 4; 52 | score += ((10 * lower_left_digit) + lower_right_digit); 53 | if (higher_index < 0) { 54 | return score; 55 | } 56 | int higher_digits_val = readRam(system, higher_index); 57 | int higher_right_digit = higher_digits_val & 15; 58 | int higher_left_digit = (higher_digits_val - higher_right_digit) >> 4; 59 | score += ((1000 * higher_left_digit) + 100 * higher_right_digit); 60 | return score; 61 | } 62 | 63 | 64 | /* extracts a decimal value from 3 bytes */ 65 | int getDecimalScore(int lower_index, int middle_index, int higher_index, const System* system) { 66 | 67 | int score = getDecimalScore(lower_index, middle_index, system); 68 | int higher_digits_val = readRam(system, higher_index); 69 | int higher_right_digit = higher_digits_val & 15; 70 | int higher_left_digit = (higher_digits_val - higher_right_digit) >> 4; 71 | score += ((100000 * higher_left_digit) + 10000 * higher_right_digit); 72 | return score; 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __ROMUTILS_HPP__ 18 | #define __ROMUTILS_HPP__ 19 | 20 | class System; 21 | 22 | // reads a byte at a memory location between 0 and 1023 23 | extern int readRam(const System* system, int offset); 24 | 25 | // extracts a decimal value from 1, 2, and 3 bytes respectively 26 | extern int getDecimalScore(int idx, const System* system); 27 | extern int getDecimalScore(int lo, int hi, const System* system); 28 | extern int getDecimalScore(int lo, int mid, int hi, const System* system); 29 | 30 | #endif // __ROMUTILS_HPP__ 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __ROMS_HPP__ 13 | #define __ROMS_HPP__ 14 | 15 | #include "RomSettings.hpp" 16 | 17 | #include 18 | #include 19 | 20 | // looks for the RL wrapper corresponding to a particular rom title 21 | extern RomSettings *buildRomRLWrapper(const std::string &rom_name); 22 | 23 | 24 | #endif // __ROMS_HPP__ 25 | 26 | -------------------------------------------------------------------------------- /atari_py/ale_interface/src/games/supported/Adventure.hpp: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * 3 | * This program is free software; you can redistribute it and/or 4 | * modify it under the terms of the GNU General Public License version 2 5 | * as published by the Free Software Foundation. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 | * ***************************************************************************** 16 | * A.L.E (Arcade Learning Environment) 17 | * Copyright (c) 2009-2013 by Yavar Naddaf, Joel Veness, Marc G. Bellemare and 18 | * the Reinforcement Learning and Artificial Intelligence Laboratory 19 | * Released under the GNU General Public License; see License.txt for details. 20 | * 21 | * Based on: Stella -- "An Atari 2600 VCS Emulator" 22 | * Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team 23 | * 24 | * ***************************************************************************** 25 | */ 26 | #ifndef __ADVENTURE_HPP__ 27 | #define __ADVENTURE_HPP__ 28 | 29 | #include "../RomSettings.hpp" 30 | 31 | 32 | /* RL wrapper for Adventure settings */ 33 | class AdventureSettings : public RomSettings { 34 | 35 | public: 36 | 37 | AdventureSettings(); 38 | 39 | // reset 40 | void reset(); 41 | 42 | // is end of game 43 | bool isTerminal() const; 44 | 45 | // get the most recently observed reward 46 | reward_t getReward() const; 47 | 48 | // the rom-name 49 | const char* rom() const { return "adventure"; } 50 | 51 | // create a new instance of the rom 52 | RomSettings* clone() const; 53 | 54 | // is an action part of the minimal set? 55 | bool isMinimal(const Action& a) const; 56 | 57 | // process the latest information from ALE 58 | void step(const System& system); 59 | 60 | // saves the state of the rom settings 61 | void saveState(Serializer & ser); 62 | 63 | // loads the state of the rom settings 64 | void loadState(Deserializer & ser); 65 | 66 | virtual int lives() { return 1; } 67 | 68 | private: 69 | 70 | bool m_terminal; 71 | reward_t m_reward; 72 | }; 73 | 74 | #endif // __ADVENTURE_HPP__ 75 | 76 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __AIRRAID_HPP__ 13 | #define __AIRRAID_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | 18 | /* RL wrapper for Air Raid settings */ 19 | class AirRaidSettings : public RomSettings { 20 | 21 | public: 22 | 23 | AirRaidSettings(); 24 | 25 | // reset 26 | void reset(); 27 | 28 | // is end of game 29 | bool isTerminal() const; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const; 33 | 34 | // the rom-name 35 | const char* rom() const { 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; 42 | 43 | // is an action part of the minimal set? 44 | bool isMinimal(const Action& a) const; 45 | 46 | // process the latest information from ALE 47 | void step(const System& system); 48 | 49 | // saves the state of the rom settings 50 | void saveState(Serializer & ser); 51 | 52 | // loads the state of the rom settings 53 | void loadState(Deserializer & ser); 54 | 55 | ActionVect getStartingActions(); 56 | 57 | 58 | // returns a list of mode that the game can be played in 59 | // in this game, there are 8 available modes 60 | ModeVect getAvailableModes(); 61 | 62 | // set the mode of the game 63 | // the given mode must be one returned by the previous function 64 | void setMode(game_mode_t, System &system, 65 | StellaEnvironmentWrapper& environment); 66 | 67 | private: 68 | 69 | bool m_terminal; 70 | reward_t m_reward; 71 | reward_t m_score; 72 | }; 73 | 74 | #endif // __AIRRAID_HPP__ 75 | 76 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #include "Carnival.hpp" 13 | 14 | #include "../RomUtils.hpp" 15 | 16 | 17 | CarnivalSettings::CarnivalSettings() { 18 | 19 | reset(); 20 | } 21 | 22 | 23 | /* create a new instance of the rom */ 24 | RomSettings* CarnivalSettings::clone() const { 25 | 26 | RomSettings* rval = new CarnivalSettings(); 27 | *rval = *this; 28 | return rval; 29 | } 30 | 31 | 32 | /* process the latest information from ALE */ 33 | void CarnivalSettings::step(const System& system) { 34 | 35 | // update the reward 36 | reward_t score = getDecimalScore(0xAE, 0xAD, &system); 37 | score *= 10; 38 | m_reward = score - m_score; 39 | m_score = score; 40 | 41 | // update terminal status 42 | int ammo = readRam(&system, 0x83); 43 | m_terminal = ammo < 1; 44 | } 45 | 46 | 47 | /* is end of game */ 48 | bool CarnivalSettings::isTerminal() const { 49 | 50 | return m_terminal; 51 | }; 52 | 53 | 54 | /* get the most recently observed reward */ 55 | reward_t CarnivalSettings::getReward() const { 56 | 57 | return m_reward; 58 | } 59 | 60 | 61 | /* is an action part of the minimal set? */ 62 | bool CarnivalSettings::isMinimal(const Action &a) const { 63 | 64 | switch (a) { 65 | case PLAYER_A_NOOP: 66 | case PLAYER_A_FIRE: 67 | case PLAYER_A_RIGHT: 68 | case PLAYER_A_LEFT: 69 | case PLAYER_A_RIGHTFIRE: 70 | case PLAYER_A_LEFTFIRE: 71 | return true; 72 | default: 73 | return false; 74 | } 75 | } 76 | 77 | 78 | /* reset the state of the game */ 79 | void CarnivalSettings::reset() { 80 | 81 | m_reward = 0; 82 | m_score = 0; 83 | m_terminal = false; 84 | } 85 | 86 | 87 | 88 | /* saves the state of the rom settings */ 89 | void CarnivalSettings::saveState(Serializer & ser) { 90 | ser.putInt(m_reward); 91 | ser.putInt(m_score); 92 | ser.putBool(m_terminal); 93 | } 94 | 95 | // loads the state of the rom settings 96 | void CarnivalSettings::loadState(Deserializer & ser) { 97 | m_reward = ser.getInt(); 98 | m_score = ser.getInt(); 99 | m_terminal = ser.getBool(); 100 | } 101 | 102 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __CARNIVAL_HPP__ 28 | #define __CARNIVAL_HPP__ 29 | 30 | #include "../RomSettings.hpp" 31 | 32 | 33 | /* RL wrapper for Carnival settings */ 34 | class CarnivalSettings : public RomSettings { 35 | 36 | public: 37 | 38 | CarnivalSettings(); 39 | 40 | // reset 41 | void reset(); 42 | 43 | // is end of game 44 | bool isTerminal() const; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const; 48 | 49 | // the rom-name 50 | const char* rom() const { return "carnival"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system); 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer & ser); 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer & ser); 66 | 67 | virtual int lives() { return 0; } 68 | 69 | private: 70 | 71 | bool m_terminal; 72 | reward_t m_reward; 73 | reward_t m_score; 74 | }; 75 | 76 | #endif // __CARNIVAL_HPP__ 77 | 78 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __DONKEYKONG_HPP__ 13 | #define __DONKEYKONG_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | 18 | /* RL wrapper for DonkeyKong */ 19 | class DonkeyKongSettings : public RomSettings { 20 | 21 | public: 22 | 23 | DonkeyKongSettings(); 24 | 25 | // reset 26 | void reset(); 27 | 28 | // is end of game 29 | bool isTerminal() const; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const; 33 | 34 | // the rom-name 35 | // MD5 36b20c427975760cb9cf4a47e41369e4 36 | const char* rom() const { return "donkey_kong"; } 37 | 38 | // create a new instance of the rom 39 | RomSettings* clone() const; 40 | 41 | // is an action part of the minimal set? 42 | bool isMinimal(const Action& a) const; 43 | 44 | // process the latest information from ALE 45 | void step(const System& system); 46 | 47 | // saves the state of the rom settings 48 | void saveState(Serializer & ser); 49 | 50 | // loads the state of the rom settings 51 | void loadState(Deserializer & ser); 52 | 53 | virtual int lives() { 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 | #endif // __DONKEYKONG_HPP__ 63 | 64 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __ENDURO_HPP__ 28 | #define __ENDURO_HPP__ 29 | 30 | #include "../RomSettings.hpp" 31 | 32 | 33 | /* RL wrapper for Enduro settings */ 34 | class EnduroSettings : public RomSettings { 35 | 36 | public: 37 | 38 | EnduroSettings(); 39 | 40 | // reset 41 | void reset(); 42 | 43 | // is end of game 44 | bool isTerminal() const; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const; 48 | 49 | // the rom-name 50 | const char* rom() const { return "enduro"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system); 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer & ser); 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer & ser); 66 | 67 | ActionVect getStartingActions(); 68 | 69 | virtual int lives() { return 0; } 70 | 71 | private: 72 | 73 | bool m_terminal; 74 | reward_t m_reward; 75 | reward_t m_score; 76 | }; 77 | 78 | #endif // __ENDURO_HPP__ 79 | 80 | -------------------------------------------------------------------------------- /atari_py/ale_interface/src/games/supported/Frogger.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 | #include "Frogger.hpp" 13 | 14 | #include "../RomUtils.hpp" 15 | 16 | FroggerSettings::FroggerSettings() { 17 | reset(); 18 | } 19 | 20 | /* create a new instance of the rom */ 21 | RomSettings* FroggerSettings::clone() const { 22 | RomSettings* rval = new FroggerSettings(); 23 | *rval = *this; 24 | return rval; 25 | } 26 | 27 | 28 | /* process the latest information from ALE */ 29 | void FroggerSettings::step(const System& system) { 30 | // update the reward 31 | int score = getDecimalScore(0xCE, 0xCC, &system); 32 | int reward = score - m_score; 33 | m_reward = reward; 34 | m_score = score; 35 | 36 | // update terminal status 37 | m_lives = readRam(&system, 0xD0); 38 | m_terminal = readRam(&system, 0xD0) == 0xFF; 39 | } 40 | 41 | 42 | /* is end of game */ 43 | bool FroggerSettings::isTerminal() const { 44 | return m_terminal; 45 | }; 46 | 47 | 48 | /* get the most recently observed reward */ 49 | reward_t FroggerSettings::getReward() const { 50 | return m_reward; 51 | } 52 | 53 | /* is an action part of the minimal set? */ 54 | bool FroggerSettings::isMinimal(const Action &a) const { 55 | switch (a) { 56 | case PLAYER_A_NOOP: 57 | case PLAYER_A_UP: 58 | case PLAYER_A_RIGHT: 59 | case PLAYER_A_LEFT: 60 | case PLAYER_A_DOWN: 61 | return true; 62 | default: 63 | return false; 64 | } 65 | } 66 | 67 | 68 | /* reset the state of the game */ 69 | void FroggerSettings::reset() { 70 | m_reward = 0; 71 | m_score = 0; 72 | m_terminal = false; 73 | m_lives = 4; 74 | } 75 | 76 | /* saves the state of the rom settings */ 77 | void FroggerSettings::saveState(Serializer & ser) { 78 | ser.putInt(m_reward); 79 | ser.putInt(m_score); 80 | ser.putBool(m_terminal); 81 | ser.putInt(m_lives); 82 | } 83 | 84 | // loads the state of the rom settings 85 | void FroggerSettings::loadState(Deserializer & ser) { 86 | m_reward = ser.getInt(); 87 | m_score = ser.getInt(); 88 | m_terminal = ser.getBool(); 89 | m_lives = ser.getInt(); 90 | } 91 | 92 | ActionVect FroggerSettings::getStartingActions() { 93 | ActionVect startingActions; 94 | startingActions.push_back(RESET); 95 | return startingActions; 96 | } 97 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __FROGGER_HPP__ 13 | #define __FROGGER_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | 18 | /* RL wrapper for Frogger */ 19 | class FroggerSettings : public RomSettings { 20 | public: 21 | FroggerSettings(); 22 | 23 | // reset 24 | void reset(); 25 | 26 | // is end of game 27 | bool isTerminal() const; 28 | 29 | // get the most recently observed reward 30 | reward_t getReward() const; 31 | 32 | // the rom-name 33 | // MD5 081e2c114c9c20b61acf25fc95c71bf4 34 | const char* rom() const { return "frogger"; } 35 | 36 | // create a new instance of the rom 37 | RomSettings* clone() const; 38 | 39 | // is an action part of the minimal set? 40 | bool isMinimal(const Action& a) const; 41 | 42 | // process the latest information from ALE 43 | void step(const System& system); 44 | 45 | // saves the state of the rom settings 46 | void saveState(Serializer & ser); 47 | 48 | // loads the state of the rom settings 49 | void loadState(Deserializer & ser); 50 | 51 | // Frogger requires the RESET action to start the game 52 | ActionVect getStartingActions(); 53 | 54 | virtual int lives() { return isTerminal() ? 0 : m_lives; } 55 | 56 | private: 57 | bool m_terminal; 58 | reward_t m_reward; 59 | reward_t m_score; 60 | int m_lives; 61 | }; 62 | 63 | #endif // __FROGGER_HPP__ 64 | 65 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __KABOOM_HPP__ 13 | #define __KABOOM_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | /* RL wrapper for Kaboom settings */ 18 | class KaboomSettings: public RomSettings 19 | { 20 | 21 | public: 22 | 23 | KaboomSettings(); 24 | 25 | // reset 26 | void reset(); 27 | 28 | // is end of game 29 | bool isTerminal() const; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const; 33 | 34 | // the rom-name 35 | const char* rom() const 36 | { 37 | return "kaboom"; 38 | } 39 | 40 | // create a new instance of the rom 41 | RomSettings* clone() const; 42 | 43 | // is an action part of the minimal set? 44 | bool isMinimal(const Action& a) const; 45 | 46 | // process the latest information from ALE 47 | void step(const System& system); 48 | 49 | // saves the state of the rom settings 50 | void saveState(Serializer & ser); 51 | 52 | // loads the state of the rom settings 53 | void loadState(Deserializer & ser); 54 | 55 | ActionVect getStartingActions(); 56 | 57 | private: 58 | 59 | bool m_terminal; 60 | reward_t m_reward; 61 | reward_t m_score; 62 | }; 63 | 64 | #endif // __KABOOM__ 65 | 66 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __KEYSTONEKAPERS_HPP__ 13 | #define __KEYSTONEKAPERS_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | 18 | /* RL wrapper for KeystoneKapers */ 19 | class KeystoneKapersSettings : public RomSettings { 20 | 21 | public: 22 | KeystoneKapersSettings(); 23 | 24 | // reset 25 | void reset(); 26 | 27 | // is end of game 28 | bool isTerminal() const; 29 | 30 | // get the most recently observed reward 31 | reward_t getReward() const; 32 | 33 | // the rom-name 34 | // MD5 be929419902e21bd7830a7a7d746195d 35 | const char* rom() const { return "keystone_kapers"; } 36 | 37 | // create a new instance of the rom 38 | RomSettings* clone() const; 39 | 40 | // is an action part of the minimal set? 41 | bool isMinimal(const Action& a) const; 42 | 43 | // process the latest information from ALE 44 | void step(const System& system); 45 | 46 | // saves the state of the rom settings 47 | void saveState(Serializer & ser); 48 | 49 | // loads the state of the rom settings 50 | void loadState(Deserializer & ser); 51 | 52 | // Keystone Kapers requires the reset button to start the game 53 | ActionVect getStartingActions(); 54 | 55 | virtual int lives() { return isTerminal() ? 0 : m_lives; } 56 | 57 | private: 58 | bool m_terminal; 59 | reward_t m_reward; 60 | reward_t m_score; 61 | int m_lives; 62 | }; 63 | 64 | #endif // __KEYSTONEKAPERS_HPP__ 65 | 66 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #include "Koolaid.hpp" 13 | 14 | #include "../RomUtils.hpp" 15 | 16 | 17 | KoolaidSettings::KoolaidSettings() { 18 | 19 | reset(); 20 | } 21 | 22 | 23 | /* create a new instance of the rom */ 24 | RomSettings* KoolaidSettings::clone() const { 25 | 26 | RomSettings* rval = new KoolaidSettings(); 27 | *rval = *this; 28 | return rval; 29 | } 30 | 31 | 32 | /* process the latest information from ALE */ 33 | void KoolaidSettings::step(const System& system) { 34 | 35 | // update the reward 36 | int score = getDecimalScore(0x81, 0x80, &system); 37 | score *= 100; 38 | int reward = score - m_score; 39 | m_reward = reward; 40 | m_score = score; 41 | 42 | m_terminal = readRam(&system, 0xD1) == 0x80; 43 | } 44 | 45 | 46 | /* is end of game */ 47 | bool KoolaidSettings::isTerminal() const { 48 | 49 | return m_terminal; 50 | }; 51 | 52 | 53 | /* get the most recently observed reward */ 54 | reward_t KoolaidSettings::getReward() const { 55 | 56 | return m_reward; 57 | } 58 | 59 | 60 | /* is an action part of the minimal set? */ 61 | bool KoolaidSettings::isMinimal(const Action &a) const { 62 | 63 | switch (a) { 64 | case PLAYER_A_NOOP: 65 | case PLAYER_A_UP: 66 | case PLAYER_A_RIGHT: 67 | case PLAYER_A_LEFT: 68 | case PLAYER_A_DOWN: 69 | case PLAYER_A_UPRIGHT: 70 | case PLAYER_A_UPLEFT: 71 | case PLAYER_A_DOWNRIGHT: 72 | case PLAYER_A_DOWNLEFT: 73 | return true; 74 | default: 75 | return false; 76 | } 77 | } 78 | 79 | 80 | /* reset the state of the game */ 81 | void KoolaidSettings::reset() { 82 | 83 | m_reward = 0; 84 | m_score = 0; 85 | m_terminal = false; 86 | } 87 | 88 | /* saves the state of the rom settings */ 89 | void KoolaidSettings::saveState(Serializer & ser) { 90 | ser.putInt(m_reward); 91 | ser.putInt(m_score); 92 | ser.putBool(m_terminal); 93 | } 94 | 95 | // loads the state of the rom settings 96 | void KoolaidSettings::loadState(Deserializer & ser) { 97 | m_reward = ser.getInt(); 98 | m_score = ser.getInt(); 99 | m_terminal = ser.getBool(); 100 | } 101 | 102 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __KOOLAID_HPP__ 13 | #define __KOOLAID_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | 18 | /* RL wrapper for Koolaid */ 19 | class KoolaidSettings : public RomSettings { 20 | 21 | public: 22 | 23 | KoolaidSettings(); 24 | 25 | // reset 26 | void reset(); 27 | 28 | // is end of game 29 | bool isTerminal() const; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const; 33 | 34 | // the rom-name 35 | const char* rom() const { return "koolaid"; } 36 | 37 | // create a new instance of the rom 38 | RomSettings* clone() const; 39 | 40 | // is an action part of the minimal set? 41 | bool isMinimal(const Action& a) const; 42 | 43 | // process the latest information from ALE 44 | void step(const System& system); 45 | 46 | // saves the state of the rom settings 47 | void saveState(Serializer & ser); 48 | 49 | // loads the state of the rom settings 50 | void loadState(Deserializer & ser); 51 | 52 | virtual int lives() { return 0; } 53 | 54 | private: 55 | 56 | bool m_terminal; 57 | reward_t m_reward; 58 | reward_t m_score; 59 | }; 60 | 61 | #endif // __KOOLAID_HPP__ 62 | 63 | 64 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __KRULL_HPP__ 28 | #define __KRULL_HPP__ 29 | 30 | #include "../RomSettings.hpp" 31 | 32 | 33 | /* RL wrapper for Krull */ 34 | class KrullSettings : public RomSettings { 35 | 36 | public: 37 | 38 | KrullSettings(); 39 | 40 | // reset 41 | void reset(); 42 | 43 | // is end of game 44 | bool isTerminal() const; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const; 48 | 49 | // the rom-name 50 | const char* rom() const { return "krull"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system); 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer & ser); 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer & ser); 66 | 67 | virtual int lives() { return isTerminal() ? 0 : m_lives; } 68 | 69 | private: 70 | 71 | bool m_terminal; 72 | reward_t m_reward; 73 | reward_t m_score; 74 | int m_lives; 75 | }; 76 | 77 | #endif // __KRULL_HPP__ 78 | 79 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __LASERGATES_HPP__ 13 | #define __LASERGATES_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | 18 | /* RL wrapper for Laser Gates */ 19 | class LaserGatesSettings : public RomSettings { 20 | public: 21 | LaserGatesSettings(); 22 | 23 | // reset 24 | void reset(); 25 | 26 | // is end of game 27 | bool isTerminal() const; 28 | 29 | // get the most recently observed reward 30 | reward_t getReward() const; 31 | 32 | // the rom-name 33 | // MD5 1fa58679d4a39052bd9db059e8cda4ad 34 | const char* rom() const { return "laser_gates"; } 35 | 36 | // create a new instance of the rom 37 | RomSettings* clone() const; 38 | 39 | // is an action part of the minimal set? 40 | bool isMinimal(const Action& a) const; 41 | 42 | // process the latest information from ALE 43 | void step(const System& system); 44 | 45 | // saves the state of the rom settings 46 | void saveState(Serializer & ser); 47 | 48 | // loads the state of the rom settings 49 | void loadState(Deserializer & ser); 50 | 51 | // LaserGates requires the fire action to start the game 52 | ActionVect getStartingActions(); 53 | 54 | virtual int lives() { return 0; } 55 | 56 | private: 57 | bool m_terminal; 58 | reward_t m_reward; 59 | reward_t m_score; 60 | }; 61 | 62 | #endif // __LASERGATES_HPP__ 63 | 64 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __LOSTLUGGAGE_HPP__ 13 | #define __LOSTLUGGAGE_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | /* RL wrapper for Lost Luggage */ 18 | class LostLuggageSettings : public RomSettings { 19 | public: 20 | LostLuggageSettings(); 21 | 22 | // reset 23 | void reset(); 24 | 25 | // is end of game 26 | bool isTerminal() const; 27 | 28 | // get the most recently observed reward 29 | reward_t getReward() const; 30 | 31 | // the rom-name 32 | // MD5 7c00e7a205d3fda98eb20da7c9c50a55 33 | const char* rom() const { return "lost_luggage"; } 34 | 35 | // create a new instance of the rom 36 | RomSettings* clone() const; 37 | 38 | // is an action part of the minimal set? 39 | bool isMinimal(const Action& a) const; 40 | 41 | // FIRE resets the game, prevent this 42 | bool isLegal(const Action& a) const; 43 | 44 | // process the latest information from ALE 45 | void step(const System& system); 46 | 47 | // saves the state of the rom settings 48 | void saveState(Serializer & ser); 49 | 50 | // loads the state of the rom settings 51 | void loadState(Deserializer & ser); 52 | 53 | // LostLuggage requires the fire action to start the game 54 | ActionVect getStartingActions(); 55 | 56 | virtual int lives() { 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 | #endif // __LOSTLUGGAGE_HPP__ 66 | 67 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __MRDO_HPP__ 13 | #define __MRDO_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | 18 | /* RL wrapper for MrDo */ 19 | class MrDoSettings : public RomSettings { 20 | 21 | public: 22 | 23 | MrDoSettings(); 24 | 25 | // reset 26 | void reset(); 27 | 28 | // is end of game 29 | bool isTerminal() const; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const; 33 | 34 | // the rom-name 35 | const char* rom() const { return "mr_do"; } 36 | 37 | // create a new instance of the rom 38 | RomSettings* clone() const; 39 | 40 | // is an action part of the minimal set? 41 | bool isMinimal(const Action& a) const; 42 | 43 | // process the latest information from ALE 44 | void step(const System& system); 45 | 46 | // saves the state of the rom settings 47 | void saveState(Serializer & ser); 48 | 49 | // loads the state of the rom settings 50 | void loadState(Deserializer & ser); 51 | 52 | // Mr. Do requires the fire action to start the game 53 | ActionVect getStartingActions(); 54 | 55 | virtual int lives() { return isTerminal() ? 0 : m_lives; } 56 | 57 | private: 58 | 59 | bool m_terminal; 60 | reward_t m_reward; 61 | reward_t m_score; 62 | int m_lives; 63 | }; 64 | 65 | #endif // __MRDO_HPP__ 66 | 67 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __PHOENIX_HPP__ 28 | #define __PHOENIX_HPP__ 29 | 30 | #include "../RomSettings.hpp" 31 | 32 | 33 | /* RL wrapper for Phoenix */ 34 | class PhoenixSettings : public RomSettings { 35 | 36 | public: 37 | 38 | PhoenixSettings(); 39 | 40 | // reset 41 | void reset(); 42 | 43 | // is end of game 44 | bool isTerminal() const; 45 | 46 | // get the most recently observed reward 47 | reward_t getReward() const; 48 | 49 | // the rom-name 50 | const char* rom() const { return "phoenix"; } 51 | 52 | // create a new instance of the rom 53 | RomSettings* clone() const; 54 | 55 | // is an action part of the minimal set? 56 | bool isMinimal(const Action& a) const; 57 | 58 | // process the latest information from ALE 59 | void step(const System& system); 60 | 61 | // saves the state of the rom settings 62 | void saveState(Serializer & ser); 63 | 64 | // loads the state of the rom settings 65 | void loadState(Deserializer & ser); 66 | 67 | virtual int lives() { return isTerminal() ? 0 : m_lives; } 68 | 69 | private: 70 | 71 | bool m_terminal; 72 | reward_t m_reward; 73 | reward_t m_score; 74 | int m_lives; 75 | }; 76 | 77 | #endif // __PHOENIX_HPP__ 78 | 79 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __SIRLANCELOT_HPP__ 13 | #define __SIRLANCELOT_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | 18 | /* RL wrapper for Up N Down */ 19 | class SirLancelotSettings : public RomSettings { 20 | public: 21 | SirLancelotSettings(); 22 | 23 | // reset 24 | void reset(); 25 | 26 | // is end of game 27 | bool isTerminal() const; 28 | 29 | // get the most recently observed reward 30 | reward_t getReward() const; 31 | 32 | // the rom-name 33 | // MD5 7ead257e8b5a44cac538f5f54c7a0023 34 | const char* rom() const { return "sir_lancelot"; } 35 | 36 | // create a new instance of the rom 37 | RomSettings* clone() const; 38 | 39 | // is an action part of the minimal set? 40 | bool isMinimal(const Action& a) const; 41 | 42 | // process the latest information from ALE 43 | void step(const System& system); 44 | 45 | // saves the state of the rom settings 46 | void saveState(Serializer & ser); 47 | 48 | // loads the state of the rom settings 49 | void loadState(Deserializer & ser); 50 | 51 | // SirLancelot requires the reset+left action to start the game 52 | ActionVect getStartingActions(); 53 | 54 | virtual int lives() { return isTerminal() ? 0 : m_lives; } 55 | 56 | private: 57 | bool m_terminal; 58 | reward_t m_reward; 59 | reward_t m_score; 60 | int m_lives; 61 | }; 62 | 63 | #endif // __SIRLANCELOT_HPP__ 64 | 65 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __TETRIS_HPP__ 26 | #define __TETRIS_HPP__ 27 | 28 | #include "../RomSettings.hpp" 29 | 30 | 31 | /* RL wrapper for Tetris */ 32 | class TetrisSettings : public RomSettings { 33 | 34 | public: 35 | 36 | TetrisSettings(); 37 | 38 | // reset 39 | void reset(); 40 | 41 | // is end of game 42 | bool isTerminal() const; 43 | 44 | // get the most recently observed reward 45 | reward_t getReward() const; 46 | 47 | // the rom-name 48 | const char* rom() const { return "tetris"; } 49 | 50 | // create a new instance of the rom 51 | RomSettings* clone() const; 52 | 53 | // is an action part of the minimal set? 54 | bool isMinimal(const Action& a) const; 55 | 56 | // process the latest information from ALE 57 | void step(const System& system); 58 | 59 | // saves the state of the rom settings 60 | void saveState(Serializer & ser); 61 | 62 | // loads the state of the rom settings 63 | void loadState(Deserializer & ser); 64 | 65 | // remaining lives 66 | int lives() { return isTerminal() ? 0 : m_lives; } 67 | 68 | private: 69 | 70 | bool m_terminal; 71 | bool m_started; 72 | reward_t m_reward; 73 | reward_t m_score; 74 | int m_lives; 75 | }; 76 | 77 | #endif // __TETRIS_HPP__ 78 | 79 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __TRONDEAD_HPP__ 13 | #define __TRONDEAD_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | 18 | /* RL wrapper for Trondead */ 19 | class TrondeadSettings : public RomSettings { 20 | 21 | public: 22 | 23 | TrondeadSettings(); 24 | 25 | // reset 26 | void reset(); 27 | 28 | // is end of game 29 | bool isTerminal() const; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const; 33 | 34 | // the rom-name 35 | const char* rom() const { return "trondead"; } 36 | 37 | // create a new instance of the rom 38 | RomSettings* clone() const; 39 | 40 | // is an action part of the minimal set? 41 | bool isMinimal(const Action& a) const; 42 | 43 | // process the latest information from ALE 44 | void step(const System& system); 45 | 46 | // saves the state of the rom settings 47 | void saveState(Serializer & ser); 48 | 49 | // loads the state of the rom settings 50 | void loadState(Deserializer & ser); 51 | 52 | virtual int lives() { return isTerminal() ? 0 : m_lives; } 53 | 54 | private: 55 | 56 | bool m_terminal; 57 | reward_t m_reward; 58 | reward_t m_score; 59 | int m_lives; 60 | }; 61 | 62 | #endif // __TRONDEAD_HPP__ 63 | 64 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | #ifndef __TURMOIL_HPP__ 13 | #define __TURMOIL_HPP__ 14 | 15 | #include "../RomSettings.hpp" 16 | 17 | 18 | /* RL wrapper for Turmoil */ 19 | class TurmoilSettings : public RomSettings { 20 | 21 | public: 22 | 23 | TurmoilSettings(); 24 | 25 | // reset 26 | void reset(); 27 | 28 | // is end of game 29 | bool isTerminal() const; 30 | 31 | // get the most recently observed reward 32 | reward_t getReward() const; 33 | 34 | // the rom-name 35 | // MD5 sum of ROM file: 36 | // 7a5463545dfb2dcfdafa6074b2f2c15e Turmoil.bin 37 | const char* rom() const { return "turmoil"; } 38 | 39 | // create a new instance of the rom 40 | RomSettings* clone() const; 41 | 42 | // is an action part of the minimal set? 43 | bool isMinimal(const Action& a) const; 44 | 45 | // process the latest information from ALE 46 | void step(const System& system); 47 | 48 | // saves the state of the rom settings 49 | void saveState(Serializer & ser); 50 | 51 | // loads the state of the rom settings 52 | void loadState(Deserializer & ser); 53 | 54 | // Turmoil requires the fire action to start the game 55 | ActionVect getStartingActions(); 56 | 57 | virtual int lives() { return isTerminal() ? 0 : m_lives; } 58 | 59 | private: 60 | 61 | bool m_terminal; 62 | reward_t m_reward; 63 | reward_t m_score; 64 | int m_lives; 65 | }; 66 | 67 | #endif // __TURMOIL_HPP__ 68 | 69 | 70 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/ale_interface/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 | -------------------------------------------------------------------------------- /atari_py/atari_ntsc_rgb_palette.h: -------------------------------------------------------------------------------- 1 | //taken from Stella in Arcade-Learning-Environment/src/emucore/console.cxx 2 | static const int rgb_palette[256] = { 3 | 0x000000, 0, 0x4a4a4a, 0, 0x6f6f6f, 0, 0x8e8e8e, 0, 4 | 0xaaaaaa, 0, 0xc0c0c0, 0, 0xd6d6d6, 0, 0xececec, 0, 5 | 0x484800, 0, 0x69690f, 0, 0x86861d, 0, 0xa2a22a, 0, 6 | 0xbbbb35, 0, 0xd2d240, 0, 0xe8e84a, 0, 0xfcfc54, 0, 7 | 0x7c2c00, 0, 0x904811, 0, 0xa26221, 0, 0xb47a30, 0, 8 | 0xc3903d, 0, 0xd2a44a, 0, 0xdfb755, 0, 0xecc860, 0, 9 | 0x901c00, 0, 0xa33915, 0, 0xb55328, 0, 0xc66c3a, 0, 10 | 0xd5824a, 0, 0xe39759, 0, 0xf0aa67, 0, 0xfcbc74, 0, 11 | 0x940000, 0, 0xa71a1a, 0, 0xb83232, 0, 0xc84848, 0, 12 | 0xd65c5c, 0, 0xe46f6f, 0, 0xf08080, 0, 0xfc9090, 0, 13 | 0x840064, 0, 0x97197a, 0, 0xa8308f, 0, 0xb846a2, 0, 14 | 0xc659b3, 0, 0xd46cc3, 0, 0xe07cd2, 0, 0xec8ce0, 0, 15 | 0x500084, 0, 0x68199a, 0, 0x7d30ad, 0, 0x9246c0, 0, 16 | 0xa459d0, 0, 0xb56ce0, 0, 0xc57cee, 0, 0xd48cfc, 0, 17 | 0x140090, 0, 0x331aa3, 0, 0x4e32b5, 0, 0x6848c6, 0, 18 | 0x7f5cd5, 0, 0x956fe3, 0, 0xa980f0, 0, 0xbc90fc, 0, 19 | 0x000094, 0, 0x181aa7, 0, 0x2d32b8, 0, 0x4248c8, 0, 20 | 0x545cd6, 0, 0x656fe4, 0, 0x7580f0, 0, 0x8490fc, 0, 21 | 0x001c88, 0, 0x183b9d, 0, 0x2d57b0, 0, 0x4272c2, 0, 22 | 0x548ad2, 0, 0x65a0e1, 0, 0x75b5ef, 0, 0x84c8fc, 0, 23 | 0x003064, 0, 0x185080, 0, 0x2d6d98, 0, 0x4288b0, 0, 24 | 0x54a0c5, 0, 0x65b7d9, 0, 0x75cceb, 0, 0x84e0fc, 0, 25 | 0x004030, 0, 0x18624e, 0, 0x2d8169, 0, 0x429e82, 0, 26 | 0x54b899, 0, 0x65d1ae, 0, 0x75e7c2, 0, 0x84fcd4, 0, 27 | 0x004400, 0, 0x1a661a, 0, 0x328432, 0, 0x48a048, 0, 28 | 0x5cba5c, 0, 0x6fd26f, 0, 0x80e880, 0, 0x90fc90, 0, 29 | 0x143c00, 0, 0x355f18, 0, 0x527e2d, 0, 0x6e9c42, 0, 30 | 0x87b754, 0, 0x9ed065, 0, 0xb4e775, 0, 0xc8fc84, 0, 31 | 0x303800, 0, 0x505916, 0, 0x6d762b, 0, 0x88923e, 0, 32 | 0xa0ab4f, 0, 0xb7c25f, 0, 0xccd86e, 0, 0xe0ec7c, 0, 33 | 0x482c00, 0, 0x694d14, 0, 0x866a26, 0, 0xa28638, 0, 34 | 0xbb9f47, 0, 0xd2b656, 0, 0xe8cc63, 0, 0xfce070, 0 35 | }; 36 | 37 | 38 | -------------------------------------------------------------------------------- /atari_py/atari_roms/adventure.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/adventure.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/air_raid.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/air_raid.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/alien.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/alien.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/amidar.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/amidar.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/assault.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/assault.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/asterix.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/asterix.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/asteroids.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/asteroids.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/atlantis.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/atlantis.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/bank_heist.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/bank_heist.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/battle_zone.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/battle_zone.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/beam_rider.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/beam_rider.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/berzerk.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/berzerk.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/bowling.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/bowling.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/boxing.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/boxing.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/breakout.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/breakout.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/carnival.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/carnival.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/centipede.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/centipede.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/chopper_command.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/chopper_command.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/crazy_climber.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/crazy_climber.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/defender.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/defender.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/demon_attack.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/demon_attack.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/double_dunk.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/double_dunk.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/elevator_action.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/elevator_action.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/enduro.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/enduro.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/fishing_derby.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/fishing_derby.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/freeway.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/freeway.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/frostbite.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/frostbite.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/gopher.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/gopher.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/gravitar.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/gravitar.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/hero.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/hero.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/ice_hockey.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/ice_hockey.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/jamesbond.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/jamesbond.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/journey_escape.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/journey_escape.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/kaboom.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/kaboom.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/kangaroo.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/kangaroo.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/krull.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/krull.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/kung_fu_master.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/kung_fu_master.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/montezuma_revenge.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/montezuma_revenge.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/ms_pacman.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/ms_pacman.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/name_this_game.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/name_this_game.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/phoenix.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/phoenix.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/pitfall.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/pitfall.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/pong.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/pong.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/pooyan.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/pooyan.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/private_eye.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/private_eye.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/qbert.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/qbert.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/riverraid.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/riverraid.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/road_runner.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/road_runner.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/robotank.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/robotank.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/seaquest.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/seaquest.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/skiing.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/skiing.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/solaris.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/solaris.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/space_invaders.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/space_invaders.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/star_gunner.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/star_gunner.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/tennis.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/tennis.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/time_pilot.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/time_pilot.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/tutankham.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/tutankham.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/up_n_down.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/up_n_down.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/venture.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/venture.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/video_pinball.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/video_pinball.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/wizard_of_wor.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/wizard_of_wor.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/yars_revenge.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/yars_revenge.bin -------------------------------------------------------------------------------- /atari_py/atari_roms/zaxxon.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/atari_roms/zaxxon.bin -------------------------------------------------------------------------------- /atari_py/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/atari_py/tests/__init__.py -------------------------------------------------------------------------------- /atari_py/tests/test_smoke.py: -------------------------------------------------------------------------------- 1 | import atari_py 2 | import numpy as np 3 | 4 | def test_smoke(): 5 | pong_path = atari_py.get_game_path('pong') 6 | ale = atari_py.ALEInterface() 7 | ale.loadROM(pong_path) 8 | action_set = ale.getMinimalActionSet() 9 | 10 | # Test stepping 11 | ale.act(action_set[0]) 12 | 13 | # Test screen capture 14 | (screen_width,screen_height) = ale.getScreenDims() 15 | arr = np.zeros((screen_height, screen_width, 4), dtype=np.uint8) 16 | ale.getScreenRGB(arr) 17 | 18 | if __name__ == '__main__': 19 | print('smoke test') 20 | test_smoke() 21 | print('done!') 22 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | if [ $(uname) == 'Linux' ] || [ $(uname) == 'Darwin' ]; then 5 | ./multibuild.sh 6 | else 7 | ./win_build.sh 8 | fi 9 | -------------------------------------------------------------------------------- /config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | function pre_build { 3 | set -ex 4 | build_zlib 5 | pip install cmake 6 | } 7 | 8 | function run_tests { 9 | pip install gym 10 | python -c "import gym; gym.make('Pong-v4')" 11 | pip install pytest 12 | pytest --pyargs atari_py.tests 13 | } 14 | 15 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | if [[ ! -z "$TRAVIS_TAG" ]]; then 3 | pip install twine 4 | twine upload --verbose wheelhouse/atari_py* 5 | 6 | if [[ ! -z "$DEPLOY_SDIST" ]]; then 7 | python setup.py sdist 8 | twine upload dist/* 9 | fi 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /deploy_to_pypi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | # TRAVIS_TAG=0.1.14 5 | 6 | if [[ -z "$TRAVIS_TAG" ]]; then 7 | echo "Not a tagged commit, quitting" 8 | exit 0 9 | fi 10 | 11 | pip install virtualenv --user 12 | python -m virtualenv --python=python3 .venv 13 | source .venv/bin/activate 14 | 15 | pip install awscli twine 16 | mkdir -p wheelhouse 17 | env 18 | # ugh something in awscli does not work on travis we'll download objects via curl 19 | # aws s3 cp --recursive s3://games-wheels/atari-py/${TRAVIS_TAG} wheelhouse/ 20 | SUFFIXES="-manylinux1_x86_64.whl -win_amd64.whl -macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl" 21 | # SUFFIXES="-manylinux1_x86_64.whl" 22 | PY_VERS="-cp36-cp36m -cp37-cp37m" 23 | URLPREFIX="https://s3-us-west-2.amazonaws.com/games-wheels/atari-py/${TRAVIS_TAG}/atari_py-${TRAVIS_TAG}" 24 | 25 | cd wheelhouse 26 | for s in $SUFFIXES; do 27 | for p in $PY_VERS; do 28 | curl -O ${URLPREFIX}${p}${s} 29 | done; 30 | done 31 | 32 | twine upload --verbose atari_py* 33 | -------------------------------------------------------------------------------- /doc/examples/Makefile: -------------------------------------------------------------------------------- 1 | # We do not automatically build the recording agent, which requires SDL. To build it, run 2 | # 3 | # > make recordingAgent 4 | all: sharedLibraryAgent rlglueAgent fifoAgent 5 | 6 | sharedLibraryAgent: 7 | make -f Makefile.sharedlibrary 8 | 9 | rlglueAgent: 10 | make -f Makefile.rlglue 11 | 12 | fifoAgent: 13 | make -f Makefile.fifo 14 | 15 | recordingAgent: 16 | make -f Makefile.recording 17 | 18 | clean: 19 | make -f Makefile.rlglue clean 20 | make -f Makefile.sharedlibrary clean 21 | make -f Makefile.fifo clean 22 | make -f Makefile.recording clean 23 | -------------------------------------------------------------------------------- /doc/examples/Makefile.fifo: -------------------------------------------------------------------------------- 1 | # Modified from the sharedLibraryInterfaceExample's makefile. 2 | 3 | USE_SDL := 0 4 | 5 | # This will likely need to be changed to suit your installation. 6 | ALE := ../.. 7 | 8 | FLAGS := -I$(ALE)/src -I$(ALE)/src/controllers -I$(ALE)/src/os_dependent -I$(ALE)/src/environment -I$(ALE)/src/external -L$(ALE) 9 | CXX := g++ 10 | FILE := fifoInterfaceExample 11 | LDFLAGS := -lale -lz 12 | 13 | UNAME_S := $(shell uname -s) 14 | ifeq ($(UNAME_S),Linux) 15 | FLAGS += -Wl,-rpath=$(ALE) 16 | endif 17 | ifeq ($(UNAME_S),Darwin) 18 | FLAGS += -framework Cocoa 19 | endif 20 | 21 | ifeq ($(strip $(USE_SDL)), 1) 22 | DEFINES += -D__USE_SDL -DSOUND_SUPPORT 23 | FLAGS += $(shell sdl-config --cflags) 24 | LDFLAGS += $(shell sdl-config --libs) 25 | endif 26 | 27 | all: fifoInterfaceExample 28 | 29 | fifoInterfaceExample: 30 | $(CXX) $(DEFINES) $(FLAGS) $(FILE).cpp $(LDFLAGS) -o $(FILE) 31 | 32 | clean: 33 | rm -rf fifoInterfaceExample *.o 34 | -------------------------------------------------------------------------------- /doc/examples/Makefile.recording: -------------------------------------------------------------------------------- 1 | # Modified from the sharedLibraryInterface's makefile. 2 | # Video recording requires SDL. If you do not have SDL installed, you will not be able to 3 | # compile this example. 4 | # 5 | # > make recordingAgent 6 | 7 | USE_SDL := 1 8 | 9 | # This will likely need to be changed to suit your installation. 10 | ALE := ../.. 11 | 12 | FLAGS := -I$(ALE)/src -I$(ALE)/src/controllers -I$(ALE)/src/os_dependent -I$(ALE)/src/environment -I$(ALE)/src/external -L$(ALE) 13 | CXX := g++ 14 | FILE := videoRecordingExample 15 | LDFLAGS := -lale -lz 16 | 17 | UNAME_S := $(shell uname -s) 18 | ifeq ($(UNAME_S),Linux) 19 | FLAGS += -Wl,-rpath=$(ALE) 20 | endif 21 | ifeq ($(UNAME_S),Darwin) 22 | FLAGS += -framework Cocoa 23 | endif 24 | 25 | ifeq ($(strip $(USE_SDL)), 1) 26 | DEFINES += -D__USE_SDL -DSOUND_SUPPORT 27 | FLAGS += $(shell sdl-config --cflags) 28 | LDFLAGS += $(shell sdl-config --libs) 29 | endif 30 | 31 | all: videoRecordingExample 32 | 33 | videoRecordingExample: 34 | $(CXX) $(DEFINES) $(FLAGS) $(FILE).cpp $(LDFLAGS) -o $(FILE) 35 | 36 | clean: 37 | rm -rf videoRecordingExample *.o 38 | -------------------------------------------------------------------------------- /doc/examples/Makefile.rlglue: -------------------------------------------------------------------------------- 1 | # Modified from the C/C++ RL-Glue codec RLGlueAgent's makefile. 2 | 3 | AGENTLDFLAGS := -lrlutils -lrlagent -lrlgluenetdev 4 | EXPLDFLAGS := -lrlutils -lrlexperiment -lrlgluenetdev 5 | CFLAGS := -Wall -pedantic 6 | 7 | all: RLGlueAgent RLGlueExperiment 8 | 9 | RLGlueAgent: RLGlueAgent.o 10 | $(CC) RLGlueAgent.o $(AGENTLDFLAGS) -o RLGlueAgent 11 | RLGlueExperiment: RLGlueExperiment.o 12 | $(CC) RLGlueExperiment.o $(EXPLDFLAGS) -o RLGlueExperiment 13 | 14 | %.o: %.c 15 | $(CC) $(CFLAGS) -c $< 16 | 17 | clean: 18 | rm -rf RLGlueAgent RLGlueExperiment *.o 19 | 20 | -------------------------------------------------------------------------------- /doc/examples/Makefile.sharedlibrary: -------------------------------------------------------------------------------- 1 | USE_SDL := 0 2 | 3 | # This will likely need to be changed to suit your installation. 4 | ALE := ../.. 5 | 6 | FLAGS := -I$(ALE)/src -I$(ALE)/src/controllers -I$(ALE)/src/os_dependent -I$(ALE)/src/environment -I$(ALE)/src/external -L$(ALE) 7 | CXX := g++ 8 | FILE := sharedLibraryInterfaceExample 9 | LDFLAGS := -lale -lz 10 | 11 | UNAME_S := $(shell uname -s) 12 | ifeq ($(UNAME_S),Linux) 13 | FLAGS += -Wl,-rpath=$(ALE) 14 | endif 15 | ifeq ($(UNAME_S),Darwin) 16 | FLAGS += -framework Cocoa 17 | endif 18 | 19 | ifeq ($(strip $(USE_SDL)), 1) 20 | DEFINES += -D__USE_SDL -DSOUND_SUPPORT 21 | FLAGS += $(shell sdl-config --cflags) 22 | LDFLAGS += $(shell sdl-config --libs) 23 | endif 24 | 25 | all: sharedLibraryInterfaceExample 26 | 27 | sharedLibraryInterfaceExample: 28 | $(CXX) $(DEFINES) $(FLAGS) $(FILE).cpp $(LDFLAGS) -o $(FILE) 29 | 30 | clean: 31 | rm -rf sharedLibraryInterfaceExample *.o 32 | -------------------------------------------------------------------------------- /doc/examples/python_example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # python_example.py 3 | # Author: Ben Goodrich 4 | # 5 | # This is a direct port to python of the shared library example from 6 | # ALE provided in doc/examples/sharedLibraryInterfaceExample.cpp 7 | from __future__ import print_function 8 | 9 | import sys 10 | from random import randrange 11 | from atari_py import ALEInterface 12 | 13 | if len(sys.argv) < 2: 14 | print('Usage:', sys.argv[0], 'rom_file') 15 | sys.exit() 16 | 17 | ale = ALEInterface() 18 | 19 | # Get & Set the desired settings 20 | ale.setInt('random_seed', 123) 21 | 22 | # Set USE_SDL to true to display the screen. ALE must be compilied 23 | # with SDL enabled for this to work. On OSX, pygame init is used to 24 | # proxy-call SDL_main. 25 | USE_SDL = False 26 | if USE_SDL: 27 | if sys.platform == 'darwin': 28 | import pygame 29 | pygame.init() 30 | ale.setBool('sound', False) # Sound doesn't work on OSX 31 | elif sys.platform.startswith('linux'): 32 | ale.setBool('sound', True) 33 | ale.setBool('display_screen', True) 34 | 35 | # Load the ROM file 36 | ale.loadROM(sys.argv[1]) 37 | 38 | # Get the list of legal actions 39 | legal_actions = ale.getLegalActionSet() 40 | 41 | # Play 10 episodes 42 | for episode in range(10): 43 | total_reward = 0 44 | while not ale.game_over(): 45 | a = legal_actions[randrange(len(legal_actions))] 46 | # Apply an action and get the resulting reward 47 | reward = ale.act(a); 48 | total_reward += reward 49 | print('Episode', episode, 'ended with score:', total_reward) 50 | ale.reset_game() 51 | -------------------------------------------------------------------------------- /doc/examples/sharedLibraryInterfaceExample.cpp: -------------------------------------------------------------------------------- 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 | * sharedLibraryInterfaceExample.cpp 13 | * 14 | * Sample code for running an agent with the shared library interface. 15 | **************************************************************************** */ 16 | 17 | #include 18 | #include 19 | 20 | #ifdef __USE_SDL 21 | #include 22 | #endif 23 | 24 | using namespace std; 25 | 26 | int main(int argc, char** argv) { 27 | if (argc < 2) { 28 | std::cerr << "Usage: " << argv[0] << " rom_file" << std::endl; 29 | return 1; 30 | } 31 | 32 | ALEInterface ale; 33 | 34 | // Get & Set the desired settings 35 | ale.setInt("random_seed", 123); 36 | //The default is already 0.25, this is just an example 37 | ale.setFloat("repeat_action_probability", 0.25); 38 | 39 | #ifdef __USE_SDL 40 | ale.setBool("display_screen", true); 41 | ale.setBool("sound", true); 42 | #endif 43 | 44 | // Load the ROM file. (Also resets the system for new settings to 45 | // take effect.) 46 | ale.loadROM(argv[1]); 47 | 48 | // Get the vector of legal actions 49 | ActionVect legal_actions = ale.getLegalActionSet(); 50 | 51 | // Play 10 episodes 52 | for (int episode=0; episode<10; episode++) { 53 | float totalReward = 0; 54 | while (!ale.game_over()) { 55 | Action a = legal_actions[rand() % legal_actions.size()]; 56 | // Apply the action and get the resulting reward 57 | float reward = ale.act(a); 58 | totalReward += reward; 59 | } 60 | cout << "Episode " << episode << " ended with score: " << totalReward << endl; 61 | ale.reset_game(); 62 | } 63 | 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /doc/java-agent/code/manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /doc/java-agent/code/nbproject/configs/Human.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/doc/java-agent/code/nbproject/configs/Human.properties -------------------------------------------------------------------------------- /doc/java-agent/code/nbproject/configs/RL.properties: -------------------------------------------------------------------------------- 1 | main.class=ale.agents.RLAgent 2 | -------------------------------------------------------------------------------- /doc/java-agent/code/nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=d952cf82 2 | build.xml.script.CRC32=a7335e3d 3 | build.xml.stylesheet.CRC32=28e38971@1.38.3.45 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=d952cf82 7 | nbproject/build-impl.xml.script.CRC32=38f45e83 8 | nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45 9 | nbproject/profiler-build-impl.xml.data.CRC32=d952cf82 10 | nbproject/profiler-build-impl.xml.script.CRC32=abda56ed 11 | nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1 12 | -------------------------------------------------------------------------------- /doc/java-agent/code/nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.run.all.processors=true 4 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 5 | application.title=ALEJavaAgent 6 | application.vendor=Marc G. Bellemare 7 | build.classes.dir=${build.dir}/classes 8 | build.classes.excludes=**/*.java,**/*.form 9 | # This directory is removed when the project is cleaned: 10 | build.dir=build 11 | build.generated.dir=${build.dir}/generated 12 | build.generated.sources.dir=${build.dir}/generated-sources 13 | # Only compile against the classpath explicitly listed here: 14 | build.sysclasspath=ignore 15 | build.test.classes.dir=${build.dir}/test/classes 16 | build.test.results.dir=${build.dir}/test/results 17 | # Uncomment to specify the preferred debugger connection transport: 18 | #debug.transport=dt_socket 19 | debug.classpath=\ 20 | ${run.classpath} 21 | debug.test.classpath=\ 22 | ${run.test.classpath} 23 | # This directory is removed when the project is cleaned: 24 | dist.dir=dist 25 | dist.jar=${dist.dir}/ALEJavaAgent.jar 26 | dist.javadoc.dir=${dist.dir}/javadoc 27 | endorsed.classpath= 28 | excludes= 29 | includes=** 30 | jar.compress=false 31 | javac.classpath= 32 | # Space-separated list of extra javac options 33 | javac.compilerargs= 34 | javac.deprecation=false 35 | javac.processorpath=\ 36 | ${javac.classpath} 37 | javac.source=1.5 38 | javac.target=1.5 39 | javac.test.classpath=\ 40 | ${javac.classpath}:\ 41 | ${build.classes.dir}:\ 42 | ${libs.junit.classpath}:\ 43 | ${libs.junit_4.classpath} 44 | javac.test.processorpath=\ 45 | ${javac.test.classpath} 46 | javadoc.additionalparam= 47 | javadoc.author=false 48 | javadoc.encoding=${source.encoding} 49 | javadoc.noindex=false 50 | javadoc.nonavbar=false 51 | javadoc.notree=false 52 | javadoc.private=false 53 | javadoc.splitindex=true 54 | javadoc.use=true 55 | javadoc.version=false 56 | javadoc.windowtitle= 57 | main.class=ale.agents.HumanAgent 58 | manifest.file=manifest.mf 59 | meta.inf.dir=${src.dir}/META-INF 60 | platform.active=default_platform 61 | run.classpath=\ 62 | ${javac.classpath}:\ 63 | ${build.classes.dir} 64 | # Space-separated list of JVM arguments used when running the project 65 | # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value 66 | # or test-sys-prop.name=value to set system properties for unit tests): 67 | run.jvmargs= 68 | run.test.classpath=\ 69 | ${javac.test.classpath}:\ 70 | ${build.test.classes.dir} 71 | source.encoding=UTF-8 72 | src.dir=src 73 | test.src.dir=test 74 | -------------------------------------------------------------------------------- /doc/java-agent/code/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | ALEJavaAgent 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /doc/java-agent/manual/Makefile: -------------------------------------------------------------------------------- 1 | FILE=java-agent 2 | 3 | all: $(FILE).pdf 4 | 5 | %.pdf: $(FILE).tex 6 | pdflatex $(FILE).tex 7 | pdflatex $(FILE).tex 8 | 9 | clean: 10 | rm -f *.{aux,log} 11 | -------------------------------------------------------------------------------- /doc/java-agent/manual/java-agent.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/doc/java-agent/manual/java-agent.pdf -------------------------------------------------------------------------------- /doc/manual/Makefile: -------------------------------------------------------------------------------- 1 | FILE=manual 2 | 3 | all: $(FILE).pdf 4 | 5 | %.pdf: $(FILE).tex 6 | pdflatex $(FILE).tex 7 | pdflatex $(FILE).tex 8 | pdflatex $(FILE).tex 9 | 10 | clean: 11 | rm -f *.{aux,log,toc,out} 12 | -------------------------------------------------------------------------------- /doc/manual/figures/ale.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/doc/manual/figures/ale.gif -------------------------------------------------------------------------------- /doc/manual/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kojoley/atari-py/86a1e05c0a95e9e6233c3a413521fdb34ca8a089/doc/manual/manual.pdf -------------------------------------------------------------------------------- /doc/scripts/videoRecordingExampleJoinMacOSX.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A script to generate an ALE video with FFMpeg, Mac OS X. 3 | 4 | # -r ## specifies the frame rate 5 | # -i record/%06d.png indicates we should use sequentially numbered frames in directory 'record' 6 | # -i sound.wav indicates the location of the sound file 7 | # -f mov specifies a MOV format 8 | # -c:a mp3 specifies the sound codec 9 | # -c:v libx264 specifies the video codec 10 | # -pix_fmt yuv420p is needed on Mac OS X for playback with QuickTime Player 11 | # 12 | ffmpeg -r 60 -i record/%06d.png -i record/sound.wav -f mov -c:a mp3 -c:v libx264 -pix_fmt yuv420p agent.mov 13 | -------------------------------------------------------------------------------- /doc/scripts/videoRecordingExampleJoinUnix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A script to generate an ALE video with FFMpeg, *nix systems. 3 | 4 | # -r ## specifies the frame rate 5 | # -i record/%06d.png indicates we should use sequentially numbered frames in directory 'record' 6 | # -i sound.wav indicates the location of the sound file 7 | # -f mov specifies a MOV format 8 | # -c:a mp3 specifies the sound codec 9 | # -c:v libx264 specifies the video codec 10 | # 11 | 12 | 13 | # Attempt to use ffmpeg. If this fails, use avconv (fix for Ubuntu 14.04). 14 | { 15 | ffmpeg -r 60 -i record/%06d.png -i record/sound.wav -f mov -c:a mp3 -c:v libx264 agent.mov 16 | } || { 17 | avconv -r 60 -i record/%06d.png -i record/sound.wav -f mov -c:a mp3 -c:v libx264 agent.mov 18 | } 19 | 20 | -------------------------------------------------------------------------------- /dockerfile.3.6: -------------------------------------------------------------------------------- 1 | FROM python:3.6 2 | 3 | RUN apt-get -y update && \ 4 | apt-get -y install cmake && \ 5 | pip install pytest 6 | 7 | COPY . /root/code 8 | WORKDIR /root/code 9 | 10 | RUN pip install . 11 | -------------------------------------------------------------------------------- /get_platform.py: -------------------------------------------------------------------------------- 1 | import distutils.util 2 | platform = distutils.util.get_platform() 3 | 4 | # technically, our platform is not actually multilinux... so this may fail in some distros 5 | # however, tested in python:3.6 docker image (by construction) 6 | # and in ubuntu:16.04 7 | platform = platform.replace('linux', 'manylinux1') 8 | 9 | print(platform) 10 | -------------------------------------------------------------------------------- /install_osx.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | CONDA_VER=3.7.0 3 | curl https://repo.continuum.io/miniconda/Miniconda3-${CONDA_VER}-MacOSX-x86_64.sh -o ~/miniconda.sh 4 | bash ~/miniconda.sh -b -p $HOME/miniconda 5 | export PATH="$HOME/miniconda/bin:$PATH" 6 | 7 | conda install pip 8 | python --version 9 | pip --version 10 | -------------------------------------------------------------------------------- /installzlib.bat: -------------------------------------------------------------------------------- 1 | curl -O https://zlib.net/zlib1211.zip 2 | unzip zlib1211.zip 3 | cp -r zlib-1.2.11 atari_py/ale_interface/src/zlib 4 | cd atari_py/ale_interface/src/zlib 5 | cmake -DCMAKE_GENERATOR_PLATFORM=x64 . 6 | cmake --build . 7 | 8 | cd ../.. 9 | mkdir -p build 10 | cp src/zlib/Debug/zlibstaticd.lib build/z.lib 11 | 12 | 13 | -------------------------------------------------------------------------------- /multibuild.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | export REPO_DIR=. 3 | export BUILD_COMMIT=$TRAVIS_COMMIT 4 | export PLAT=x86_64 5 | export MB_PYTHON_VERSION=$PY_VER 6 | 7 | git clone https://github.com/matthew-brett/multibuild && cd multibuild && git checkout 254ad28 && cd .. 8 | source multibuild/common_utils.sh 9 | source multibuild/travis_steps.sh 10 | before_install 11 | build_wheel $REPO_DIR $PLAT 12 | install_run $PLAT 13 | 14 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | # Tox (http://tox.testrun.org/) is a tool for running tests 2 | # in multiple virtualenvs. This configuration file will run the 3 | # test suite on all supported python versions. To use it, "pip install tox" 4 | # and then run "tox" from this directory. 5 | 6 | [tox] 7 | envlist = py27, py35 8 | 9 | [testenv:py35] 10 | whitelist_externals=echo 11 | install_command=echo {packages} 12 | commands = 13 | pip install numpy nose2 14 | pip install -e . 15 | nose2 16 | python setup.py clean --all 17 | 18 | [testenv:py27] 19 | whitelist_externals=echo 20 | install_command=echo {packages} 21 | commands = 22 | pip install numpy nose2 23 | pip install -e . 24 | nose2 25 | python setup.py clean --all 26 | -------------------------------------------------------------------------------- /win_build.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | choco install --yes python3 --version $PY_VER 3 | export PYROOT=/c/Python${PY_VER//./} 4 | export PATH=$PYROOT:$PYROOT/Scripts:$PATH 5 | pip install cmake pytest 6 | ./installzlib.bat 7 | mkdir -p atari_py/ale_interface/build 8 | 9 | cd atari_py/ale_interface/build 10 | cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. 11 | cmake --build . 12 | cp Debug/ale_c.dll ../ 13 | cd ../../../ 14 | 15 | pip install wheel && pip wheel . -w wheelhouse --no-deps -vvv 16 | ls wheelhouse/atari_py* 17 | rm -rf atari_py* 18 | pip install $(ls wheelhouse/atari_py*) 19 | pytest --pyargs atari_py.tests 20 | 21 | --------------------------------------------------------------------------------