This document provides detailed instructions for setting up and running the Grok Plays Pokémon project.
Before you begin, ensure you have the following installed:
- Python 3.8+: The project is built on Python
- Git: For version control and cloning the repository
- Pokémon Red ROM: A legal copy of the Pokémon Red Game Boy ROM (not included)
PyBoy (the Game Boy emulator) requires some system dependencies:
sudo apt-get update
sudo apt-get install python3-dev python3-pip python3-numpy libsdl2-dev libsdl2-2.0-0brew install sdl2 pythonInstall the SDL2 development libraries from libsdl.org or use:
pip install pysdl2-dll-
Clone the repository:
git clone https://github.com/NYTEMODEONLY/grok-plays-pokemon.git cd grok-plays-pokemon -
Create a virtual environment (recommended):
python -m venv venv # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up the ROM directory:
mkdir -p roms
-
Copy your legally obtained Pokémon Red ROM to the
romsdirectory and rename it topokemon_red.gb:cp /path/to/your/pokemon_red.rom roms/pokemon_red.gb
The project uses default settings that work out of the box, but you can customize some aspects:
-
ROM filename: If you want to use a differently named ROM file, edit the
ROM_FILEvariable inapp.py:ROM_FILE = 'your_rom_name.gb'
-
Server host/port: To change the server host or port, edit the
socketio.runline inapp.py:socketio.run(app, host='0.0.0.0', port=8080, debug=True)
-
Screenshot interval: To adjust how frequently screenshots are captured, modify the
SCREENSHOT_INTERVALvariable inapp.py:SCREENSHOT_INTERVAL = 0.5 # seconds between screenshots
-
Start the Flask server:
python app.py
-
Open your web browser and navigate to:
http://localhost:5000 -
Click the "Start Game" button on the web interface to initialize the emulator and begin gameplay.
The project includes a sample controller script (grok_controller.py) that demonstrates how Grok AI would control the game:
- With the server running, open a new terminal window
- Activate the virtual environment if you created one
- Run the controller script:
python grok_controller.py
This script will:
- Connect to the running server
- Start the game if it's not already running
- Execute a series of actions with commentary
- Simulate playing through the beginning of the game
ERROR - ROM file not found: roms/pokemon_red.gb
Solution: Ensure you have placed your Pokémon Red ROM in the roms directory with the correct filename.
ERROR - Failed to initialize emulator: [SDL Error Message]
Solution: This usually indicates an issue with SDL2. Make sure you have installed the SDL2 dependencies for your system.
ERROR - Address already in use
Solution: Another application is using port 5000. Either stop that application or change the port in app.py.
ModuleNotFoundError: No module named 'pyboy'
Solution: Ensure you've installed all dependencies:
pip install -r requirements.txtThe application logs information to the console. Look for errors or warnings that might explain any issues you're experiencing.
To access the application from other devices on your local network:
-
Make sure the server is running with host
0.0.0.0:socketio.run(app, host='0.0.0.0', port=5000, debug=True)
-
Find your computer's local IP address:
# On Windows: ipconfig # On macOS/Linux: ifconfig
-
On other devices, navigate to:
http://YOUR_LOCAL_IP:5000
To deploy the application on the internet, consider using:
- Heroku: Good for quick deployments
- AWS/GCP/Azure: Better for production deployments
- DigitalOcean: A simple VPS option
Note that you'll need to adapt the application for production use:
-
Turn off debug mode:
socketio.run(app, host='0.0.0.0', port=5000, debug=False)
-
Use a production WSGI server (e.g., Gunicorn with eventlet):
gunicorn --worker-class eventlet -w 1 app:app
-
Consider using environment variables for configuration:
import os ROM_FILE = os.environ.get('POKEMON_ROM_FILE', 'pokemon_red.gb')
- Reduce screenshot quality: If performance is an issue, you can reduce the quality of screenshots
- Adjust tick rate: Modify how many frames the emulator advances per tick
- Optimize WebSocket traffic: Reduce the frequency of updates on slow connections
After setting up the basic application, you might want to:
- Implement real memory reading: Replace the placeholder game state with actual memory reading
- Enhance the user interface: Add more features to the web interface
- Improve the AI logic: Develop more sophisticated gameplay strategies
- Add community features: Allow viewers to interact with the gameplay