Skip to content

PWhiddy/PokemonRedExperiments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jan 16, 2025
44cfc4e · Jan 16, 2025
Oct 23, 2023
Nov 19, 2024
Sep 8, 2023
Jan 16, 2025
Oct 18, 2023
Dec 15, 2023
Oct 11, 2023
Nov 8, 2024
Jun 14, 2022
Dec 15, 2021
Dec 18, 2021
Jan 12, 2022
Oct 29, 2021
Sep 4, 2024

Repository files navigation

Train RL agents to play Pokemon Red

New 10-19-24! Updated & Simplified V2 Training Script - See V2 below

Stream your training session to a shared global game map using the Broadcast Wrapper

See how in Training Broadcast section

Watch the Video on Youtube!

Join the discord server

Join the Discord server!

Running the Pretrained Model Interactively 🎮

🐍 Python 3.10+ is recommended. Other versions may work but have not been tested.
You also need to install ffmpeg and have it available in the command line.

Windows Setup

Refer to this Windows Setup Guide

For AMD GPUs

Follow this guide to install pytorch with ROCm support

Linux / MacOS

V2 is now reccomended over the original version. You may follow all steps below but replace baselines with v2.

  1. Copy your legally obtained Pokemon Red ROM into the base directory. You can find this using google, it should be 1MB. Rename it to PokemonRed.gb if it is not already. The sha1 sum should be ea9bcae617fdf159b045185467ae58b2e4a48b9a, which you can verify by running shasum PokemonRed.gb.
  2. Move into the baselines/ directory:
    cd baselines
  3. Install dependencies:
    pip install -r requirements.txt
    It may be necessary in some cases to separately install the SDL libraries.
  4. Run:
    python run_pretrained_interactive.py

Interact with the emulator using the arrow keys and the a and s keys (A and B buttons).
You can pause the AI's input during the game by editing agent_enabled.txt

Note: the Pokemon.gb file MUST be in the main directory and your current directory MUST be the baselines/ directory in order for this to work.

Training the Model 🏋️

V2

  • Trains faster and with less memory
  • Reaches Cerulean
  • Streams to map by default
  • Other improvements

Replaces the frame KNN with a coordinate based exploration reward, as well as some other tweaks.

  1. Previous steps but in the v2 directory instead of baselines
  2. Run: python baseline_fast_v2.py

Tracking Training Progress 📈

Training Broadcast

Stream your training session to a shared global game map using the Broadcast Wrapper on your environment like this:

env = StreamWrapper(
            env, 
            stream_metadata = { # All of this is part is optional
                "user": "super-cool-user", # choose your own username
                "env_id": id, # environment identifier
                "color": "#0033ff", # choose your color :)
                "extra": "", # any extra text you put here will be displayed
            }
        )

Hack on the broadcast viewing client or set up your own local stream with this repo:

https://github.com/pwhiddy/pokerl-map-viz/

Local Metrics

The current state of each game is rendered to images in the session directory.
You can track the progress in tensorboard by moving into the session directory and running:
tensorboard --logdir .
You can then navigate to localhost:6006 in your browser to view metrics.
To enable wandb integration, change use_wandb_logging in the training script to True.

Static Visualization 🐜

Map visualization code can be found in visualization/ directory.

Supporting Libraries

Check out these awesome projects!

About

Playing Pokemon Red with Reinforcement Learning

Resources

License

GitHub · Build and ship software on a single, collaborative platform · GitHub
Skip to content
GitHub Copilot is now available for free. Learn more

Build and ship software on a single, collaborative platform

Join the world’s most widely adopted AI-powered developer platform.

Try GitHub Copilot

GitHub features

A demonstration animation of a code editor using GitHub Copilot Chat, where the user requests GitHub Copilot to refactor duplicated logic and extract it into a reusable function for a given code snippet.

Build code quickly and more securely with GitHub Copilot embedded throughout your workflows.

GitHub is used by

ShopifyEYFigmaDuolingoNew York TimesMercado LibreAmerican AirlinesFordMercedes BenzSociété GénéraleVodafonePhilipsSAPInfosysSpotify

Accelerate performance

With GitHub Copilot embedded throughout the platform, you can simplify your toolchain, automate tasks, and improve the developer experience.

A Copilot chat window with extensions enabled. The user inputs the @ symbol to reveal a list of five Copilot Extensions. @Sentry is selected from the list, which shifts the window to a chat directly with that extension. There are three sample prompts at the bottom of the chat window, allowing the user to Get incident information, Edit status on incident, or List the latest issues. The last one is activated to send the prompt: @Sentry List the latest issues. The extension then lists several new issues and their metadata.

Work 55% faster.Jump to footnote 1 Increase productivity with AI-powered coding assistance, including code completion, chat, and more.

Duolingo boosts developer speed by 25% with GitHub Copilot

Read customer story

2024 Gartner® Magic Quadrant™ for AI Code Assistants

Read report

Optimize your process with simple and secured CI/CD.

A list of workflows displays a heading ‘45,167 workflow runs’ at the top. Below are five rows of completed workflows accompanied by their completion time and their duration formatted in minutes and seconds.Discover GitHub Actions

Built-in application security
where found means fixed

Use AI to find and fix vulnerabilities—freeing your teams to ship more secure software faster.

Apply fixes in seconds. Spend less time fixing vulnerabilities and more time building features with Copilot Autofix.

Copilot Autofix identifies vulnerable code and provides an explanation, together with a secure code suggestion to remediate the vulnerability.

Solve security debt. Leverage AI-assisted security campaigns to reduce application vulnerabilities and zero-day attacks.

Discover security campaigns
A security campaign screen displays the campaign’s progress bar with 97% completed of 701 alerts. A total of 23 alerts are left with 13 in progress, and the campaign started 20 days ago. The status below shows that there are 7 days left in the campaign with a due date of November 15, 2024.

Dependencies you can depend on. Update vulnerable dependencies with supported fixes for breaking changes.

Learn about Dependabot
List of dependencies defined in a requirements .txt file.

Your secrets, your business: protected. Detect, prevent, and remediate leaked secrets across your organization.

Read about secret scanning
GitHub push protection confirms and displays an active secret, and blocks the push.

Work together, achieve more

Collaborate with your teams, use management tools that sync with your projects, and code from anywhere—all on a single, integrated platform.

A project management dashboard showing tasks for the ‘OctoArcade Invaders’ project, with tasks grouped under project phase categories like ‘Prototype,’ ‘Beta,’ and ‘Launch’ in a table layout. One of the columns displays sub-issue progress bars with percentages for each issue.

Your workflows, your way. Plan effectively with an adaptable spreadsheet that syncs with your work.

It helps us onboard new software engineers and get them productive right away. We have all our source code, issues, and pull requests in one place... GitHub is a complete platform that frees us from menial tasks and enables us to do our best work.
Fabian FaulhaberApplication manager at Mercedes-Benz

Create issues and manage projects with tools that adapt to your code.

Display of task tracking within an issue, showing the status of related sub-issues and their connection to the main issue.Explore GitHub Issues

Millions of developers and businesses call GitHub home

Whether you’re scaling your development process or just learning how to code, GitHub is where you belong. Join the world’s most widely adopted AI-powered developer platform to build the technologies that redefine what’s possible.

Footnotes

  1. Survey: The AI wave continues to grow on software development teams, 2024.

  2. This 7X times factor is based on data from the industry’s longest running analysis of fix rates Veracode State of Software Security 2023, which cites the average time to fix 50% of flaws as 198 days vs. GitHub’s fix rates of 72% of flaws with in 28 days which is at a minimum of 7X faster when compared.

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published