Skip to content

lobreen/SwapCups-Python

Repository files navigation

Swap Cups (Python / tkinter)

macOS Linux FreeBSD Windows ARM64

Platforms tested: macOS. tkinter is cross-platform, so Linux, FreeBSD, and Windows (incl. ARM64) are expected to work and are planned for testing — not yet verified.

The "Three Cups" shell game, built up in stages with Python's standard-library tkinter GUI toolkit. A blue ball is hidden under one of three cups; a sequence of swaps (A = Left/Middle, B = Middle/Right, C = Left/Right) shuffles them, and you work out where the ball ended up.

Files (in order of growth)

File What it adds
three_cups.py The pure logic — hide the ball, apply swaps, find the ball (no GUI).
three_cups_gui.py A first tkinter window using text-box "cups".
three_cups_canvas.py Real cup shapes drawn on a Canvas; redraw-from-state each frame.
three_cups_animated.py Swaps play out over time with root.after() (no freezing).
three_cups_interactive.py Full game: ball hidden during play, green/blue "Roswell" dots blink over each swapping pair, and after the run you click a cup to lift it — the ball flashes 7× if found, otherwise the cup is empty.

Run

python3 three_cups_interactive.py

Requires Python 3 with tkinter (included in standard CPython on macOS/Windows; on some Linux distros install python3-tk).

Verifying on a new OS

tkinter ships with CPython but the Tk runtime is sometimes a separate package. Only that install step differs; the run command is the same everywhere:

OS Install Tk Run
Linux (Debian/Ubuntu) sudo apt install python3 python3-tk python3 three_cups_interactive.py
Linux (Fedora) sudo dnf install python3 python3-tkinter python3 three_cups_interactive.py
Linux (Arch) sudo pacman -S python tk python3 three_cups_interactive.py
FreeBSD pkg install python3 py3XX-tkinter python3 three_cups_interactive.py
Windows (incl. ARM64) install Python from python.org (Tk is bundled) py three_cups_interactive.py

(On FreeBSD the py3XX-tkinter name tracks your Python version, e.g. py311-tkinter.)

Functional check (same on every OS):

  1. Pick a cup — it lifts and the ball flashes 7×.
  2. Enter swaps (e.g. ABCAB) and press Play — green/blue dots blink over each pair.
  3. When done, click a cup — the ball flashes 7× if found, else "Nothing under that cup."

When a platform passes, flip its badge from planned-lightgrey to tested-2ea44f (and add the matching topic).

Sibling ports

The same game also exists in SwiftUI and C++/wxWidgets.

About

Swap the Cups shell game — Python/tkinter (with Roswell dots + click-to-reveal)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages