meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3.29k stars 798 forks source link

Nara: Virtual Pet Game for Meshtastic #4434

Open eljojo opened 1 month ago

eljojo commented 1 month ago

What is it?

Nara (Not A Robotic Animal) is a virtual pet game, built as a module for Meshtastic. You battle other nodes and win points.

The idea is to have fun while also encouraging people to join and grow the Meshtastic network.

Watch video here: https://youtu.be/MWfdFIDvkeY

https://github.com/user-attachments/assets/6cd1a610-c8c0-4f2c-8517-1abb95137a72

How to play?

All you have to do is enable the module and go outside!

### How does the algorithm work?

The algorithm ensures fair play by using cryptographic hashes to determine winners, regardless of hardware differences. First, both nodes exchange randomly generated numbers and start the battle. | Message | From | To | |------------------|---------|---------| | Battle Invite (123) | Aaron | Britney | | Battle Accept (456) | Britney | Aaron | Once numbers have been exchanged, they are combined to do a hash computation. The formula is: ``` SHA256("%d/%d/%0x/%d", aaronMessage, britneyMessage, localNodeNum, counter) ``` Nodes will compute hashes, increasing the counter, until one of the following happens: - A counter is found, for which the hash ends in **four** zeros - Input: `"123/456/4359109c/54633"` - Hash: `7724bec8bb34ae39a85af34402f4b4a08db7a8edd6d0230f166b014cc1950000` - The counter reaches 100,000 iterations -- Nodes give up. - The other node finds a counter better than our current best iteration (i.e., even if we find a matching hash, our counter will lose). Once Naras find a matching counter, or give up searching, they'll message the other one letting them know of their counter. The counter is verified upon reception by the other node. | Message | From | To | Meaning | |--------------------|---------|---------|----------------------------------| | Battle Turn (432) | Britney | Aaron | (waiting for Aaron) | | Battle Turn (1234) | Aaron | Britney | Britney wins: 432 < 1234 |

What are the next steps?

I'm sharing this project to see if there's potential in merging some form of this into the Meshtastic codebase.

Project status?

Currently, there's a working proof of concept. I'm at the point of getting community feedback before continuing developing this idea. The game could go in multiple different directions. I don't have experience with C++, so my code may need re-writing.

You can find the code here: https://github.com/meshtastic/firmware/compare/master...eljojo:meshtastic-firmware:nara-module

Working features:

FAQ:

Other Ideas:

Requirements:

garthvh commented 1 month ago

Very cool!

jp-bennett commented 1 month ago

This sounds so good. Looking forward to giving it a closer look, and thinking about how to integrate!