# Moonsheep Cannon

**Moonsheep Cannon** is a collaborative game between **Witty** and [**@moonsheepverse**](https://x.com/moonsheepverse), where players bet, aim, and launch sheep across chaotic, cartoonish landscapes filled with **mushrooms, aliens, and volcanoes**. Every shot is a mix of skill, timing, and luck, and every meter your sheep travels increases your payout.

## 🎯 How to Play

1. Choose your game mode: **Classic** or **Alien Invasion**.
2. **Set your launch angle** using the **up** or **down** buttons (between 15° – 75°).
3. **Choose your bet amount.**
4. **Press Launch or hit the spacebar** to fire your sheep.
5. **Watch it fly.** Distance and interactions with objects determine your reward.

For every **100 m** traveled, you earn **1× your bet**. For example, reaching **330 m** gives a **3.3×** return.

### 🎮 Game Modes

#### Classic

A pure distance-based mode. Your payout is determined solely by how far your sheep travels. UFOs, mushrooms, and volcanoes may boost flight distance, but alien interactions do not grant bonus multipliers or penalties. Flags or batteries instantly end the run — hitting them means you lose your bet.

#### Alien Invasion

Alien Invasion adds bonus multipliers and penalties when your sheep hits aliens during its flight. In addition to the distance-based payout, aliens come in three types:

* 🟡 **Gold Alien**: +10× bonus
* 🟢 **Green Alien**: +3× bonus
* 🔴 **Red Alien**: +0.3× bonus

UFOs, mushrooms, and volcanoes still boost flight distance. Flags or batteries instantly end the run — hitting them means you lose your bet.

### ⚡ Terrain Bonuses & Hazards

* UFOs, mushrooms, and volcanoes boost flight distance in both modes.
* Alien bonuses and penalties apply **only in Alien Invasion** mode.
* Flags or batteries instantly end the run. Hitting them means you lose your bet.

## 🛡️ Verifiable Fairness

Moonsheep Cannon is mathematically provable and verifiably fair. We use a Signed Commit-Reveal system secured by a smart contract on Abstract. This ensures the game outcome is locked by the server before you play, but the final result is only determined once you add your own User Salt. This prevents the house from rigging the result or pre-selecting a losing outcome.

### How the Game is Locked

1. The Server's Commitment: When you prepare to launch, the server generates a Secret Seed and its Hash. It signs this hash and sends it to your browser.
2. Your Input (User Salt): When you click launch, you generate a unique User Salt. You send both the server's signature and your salt to the smart contract via the `createGame` function.
3. The Lock: The contract saves the `gameSeedHash` on-chain. Because the server has already signed this hash, it is permanently bound to it and cannot change the seed later to make you lose.
4. The Reveal: After the flight finishes, the server calls `cashOut` or `markGameAsLost` and reveals the raw Secret Seed. The contract hashes this seed and compares it to the hash you locked on-chain. If they do not match, the transaction fails entirely.

### 🔍 How to Verify Your Round

The game doesn't "decide" your outcome on the fly. It uses your combined entropy to select a deterministic result from Pre-simulated Terrains. For every possible angle (15° – 75°), we have pre-computed thousands of unique flight paths stored on IPFS.

You can audit any round manually using the [CommitReveal Contract (0x8134...1699)](https://www.google.com/search?q=https://abscan.org/address/0x81342bc68f61f5e01bc086d93792828412691699).

#### Step-by-Step Verification:

1. Find the Hash: Locate your `createGame` transaction on Abscan. In the Logs tab, look for the `GameCreated` event and copy the `gameSeedHash`.
2. Find the Seed and Salt: Locate the transaction that ended the game (`cashOut` or `markGameAsLost`). In the Logs tab, copy the `gameSeed` and the `salt`.
3. Check the Math:
   * Integrity Check: Hash the revealed `gameSeed` using a Keccak-256 generator. It must perfectly match the `gameSeedHash` from Step 1.
   * Result Check: Use the TypeScript logic below with your `gameSeed` and `salt` to derive the exact index. Match this index against the IPFS datasets to verify the flight distance.

#### Verification Code

The following logic is used to select your flight path. This can be run by anyone to independently verify the outcome.

TypeScript

```typescript
import { encodeAbiParameters, Hex, keccak256, parseAbiParameters } from "viem";

const sheepCannonData: Record<number, any[]> = {}; // Dataset loaded from IPFS

function runGame(gameSeed: Hex, salt: Hex, angle: number): any {
  // Combine the game seed and user salt for a unique hash
  const combinedSeed = keccak256(
    encodeAbiParameters(
      parseAbiParameters('bytes32, bytes32'),
      [gameSeed, salt]
    )
  );

  // Convert the hash into a numeric index
  const seedNumber = parseInt(combinedSeed.slice(2, 10), 16);
  const resultSources = sheepCannonData[angle];

  // Select the result from the pre-simulated data
  const randomIndex = seedNumber % resultSources.length;
  return resultSources[randomIndex];
}
```

***

### 📂 Open Data Sources (IPFS)

Transparency is at the core of Moonsheep Cannon. You can audit the game engine or verify specific runs by accessing our simulation datasets directly via IPFS. These datasets contain the coordinate and event data for every possible seed at every launch angle.

| Resource            | Link                                                                                                                             |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Game Build          | [View on IPFS](https://www.google.com/search?q=https://ipfs.io/ipfs/bafkreib5hx2aesxzu5fon5wh4tbreglfhsjhkbhi4hrv2d5n2nkgyg6hf4) |
| Classic Mode Data   | [View on IPFS](https://www.google.com/search?q=https://ipfs.io/ipfs/bafybeih3wkbyjchq6yif36q3ktmjmxaqpfjbpmq3pe6honulfzu36zqdqm) |
| Alien Invasion Data | [View on IPFS](https://www.google.com/search?q=https://ipfs.io/ipfs/bafybeibvrab673q4u7lqy6hcuwp2rjqj77gvwwkyp32jqsy47hhgfmd6y4) |

### 💰 RTP and Risk

#### Classic

* The Return to Player (RTP) varies slightly by launch angle, typically between **96.00% \~ 96.08%**.
* Across all angles combined, the overall RTP is **96.04%**.

#### Alien Invasion

* The Return to Player (RTP) varies slightly by launch angle, typically between **96.00% \~ 96.08%**.
* Across all angles combined, the overall RTP is **96.03%**.

#### General

* Lower angles carry higher risk and higher potential payout.
* Higher angles provide more consistent, lower-variance returns.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.witty.game/welcome-to-witty/moonsheep-cannon.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
