https://github.com/nikouu/cpu-plays-pokemon
A fun little proof of concept for mGBA-http where it takes in your CPU usage as what button to press.
https://github.com/nikouu/cpu-plays-pokemon
csharp dotnet mgba pokemon twitchplays
Last synced: about 2 months ago
JSON representation
A fun little proof of concept for mGBA-http where it takes in your CPU usage as what button to press.
- Host: GitHub
- URL: https://github.com/nikouu/cpu-plays-pokemon
- Owner: nikouu
- License: mit
- Created: 2023-12-23T23:40:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-24T06:25:45.000Z (over 2 years ago)
- Last Synced: 2025-04-06T08:08:51.594Z (over 1 year ago)
- Topics: csharp, dotnet, mgba, pokemon, twitchplays
- Language: C#
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CPU Plays Pokemon
A fun little proof of concept for [mGBA-http](https://github.com/nikouu/mGBA-http) where it takes in your CPU usage as what button to press.
https://github.com/nikouu/CPU-Plays-Pokemon/assets/983351/3ca74ae2-1c7c-41e4-a104-7cd4c9fa328c
_Video is sped up._
## How it works
Every second:
1. The CPU usage is checked
2. Some maths then the usage is mapped to a key
3. The key is sent to mGBA-http and onwards to mGBA
## How to run
1. Have mGBA up and running
1. Get and setup [mGBA-http](https://github.com/nikouu/mGBA-http)
1. Get this project
2. Run this project (either in Visual Studio/your IDE of choice, or with `dotnet run`)
## Interesting bits
- Uses the new [`PeriodicTimer`](https://learn.microsoft.com/en-us/dotnet/api/system.threading.periodictimer?view=net-8.0) object
- The maths for the value to modulo is a mixture of both the whole and fraction because:
- If just the whole value is used, then there may not be enough variation in CPU usage to modulo for all the keys
- If it's just the fraction, the trailing zero is cut off, meaning we never get the A key
- [`PerformanceCounter`](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.performancecounter?view=dotnet-plat-ext-8.0) is now a NuGet package
## Timelapse
The following is a whole hour of "playing" and "progress":
https://github.com/nikouu/CPU-Plays-Pokemon/assets/983351/8ae1b4fe-04d7-4f05-8ae6-890ae5ef0213