You are browsing as a guest. Sign up (or log in) to start making projects!

Barcode Number Game

  • 3 Devlogs
  • 1 Total hours

Barcode check digit Game

Ship #1 Changes requested

What is it?
An interactive math-puzzle game built using Python and Streamlit that turns a real-world hidden engineering mechanism—the retail fallback key-in process—into a fun arcade experience.

How does it work? What's the challenge?
Standard retail UPC-A barcodes are exactly 12 digits long and rely on a strict mathematical **Modulo-10 Checksum Algorithm** to prevent scanning errors. When a barcode is physically scratched, cashiers must type the numbers manually. This game simulates that broken terminal protocol: it generates 11 random barcode digits but completely blinds one variable slot with a `❓` question mark. The player is given the final 12th **Check Digit** and must use modular algebra in reverse to calculate the missing digit before submitting their code verification.

- Attempt-Based Scoring Matrix: Built to reward care over careless guessing. A perfect first-try scan awards +10 points. A second attempt awards +5 points, and a final manual override squeaks by with +1 point.
- Three-Strike Terminal Lockout: If a player records 3 consecutive checksum failures, a system error state triggers. The script locks out the number entry widget, reveals the correct answer in a terminal log, and forces them to click a manual "Initialize Next Puzzle Sequence" button to reset the parameters.
- Persistent Session State Memory: Leverages `st.session_state` vectors to freeze the random barcode matrix across input submissions, avoiding accidental page-reload re-randomization bugs.
- Mathematically Honest Help Expander: Features a drop-down panel displaying a step-by-step breakdown of the live calculation. It creates a temporary `blind_digits` copy array, replacing the hidden variable with a clean `0` so players can inspect the raw odd-position (weighted x3) and even-position sums to reverse-engineer the math.

  • 3 devlogs
  • 1h
  • 11.67x multiplier
  • 15 Stardust
Try project → See source code →
Open comments for this post

23m 51s logged

The game is complete! I might add some extra features later on but for now it’s done. The game has a strike counter, a punishing score adder (1st try 10 pts, 2nd try 5 pts, 3rd try 1 pt, >3rd try 0 pts) The help dropdown does most of the calculations leaving a much more easily solvable calculation.

0
0
2
Open comments for this post

29m 53s logged

I have now added a player input box and a help dropdown which reveals the step by step process to work out the missing number using modulo 10. The score now increases by 10 every time a digit is guessed correctly. A new puzzle is generated every time the player guesses it correctly.

0
0
1

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…