Skip to content
0xDirmesPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Monopoly with AI Players & Blockchain Payments

Monopoly Board

Overview

Canvas-based Monopoly game featuring AI-powered players using Claude Haiku 4.5 and blockchain micropayments via the X402 protocol.

Features

  • Complete Monopoly mechanics - 40 squares, properties, trading, houses/hotels, bankruptcy
  • AI-powered purchase decisions - Claude Haiku 4.5 with prompt caching for strategic gameplay
  • X402 payment protocol - AUSD token micropayments on Base Sepolia
  • Real-time visualization - Canvas-based board with balance history charts
  • Configurable strategies - Simple, aggressive, conservative, or AI-driven players

Quick Start

  1. Clone and install dependencies:

    git clone <repo-url>
    cd monopoly
    pnpm install
  2. Configure environment variables (see Environment section)

  3. Start the game server:

    PLAYERS_CONFIG=examples/players-ai.json npx tsx src/main.ts
  4. Build the client:

    npx esbuild src/index.ts --bundle --outfile=index.js
  5. Open index.html in your browser

Architecture

src/
├── index.ts          # Browser client - Canvas-based game rendering
├── main.ts           # Game server entry point
├── game/
│   ├── gameServer.ts # Express server with game state management
│   ├── card.ts       # Board positions and property definitions
│   └── player.ts     # Player state and strategy handling
└── payment/
    └── x402.ts       # X402 payment protocol implementation
  • Client: Canvas-based browser game with real-time board visualization
  • Server: Express.js handling player joins, moves, and property transactions
  • Payments: X402 protocol with EIP-712 signatures for micropayments

Environment

Create a .env file with:

# Server wallet (receives payments)
SERVER_ADDRESS=0x...
SERVER_PK=0x...

# Anthropic API (for AI players)
ANTHROPIC_API_KEY=sk-ant-...

# Optional
PORT=3000

Player Configuration

Player configs define starting conditions and strategies. See examples/ folder:

File Description
players.json Basic 2-player setup
players-ai.json AI players with custom strategy prompts
players-bankruptcy.json Bankruptcy testing scenario
players-trading.json Trading system testing

Example AI player config:

{
  "name": "Aggressive Alice",
  "color": "blue",
  "strategy": "ai",
  "strategyPrompt": "Buy every property you can afford. Prioritize completing monopolies.",
  "initialBalance": 5000
}

Tech Stack

  • TypeScript - Type-safe development
  • Express - Game server
  • Canvas API - Board visualization
  • Viem - Ethereum interactions
  • Anthropic SDK - AI player decisions

Payment Details

  • Token: AUSD on Base Sepolia
  • Contract: 0xa9012a055bd4e0eDfF8Ce09f960291C09D5322dC
  • Join cost: 100 AUSD
  • Move cost: 200 AUSD per turn

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages