# RethMatch
RethMatch is onchain tournament for bots, inspired by Pac-Man and Agar.io, built with [MUD](mud.dev) and hosted on the [Reth](https://github.com/paradigmxyz/reth)-powered [Odyssey](https://ithaca.xyz/updates/odyssey) testnet.
## Table of Contents
- [Rules](#rules)
- [Mechanics](#search)
- [Building / Authenticating a Bot](#Building--Authenticating-a-Bot)
## Rules
1. The RethMatch competition will run from **May 30th 12:00 PM PT to June 1st 9 PM PT**.
3. **Don't exploit bugs in the RethMatch contracts**! Save your auditing skills for the [Paradigm CTF](https://ctf.paradigm.xyz).
* If you exploit live bugs in the RethMatch contracts, we reserve the right to revert your score and/or disqualify you from winning.
* Instead, **report any findings to us** via direct message on [X](https://x.com/transmissions11). Depending on severity we will **award points** to your top scoring life at competition end as follows:
* High severity: +25% points
* Medium severity: +10% points
* Low severity: +2.5% points
## Mechanics
**Code**: [paradigmxyz/rethmatch](https://github.com/paradigmxyz/rethmatch)
**Contract:** See contract link in the bottom left 'quick links' section on the [game site](rethmatch.paradigm.xyz).
**Note:** We'll be making balance adjustments to keep the game fun and interesting during the competition. Follow us on [X](https://x.com/transmissions11) to stay up-to-date.
* A RethMatch map is made of many equal width *lines*. Players can spawn on any line.
* The *diameter* of a player is a function of their *mass* (sqrt).
* Players have a horizontal *velocity* which they can set the direction of at any time.
* Players can switch lines by *jumping* up or down. You cannot be on multiple lines at once.
* When players hit the end of a line, they bounce off it.
* Players gain mass by eating *food*, *power pellets*, or other players.
* Players can die by being eaten, or by colliding with a wall.
* Food
* Food entities exist only to be eaten.
* Even if you are smaller than them, you can still eat them.
* They spawn randomly as a result of collisions.
* Power pellets
* Power pellets spawn randomly like food at much lower odds.
* Eating one gives you the ability to bounce off walls and consume players of any size for a limited amount of time.
* If you collide with another player who is powered up as a result of recently consuming a power pellet, you will bounce off each other.
* Walls:
* There are two walls per line. Different lines have different wall speeds.
* If you overlap with a wall, you die instantly, unless you are powered up from recently consuming a power pellet.
* Eating other players
* You must be bigger than them (have larger mass) or be *powered up* as a result of recently eating a *power pellet*.
* Either overlap with them horizontally, or jump on them from the line above or below.
* Eating other players gives you `min(mass_they_consumed, their_current_mass)` mass.
* This is to discourage players from eating newly spawned players.
* Jumping
* You can only jump at most one line per block.
* Jumping decreases your mass by a constant percentage each jump. Do it sparingly.
* Jumping down from the *bottommost line* will send you to the *topmost line*, and jumping up from the topmost will send you to the bottommost.
* Leaderboard/Scoring:
* When you die, your life is given a score based on the total mass consumed during that life.
* Your *overall score* is the sum of your top 10 lifetime scores.
* Your ranking on the leaderboard will be determined by your overall score and any additional points earned by submitting bug reports.
## Building / Authenticating a Bot
To increase the difficulty of sybil attacks and link players with their X (Twitter) usernames, players must first sign in with X and then link their X (Twitter) accounts to an Odyssey address before playing.
Detailed steps are as follows:
• **Sign in with X (Twitter)**
- Visit the [game website](https://rethmatch.paradigm.xyz) and click "LOGIN WITH X TO PLAY"
- Complete the X authentication process.
• **Choose an wallet address to link**
- Your bot needs an Ethereum wallet with funds on the [Odyssey testnet](https://ithaca.xyz/updates/odyssey)
- Bridge funds [here](https://hub.conduit.xyz/odyssey)
- The wallet address will be permanently linked to your X account
- ⚠️ **Warning**: You cannot change this address later, so choose carefully!
• **Generate your access signature**
- After logging in, click "GENERATE ACCESS SIGNATURE"
- Enter your bot's address when prompted (format: `0x...`)
- Our backend will generate a unique access signature
- *Copy this signature* - you'll need to submit it on-chain to get started.
• **Link your X account to your address on-chain**
- Call the [`access()` method](https://github.com/paradigmxyz/rethmatch/blob/main/packages/contracts/src/systems/AccessSystem.sol) with the **access signature from earlier** and your *lowercased* X username.
- e.g. with [cast](http://foundry.sh): `cast send <WORLD_CONTRACT> "access(bytes,string)" <ACCESS_SIGNATURE> <LOWERCASED_TWITTER_USERNAME> --rpc-url https://odyssey.ithaca.xyz`
- Once successful, your bot is authorized to play the game.
- 🚨 **Important**: Once you successfully call `access()`, you can no longer link your X username to another address!
• **Step 5: Start Playing**
- Your authenticated address can now call `spawn()` and other methods to control a player.
- Dive into the code to get started: [paradigmxyz/rethmatch](https://github.com/paradigmxyz/rethmatch)
- You may find it helpful to look through the [MUD documentation](https://mud.dev/introduction) to understand the game implementation.