Research Note
Game Development with pygame
Proficiency
Proficient
Description
pygame framework (full stack)
pygame.sprite.Spritebase class + inheritance tree (9 Enemy subclasses; 4 Bar subclasses)pygame.sprite.Grouporganized by type (enemiesfull set +ord_enemies/heal_enemies/split_enemiessubset for per-type batch collision/update)pygame.Surface/pygame.image.load/convert_alpha+ double-buffered drawingpygame.mixer:music.load + play(-1)for looping BGM +mixer.Soundfor triggered SFXpygame.fontwith custom font (Futura.ttc) + text renderingpygame.time.ClockFPS control (60 FPS, 60s per match)pygame.eventevent loop: KEYDOWN/KEYUP + QUIT + multi-branch
Scene + state management
- Multi-mode state machine (main menu / battle / story / pause / end / tutorial — 6 scenes)
- Assets pre-loaded into Surface caches to avoid runtime disk I/O
- Pause/end overlays + per-menu option state
Custom DSL (Domain-Specific Language) design
- Token-stream data structure (double-ended deque) supporting both
L_prepend andR_append - Key-to-token mapping (
KEYDICTlookup) - Real-time evaluation (
calc(x)applies tokens in order) - Symbolic simplification rule engine (inverse pair cancellation:
a·s,l·e,d·d,-·-,/·*) — lite computer-algebra normalize - Expression pretty-print (token stream → readable string like
sin(e(x/2))) - Custom exceptions as gameplay mechanic (
out_of_domainon log(neg)/arcsin(|x|>1)/1/0 triggers “function invalid” feedback)
Game balance & incentive design
- Non-linear cost function:
cost = f(linear, A, d, e, l)with exponential compositionpow(2+linear, 1.5+A)penalizing nested operations — making elegant expressions the dominant strategy - Converting mathematical rigor (exceptions) into gameplay feedback — getting it wrong is how you learn
Coordinate abstraction
- Four bidirectional mapping functions (
lof/tof/xof/yof) decouple physics and screen coords pygame.sprite.Sprite.rect.centerand custom (x, y) coord systems kept in sync
Gamified educational design
- 11-level tutorial with increasing math difficulty: single ln → single exp → single sin → 2sin → sin×2 → sin÷2 → …
- Each level has fixed target points (e.g.
[(0,-4), (1,0), (3,1), (7,2)]for ln) — player must construct a function through them — an inverse problem-to-answer practice - Knowledge sequencing: single ops first, then composition, then deep nesting — core curriculum-design principle
- Directly relevant to the Exam-centric AI Coaching idea in
Engine reverse-engineering (cross-project)
- In , to build the rollout simulator, Zhenyu fully reverse-engineered Prof. Chen’s
kernel.py(eject physics / multi-body absorb / collision grouping) — white-box modeling of external game engines
Relationships to Other Skills
- Complementary to Game AI & Control Architecture: one develops the game, the other develops AI that plays games
- Carried by Algorithms & Data Structures: OOP inheritance, deque streams, rule-engine simplification — all vehicles of this skill
- Resonates with Frontend & Web Development: both are “interactive application development” (pygame Surface vs DOM); same product-aesthetics + engineering-detail preference
- Resonates with Claude Code Skill Authoring Methodology: DSL design (keyboard → math function) is isomorphic to SKILL.md + persona + examples design thinking (Skills as user-defined behavior)
Used In
- — Math Kills Monsters Alpha 4.0 (~1300 lines pygame + 9 enemies + 11 tutorial levels + full UI + audio/visual assets)
- — white-box understanding of the kernel.py / world.py / cell.py game engine internals
- Potential future use: interactive components for educational/visualization products