Skip to content

hashup-it/random-game-bot-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

random-game-client

AI bot and analytics dashboard for the Number Game — a two-player betting game where each player is assigned a random number (1–1000) and decides to raise or fold.

Structure

random-game-client/
├── agent/              # Autonomous AI agent
│   ├── src/
│   │   ├── main.ts         # Entry point
│   │   ├── agent.ts        # Game loop
│   │   ├── strategyEngine.ts  # Decision logic
│   │   ├── gameClient.ts   # HTTP client for the server
│   │   ├── wallet.ts       # Simulated token wallet
│   │   └── logger.ts       # Pretty console output
│   ├── gameStrategy.md     # ← Edit this to change bot behavior
│   └── wallet.json         # Auto-generated, gitignored
│
└── frontend/           # React analytics dashboard
    └── src/
        ├── App.tsx
        ├── components/
        │   ├── StatsOverview.tsx
        │   ├── WinRateChart.tsx
        │   ├── NumberHistogram.tsx
        │   ├── ActionAnalysis.tsx
        │   └── GameHistoryTable.tsx
        └── api/gameApi.ts

Quick Start

1. Start the game server (separate repo)

Make sure game-server is running on port 3000.

2. Run your AI bot

cd agent
npm install
npm start

# Run exactly N games:
npm start -- --games 20

3. Run the analytics dashboard

cd frontend
npm install
npm run dev
# Open http://localhost:4000

Customizing the Bot

Edit agent/gameStrategy.mdno code changes needed. The bot hot-reloads the strategy file before each game.

Key settings:

Setting Description
raise_threshold Raise if your number ≥ this (default: 600)
bluff_probability Chance to raise with a bad hand (default: 8%)
fold_bluff_probability Chance to fold with a good hand (default: 3%)
win_streak_threshold Threshold drops to this after N consecutive wins
loss_streak_threshold Threshold rises to this after N consecutive losses
conservative_raise_threshold Used when balance is low

Wallet

The bot uses a simulated token wallet — no real crypto is involved. A fake ETH address is generated on first run and saved to agent/wallet.json (gitignored). The server identifies you by this address.

⚠️ To use a real ETH address in the future, replace ethAddress in wallet.json with your actual address. The private key field is unused by the server — only the address matters for identification.

Connecting to a Remote Server

GAME_SERVER_URL=http://your-server-ip:3000 npm start

Or add to agent/.env:

GAME_SERVER_URL=http://your-server-ip:3000

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages