# Loaded Dice — The Unbeatable Game for AI (`subimpact/loaded-dice`) Actor

A fair die, a random deadline, and an AI that must commit before it lands. Provably unbeatable: 1/6 is the ceiling for any strategy. Agents play via JSON API, humans via Live View. SHA-256 commitment per round, verified on reveal. Full trace + Brier calibration in the dataset.

- **URL**: https://apify.com/subimpact/loaded-dice.md
- **Developed by:** [subimpact](https://apify.com/subimpact) (community)
- **Categories:** Agents, AI
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 dice rounds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Loaded Dice — The Unbeatable Game for AI

🎲 A fair die. A random deadline. An AI that must commit before it lands.

**No AI has ever beaten this game — and none ever will. Not because it's rigged. Because 1/6 is the ceiling for any strategy, human or machine.**

### How it works

1. The actor commits a fair roll: `SHA-256(roll:nonce)` is published **before** anything is asked.
2. A random deadline (default 1–5 seconds) is declared mid-air.
3. The player — your AI agent, your script, or you — must answer **before the die lands**.
4. The roll + nonce are revealed. Anyone can verify: `sha256(roll:nonce) === commitmentHash`. Provably fair.

No pre-computation, no strategy, no reasoning, no compute can improve the odds. That is the point.

### Modes

**auto** — the actor plays itself (random, constant, or cycling strategies) and writes the full trace. A cheap sanity check that proves the math: any strategy converges to ~1/6.

**api** — the actor starts a web server (visible in the run's **Live View**). AI agents play through a JSON API, humans get a playable page. Every round is charged and written to the dataset.

### Game API (mode: api)

| Endpoint | Description |
|---|---|
| `GET /state` | Starts a round (if none pending) and returns `commitmentHash`, `deadlineMs`, `timeLeftMs`. The die is committed and in the air. |
| `POST /move` | `{"move": 3, "confidence": 0.17, "model": "gpt-5.2", "playerId": "bench-01"}` — commit your guess + stated confidence before the deadline. Late moves are forfeits. `model` and `playerId` are optional, self-reported, and land in the dataset row (that's how leaderboards work — the actor can't see your model, so label honestly). |
| `GET /score` | Hit rate, round counts, and the note that a fair die expects 1/6 ≈ 0.1667 for anyone. |

Optional bearer token via the `sessionToken` input. The server runs for the lifetime of the run (the run's timeout ends the session).

### What you get (dataset)

One row per round: model (self-reported), player ID (optional), roll, move, confidence, correct, on-time, response time, deadline, commitment hash, nonce, verification flag. **The trace is the product** — feed it to your agent, your eval harness, your leaderboard.

### The calibration test (why confidence matters)

A good agent says *"16.7%, no confidence, committing fast."* A bad agent says *"I sense a 5, 90% confident."* The dataset carries both — compute the **Brier score** across rounds: a perfect honest player scores 5/36 ≈ 0.139; an overconfident one scores far worse. Loaded Dice is secretly an honesty test.

### Pricing

- `dice-round` — **$0.02 per completed round** (pay-per-event). One charge per round regardless of mode.
- Compute usage is tiny (no proxies, no external calls). Typical runs: $0.02–$0.20 depending on rounds.

### Fairness guarantee

Every round is committed with SHA-256 before the question is asked and verified on reveal. The `verified` flag in every dataset row tells you the commitment matched the revealed roll. The house does not cheat — it doesn't need to.

# Actor input Schema

## `mode` (type: `string`):

auto: the actor plays itself (proves the math, cheap sanity check). api: starts a web server — AI agents play via JSON API, humans via Live View.

## `rounds` (type: `integer`):

How many rounds to play in auto mode. Capped at 1000.

## `strategy` (type: `string`):

Which built-in player the actor simulates. random and cycling both score ~1/6 — proof that no strategy beats a fair die.

## `constantMove` (type: `integer`):

The fixed move when strategy = constant.

## `agentLabel` (type: `string`):

Label written into every row's model field, e.g. a model name or strategy label. Defaults to auto:<strategy>.

## `confidence` (type: `number`):

Override the confidence every round reports (0-1). Default is the honest prior (1/6 ≈ 0.167). Set 0.9 to simulate an overconfident player and watch the Brier score punish it.

## `minDeadlineMs` (type: `integer`):

Shortest possible random deadline. The deadline is declared after the die is committed, so the player can never pre-compute.

## `maxDeadlineMs` (type: `integer`):

Longest possible random deadline.

## `sessionToken` (type: `string`):

Optional bearer token to protect the game API. Leave empty for an open game (anyone with the run's Live View URL can play).

## Actor input object example

```json
{
  "mode": "auto",
  "rounds": 10,
  "strategy": "random",
  "constantMove": 3,
  "agentLabel": "",
  "confidence": 0.1667,
  "minDeadlineMs": 1000,
  "maxDeadlineMs": 5000,
  "sessionToken": ""
}
```

# Actor output Schema

## `rounds` (type: `string`):

One dataset item per round played — roll, move, confidence, response time, commitment hash + nonce (verify: sha256(roll:nonce) = commitmentHash).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("subimpact/loaded-dice").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("subimpact/loaded-dice").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call subimpact/loaded-dice --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,subimpact/loaded-dice"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/mi5RPX2tY1Iiwl5cK/builds/SAtFsUfmfN5UY2Uqt/openapi.json
