{"id":13422691,"url":"https://github.com/ntasfi/PyGame-Learning-Environment","last_synced_at":"2025-03-15T12:30:49.489Z","repository":{"id":4216567,"uuid":"52380933","full_name":"ntasfi/PyGame-Learning-Environment","owner":"ntasfi","description":"PyGame Learning Environment (PLE) -- Reinforcement Learning Environment in Python.","archived":false,"fork":false,"pushed_at":"2022-01-19T22:19:02.000Z","size":8250,"stargazers_count":1016,"open_issues_count":22,"forks_count":231,"subscribers_count":39,"default_branch":"master","last_synced_at":"2024-10-27T23:59:36.772Z","etag":null,"topics":["agent","ai","artificial-intelligence","deep-reinforcement-learning","game","machine-learning","pygame","python","reinforcement-learning","research"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ntasfi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-23T18:13:39.000Z","updated_at":"2024-10-26T09:41:51.000Z","dependencies_parsed_at":"2022-08-08T02:00:03.059Z","dependency_job_id":null,"html_url":"https://github.com/ntasfi/PyGame-Learning-Environment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntasfi%2FPyGame-Learning-Environment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntasfi%2FPyGame-Learning-Environment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntasfi%2FPyGame-Learning-Environment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntasfi%2FPyGame-Learning-Environment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntasfi","download_url":"https://codeload.github.com/ntasfi/PyGame-Learning-Environment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243731007,"owners_count":20338754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","ai","artificial-intelligence","deep-reinforcement-learning","game","machine-learning","pygame","python","reinforcement-learning","research"],"created_at":"2024-07-30T23:00:50.518Z","updated_at":"2025-03-15T12:30:48.054Z","avatar_url":"https://github.com/ntasfi.png","language":"Python","readme":"# PyGame-Learning-Environment\n\n![Games](ple_games.jpg?raw=True \"Games!\")\n\n**PyGame Learning Environment (PLE)** is a learning environment, mimicking the [Arcade Learning Environment](https://github.com/mgbellemare/Arcade-Learning-Environment) interface, allowing a quick start to Reinforcement Learning in Python. The goal of PLE is allow practitioners to focus design of models and experiments instead of environment design.\n\nPLE hopes to eventually build an expansive library of games.\n\n**Accepting PRs for games.**\n\n## Documentation\n\nDocs for the project can be [found here](http://pygame-learning-environment.readthedocs.org/). They are currently WIP.\n\n## Games\n\nAvailable games can be found in the [docs](http://pygame-learning-environment.readthedocs.org/en/latest/user/games.html).\n\n## Getting started\n\nA `PLE` instance requires a game exposing a set of control methods. To see the required methods look at `ple/games/base.py`. \n\nHere's an example of importing Pong from the games library within PLE:\n\n```python\nfrom ple.games.pong import Pong\n\ngame = Pong()\n```\n\nNext we configure and initialize PLE:\n\n```python\nfrom ple import PLE\n\np = PLE(game, fps=30, display_screen=True, force_fps=False)\np.init()\n```\n\nThe options above instruct PLE to display the game screen, with `display_screen`, while allowing PyGame to select the appropriate delay timing between frames to ensure 30fps with `force_fps`.\n\nYou are free to use any agent with the PLE. Below we create a fictional agent and grab the valid actions:\n\n```python\nmyAgent = MyAgent(p.getActionSet())\n```\n\nWe can now have our agent, with the help of PLE, interact with the game over a certain number of frames:\n\n```python\n\nnb_frames = 1000\nreward = 0.0\n\nfor f in range(nb_frames):\n\tif p.game_over(): #check if the game is over\n\t\tp.reset_game()\n\n\tobs = p.getScreenRGB()\n\taction = myAgent.pickAction(reward, obs)\n\treward = p.act(action)\n\n```\n\nJust like that we have our agent interacting with our game environment.\n\n## Installation\n\nPLE requires the following dependencies:\n* numpy\n* pygame\n* pillow\n\nClone the repo and install with pip.\n\n```bash\ngit clone https://github.com/ntasfi/PyGame-Learning-Environment.git\ncd PyGame-Learning-Environment/\npip install -e .\n``` \n\n## Headless Usage\n\nSet the following in your code before usage:\n```python\nos.putenv('SDL_VIDEODRIVER', 'fbcon')\nos.environ[\"SDL_VIDEODRIVER\"] = \"dummy\"\n```\n\nThanks to [@wooridle](https://github.com/ntasfi/PyGame-Learning-Environment/issues/26#issuecomment-289517054).\n\n## Updating\n\n`cd` into the `PyGame-Learning-Environment` directory and run the following:\n\n```bash\ngit pull\n```\n\n## Todos\n * Documentation is currently in progress.\n * Tests\n * Parallel Learning (One agent, many game copies)\n * Add games\n * Generalize the library (eg. add Pyglet support)\n\n\n## Citing PLE\n\nIf PLE has helped your research please cite it in your publications. Example BibTeX entry:\n\n```\n@misc{tasfi2016PLE,\n  author = {Tasfi, Norman},\n  title = {PyGame Learning Environment},\n  year = {2016},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/ntasfi/PyGame-Learning-Environment}}\n}\n```\n","funding_links":[],"categories":["Cool Projects","Environments","Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntasfi%2FPyGame-Learning-Environment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntasfi%2FPyGame-Learning-Environment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntasfi%2FPyGame-Learning-Environment/lists"}