Skip to main content

Adventures in Polyomino Tiling

Recently I began working on a recreational programming project that unites several subjects I have been wanting to explore for many years: AI, GUI programming, certain mathematical problems, and the intellectual zen and stimulus of gamifying them. My experiences with computer games growing up were quite limited despite that our family was somewhat early to install a 'family computer' in the library in 1992, a 80286 loaner at first and then a late model 386 with a turbo button on the chassis that doubled the CPU freq from only 33 to a screaming fast 66 MHz. I attribute this to my family's traditionalist values. Whether these positively or negatively curtailed my proclivities and aptitudes for computer-based labor, I cannot say for sure. It is true that I did not waste months of my youth on low quality game time, but I've never been wont for abdicating my languid and wastrel temporal habits. I recall several days or even weeks of boredom, and I am sure I have even made up some of the deficit in recent years with several offerings of temporal squandering in low grade video game time: a burning of time against the relentless scourge and depression of real adult responsibility.

Though I've never had the patience for most serious video games, nor the dedication and care to accommodate any I do find interesting with necessary computing resources--I'm insufferably opinionated over the most tedious minutiae and seem to exist in a perpetual state of annoyance even, or especially, when it comes to 'entertainment'--I do remember the halcyon days of sneakernetting copies of simulation games from my friend's house on a 3.5" floppy disk and covertly installing them on our family computer. My brother also found free demos of doom and dark forces online that have got me on a 90's retro Star Wars game tear lately, so long as they work in dosbox or wine. But I greatly digress. The topic here is polyomino games, specifically a game format that is as captivating as it is simple: tetromino tiling.

I used to play ksirtet in the KDE 3 days, but they didn't port it to QT/KDE 4 and the replacement didn't have all of the configurable keyboard shortcuts that ksirtet had. Ksirtet added two features that meaningfully enhanced the gameplay in a way that lowered the threshold for the zen state: translating pieces to the left and right sides of the board, and showing a shadow (a projection) of the piece under the bottom of of the tile board. This allowed you to maintain constant focus on the existing tiling state while simultaneously processing everything else with peripheral sight.

This is my second attempt at reimplementing ksirtet, the first devolved rapidly into vapid, desultory digressions on generalized multidimensional polyomino tiling problems and algorithms. Fortunately, now that I'm older and less idealistic--more impatient, perhaps--I've made some progress. I can't claim much so far for myself as I copied the code directly from Jan Bodnar's excellent wxPython demo tutorial, for which he also has a parallel pyQT version. I'm still evaluating whether to continue with wxPython or not. The relative elegance of the GUI framework will hopefully matter little to me and I may make a change if it results in drastically simpler cross-platform dependencies.

Screenshot of pySirtet 0.1

pySirtet 0.1 in action. Version 0.1 is basically a refactor of the zetcode demo. I've made the code more pythonic, and defintely a little more justinesque.

If you are interested in the game, you can follow the development on GitHub. I have been moderately impressed with the quality of documentation

and good information (as stackoverflow Q&A's, for example) on wxPython online so far, so I may stay with wxPython for now, despite that Phoenix hasn't molted yet.

On Learning Maths

While imagining how awesome of a maths and philosophy teacher I am going to be for my daughter, whose patience occasionally expires in expressions such as "dad, you don't have to teach me all the time", I recalled my own experience with elementary maths and how wastefully and long I fought against both the formalism and, more significantly, the threat and charge of inadequacy for miscomprehension or substandard performance--so much for meritocracy.

The first real arrival a student experiences in the primary education of mathematics in the US is elementary algebra, which is something of a sterilized and frustrating scope from the wonderfully weird and bizarre natural scape of algebra. The subject of elementary algebra is necessarily constructed from two theories: the theory of equations and the theory of functions, and typically features a myopic fixation on polynomial functions. Neither command of nor felicity in the topic can be attained without a fluent proficiency in both theories. For me, it was not until I took foundations of analysis, well into a maths BS, taught by a practicing mathematician at a research university that my understanding of these two theories was finally made clear. How much more advantage that my daughter would have then I, I thought, to learn from someone who knows the rigor and loves the subject.

There are other mathematical lexicons so fundamental to their domain, and all those that derive therefrom, similar to the theories of equations and functions, that I wish I either had had the intelligence to recognize or the fortune in a teacher wise enough to make it clear when I formally began learning them. The first comes from the theory of differential equations and the second from the theory of probability. Fluency in elementary algebra and calculus is not sufficient to be successful in constructing and applying differential equations and their solutions or appropriating their models. The same can be said about elementary algebra, some of whose ancient practitioners conjured wild scenarios to solve as if by magic. But since we are to learn that elementary algebra only has merit in the service of other topics, specifically those that form the mathematical prerequisites for a proper engineering education, no such interest or wonder was ever afforded by me to the magic of long form word problems in elementary algebra and how the application thereof is artful or captivating. A proper engineer's pursuit, however is the creative and discriminating application of differential equations, both ordinary and partial, and their solutions. Again, it was not until my second semester of graduate quantum mechanics that I think I really started to see such maths in nature. Once you learn the ways of differential equations, you never look at things in the same way again. You see them as boundary conditions, resonances, and decays.

The last item comes from the theory of probability, is more of a concept than a dialect, and is called a random variable. Like differential equations, which can be seen as a generalization of the theory of equations to which the solutions are functions rather than variables (sets), random variables generalize the meaning of a variable in ways that are profoundly insightful to any field that applies maths to reality, but a full comprehension for me only came together near the end of my first semester in undergraduate probability.

My relative travails in each topic I think demonstrates my own daft beginnings more than anything else. We know so little about ourselves in the beginning and how we learn. Mathematics has never been easy for me and despite the unrelenting contrary accusations. It is a fulfilling competence that was refined only through years of intellectual agony and determination. I think I was improbably lucky to have obtained and retained a handle on its innate, sublime beauty from when I was very young.

Maths is a language but they are also a curious collection of disparate locales with translations and orthonormal purposes as needed. Seductive formulas such as the complex exponential and elliptic curves belie an awesome variety and utility underneath their deceptively simple forms and we conjecture about yet more ambitious, unified truth from simple forms. I always return to Hilbert's defiant declaration:

Wir müssen wissen.
Wir werden wissen.

and wonder what weird meaning is wrought from raw logic in the human mind against its eclectic Condition and whether that construct really does sing the music of the universe, or the mad phantasms and sprites that spring into consciousness or both.

Setting Up Blog

I've always been wary of third party and/or hosted web publishing platforms, but it seems that there are plenty of lightweight static blogging engines out there. For me it came down to pelican and nikola, wherein I chose nikola. Mainly I wanted something that advertised full support for rST, and a few other niceties, such as tags and comments.