ESP32 Rock, Paper, Scissors
a miniature AI model for microcontrollers
2 min readupdated
This is a tiny fixed AI model (only 499 parameters and 2.4 KB) that predicts a human's next move in Rock, Paper, Scissors based on the results of the three previous rounds. The model is trained on 102,000 real game rounds and runs on an ESP32-S3 microcontroller (part of the M5Stack CoreS3 device) alongside a team of algorithms that adapt to the player on the fly. It gives the system an edge at the start of the game so the first rounds aren't just random guesses. The project will be useful for embedded systems developers, microcontroller enthusiasts, and anyone learning practical AI applications on hardware.
Key features
- Architecture: multilayer perceptron with a 27 → 16 (tanh) → 3 layout.
- Minimal size: model weights are only 2.4 KB (499 parameters, float32).
- Pretrained base: trained on behavioral data from 345 real players (over 102,000 rounds).
- Hardware integration: built to run on the ESP32-S3 microcontroller and run on a computer.
What you can do
- Run on device: flash the ESP32-S3 microcontroller (M5Stack CoreS3) to play Rock, Paper, Scissors in real time.
- Run on PC: test the model logic on a computer using the source code from the repository.
- Study for learning: use the project as a demonstration of how a compact AI model can analyze human habits.
- Embed in a project: use the header file with model weights in your own C/C++ projects for ESP32.
Example
An example of using the model weight structure in code (safetensors format): the hidden layer uses a tanh activation function, and the output uses softmax to select a move.
Read more
DetailsBenchmarks: prediction accuracy on early rounds increases from 37% to 44-47% thanks to pre-training.
Hardware requirements: ESP32-S3 microcontroller (such as M5Stack CoreS3) or a regular PC.
Limitations: the model knows general human behavioral patterns from the dataset rather than the specific player in front of the screen — other algorithms fine-tune it further.
License: MIT.










Comments