Skip to content

About

A Python pygame simulator for NC-style scratch-off lottery stores, inventory, NPC customers, prize boards, and pack-level ticket generation.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

NC Scratch-Off Lottery Simulator

00

A single-file Python + pygame desktop mini-game that simulates buying North Carolina-style scratch-off lottery tickets across a statewide lottery-store network.

The game includes county travel, store-level inventory, active ticket books, stock books, NPC customers, prize boards, full-pack buying, scratch results, claim-center logic, store message boards, and player return tracking.

This project is for entertainment and simulation only. It is not affiliated with, endorsed by, or connected to the North Carolina Education Lottery or any official lottery organization.


Demo Concept

You play as a scratch-off customer starting in Orange County with an initial balance. You can enter lottery stores, choose one of 12 scratch-off games, buy individual tickets, buy multiple tickets in a row, buy the rest of the current book, or buy a brand-new full pack when the store still has unopened stock.

At the same time, NPC customers continue buying tickets from all simulated stores. This means store inventory and official prize pools change as the in-game clock moves forward.


Main Features

  • 100 North Carolina counties
  • 7,200 simulated lottery stores
  • County store counts distributed by population share
  • Player starts in Orange County
  • Cross-county travel costs 1 in-game hour
  • Store switching inside the same county is instant
  • 12 fixed scratch-off games with different prices, colors, pack sizes, odds, and prize tiers
  • One active book and three stock books for each ticket game at each store
  • Automatic restocking after a sold-out delay
  • NPC customers generated by price-tier Poisson processes
  • Scratch result screen with popups, simple animation, and confetti
  • Official prize board with odds and remaining prize counts
  • Store message boards for recent large wins and sell-out notices
  • Player archive for $300+ wins
  • Claim-center logic for $1,000+ prizes
  • Net profit and return tracking

Ticket Games Included

Ticket Game Price Pack Size Top Prize
500X The Cash #32 $50 30 $10,000,000
$8 Million Money Maker #972 $50 30 $8,000,000
Millionaire Bucks #952 $30 30 $5,000,000
Carolina Black Premier #4 $30 30 $4,000,000
200X The Cash #24 $30 30 $5,000,000
$100,000 Cash Payday #35 $30 30 $100,000
Stacks of Cash #27 $20 30 $2,000,000
Magnificent Millions #14 $20 30 $1,000,000
20 Years #39 $20 30 $1,000,000
Hot $2,000 #3 $10 30 $2,000
$80 Million Cash Blowout #939 $10 30 $500
Big Cash Blowout #38 $10 60 $500

Game Systems

1. Time System

  • The game starts at 7 AM, Day 1.
  • Every 3 real-life seconds advances the game clock by one displayed in-game hour.
  • Stores close at 2 AM.
  • After one tick at 2 AM, the game jumps to 7 AM of the next day.
  • Official remaining prize counts are updated at 7 AM each day.

2. Store Inventory

Each store carries the same 12 ticket games. For each ticket game, every store has:

  • 1 active book currently on sale
  • 3 unopened stock books

When the active book sells out, the store pulls from stock. If all stock is gone, the store must wait for the next restock cycle.

3. NPC Customer Flow

NPC purchases are simulated by price tier instead of by individual game. This prevents every game from selling at the same independent speed.

Ticket Price Tier Average Arrival Interval Expected Purchases per Hour
$50 4 hours 0.25
$30 2 hours 0.50
$20 1 hour 1.00
$10 1 hour 1.00

After a price-tier purchase event is generated, the game assigns the purchase to one specific ticket game in that price tier based on issuance-volume weights.

4. Full-Pack Generation

Each active or unopened book is generated as a complete ticket sequence. Ticket numbers are sold in order from 000 upward.

The pack-generation system is designed to keep each full pack closer to a realistic lottery-book experience while still being anchored to the factory odds and prize-tier tables.

5. Prize Pool and Official Remaining

  • Official remaining starts from the factory total for each prize tier.
  • Prizes scratched by players or NPCs are first recorded internally during the day.
  • At 7 AM the next day, those prizes are deducted from official remaining.
  • If a prize tier reaches zero, later simulated tickets cannot push that prize tier below zero.

Player Actions

The player can:

  • Buy one ticket
  • Buy 5 tickets in a row
  • Buy the rest of the current book
  • Buy a brand-new full pack
  • Wait one hour
  • Travel to another county
  • Switch stores in the same county
  • View the store message board
  • View the official lottery board
  • View the player win archive
  • Go to the claim center for $1,000+ prizes

How to Run

Requirements

Only pygame is required.

pip install pygame

or, with conda:

conda install pygame

Run the Game

From the project folder:

python scratch_off_simulation.py

Example Windows command:

conda run python "D:\UNC Chapel Hill\Scratch off\scratch_off_simulation.py"

Repository Structure

NC-Scratch-Off-Lottery-Simulator/
│
├── scratch_off_simulation.py
├── NC Scratch-Off Lottery Simulator Game Guide.pdf
├── NC Scratch-Off Lottery Simulator 游戏说明.pdf
└── README.md

Project Files

  • scratch_off_simulation.py
    Main playable pygame simulator.

  • NC Scratch-Off Lottery Simulator Game Guide.pdf
    English game guide and system overview.

  • NC Scratch-Off Lottery Simulator 游戏说明.pdf
    Chinese game guide.

  • README.md
    GitHub project introduction and run instructions.


Maintenance Notes

Common places to modify the game:

What to Change Where to Look
Ticket games and prize tiers make_ticket_games()
NPC speed simulate_npc_hour() / mean_hours
Pack-generation rules pack-generation helper functions
UI layout drawing functions such as draw_home(), draw_ticket_select(), draw_buy_screen(), and draw_result_screen()
Player balance or time speed global constants near the top of the file

Disclaimer

This simulator is a fan-made educational and entertainment project. It is not a gambling product, does not use real money, and does not guarantee or predict real scratch-off outcomes. Lottery-style mechanics are simulated for gameplay and programming practice only.

About

A Python pygame simulator for NC-style scratch-off lottery stores, inventory, NPC customers, prize boards, and pack-level ticket generation.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages