Rendering a 3D Rubik's Cube with Matplotlib
How to draw a fully interactive Rubik’s cube using Poly3DCollection, handle keyboard events for face rotations, and integrate the Kociemba two-phase solver.
Why Matplotlib for a Rubik’s Cube?
Rubik’s cube visualizations typically use OpenGL, Three.js, or a game engine. Using matplotlib’s
mpl_toolkits.mplot3dis unconventional. It’s designed for scientific plotting, not real-time 3D interaction. But it has one huge advantage: zero dependencies beyond what you already have for data visualization. No WebGL, no GPU shaders, no build pipeline. Justpip install matplotliband you have a working 3D cube.Building a Physics Simulation Engine in Python
How the physics_modeling package is architected: base classes, numerical integrators, separation of physics from visualization, and property-based testing.
The Core Abstraction
Every physics simulation answers the same question: given a system’s current state, what is its state at the next instant? Whether you’re modeling a spring, an epidemic, or a galaxy of gravitating bodies, the computation follows one pattern: compute derivatives, advance time, repeat.
The
physics_modelingpackage encodes this pattern in aSimulationbase class:Modernizing Legacy Code: From 2004 VPython to Python 3.14
Taking old college physics simulations written twenty years ago and getting them running on modern Python.
The Time Capsule
In 2004, I was a student at The Evergreen State College in a program called Modeling Motion. We wrote Python simulations of physics phenomena (springs, gravity, epidemics, particle collisions) using a library called VPython. I was learning physics and programming simultaneously, translating equations of motion into running code for the first time.
Building Space MUD: A Text Game About Robots on a Space Station
The premise is simple: you wake up on a broken space station. You don’t remember anything. You start exploring, picking up items, talking to other units, repairing systems. And at some point it clicks: you’re not a person. You’re a robot. The whole game uses mechanical language from the start. Your health is “integrity.” You don’t sleep, you go idle. When you die, it’s an “emergency reboot.” The station doesn’t call you a crew member. It calls you a unit.