# Python

## The Pyglet Game Library

Over the holidays, I sat down and wrote a casual turn-based strategy game. Aside from the obvious fun aspect, one major motivation was to gain experience with the pyglet game library, which I wanted to evaluate as a potentially general, light-weight GUI library for Python.

## Takeover: A Turn-Based Strategy Game

Over the holidays, I had the opportunity to work on a spare time project, and so I sat down and wrote a casual, turn-based strategy game; a variant (you might say: a clone) of the KDE game Konquest.

## Bridson's Blue Noise Algorithm Examined

Finding a realistic (or at least, realistic looking) initial configuration of game objects or simulation particles can be a challenge. The desired configuration should appear to be both “random” and at the same time “spatially uniform”, without objects clustering together or overlapping.

## Hidden Markov Models

I have started to get interested in Hidden Markov Models (HMM). As a warm-up, I prepared a pure Python implementation of the relevant algorithms (github).

## Command Line Arguments with Python's Argparse Module

Processing command-line arguments in ad-hoc python tools is one of those areas where I tend to just hack it together from scratch — simply because the effort of learning and understanding the relevant library packages not only seems to be more work than it is worth, but also and in particular more effort than “just doing it” by hand. I don’t want anything fancy, after all. I just want to get it done.

## A Fix for Pysolfc on Linux Mint 21 Vanessa

There are problems playing the pysolfc solitaire game on the latest release of Linux Mint 21 (Vanessa).

The game requires the formatter module from the Python Standard Library, which had been deprecated since Python 3.4, and has been removed in Python 3.10.

An easy, but ad-hoc workaround goes as follows:

## The Diamond-Square Algorithm for Terrain Generation

The Diamond-Square Algorithm is the natural first stop for generating artificial landscapes. The algorithm itself is beautifully simple (more details below, and on its Wikipedia page). But a casual implementation ended up not working at all, prompting me to look for an existing implementation to learn from. However, most implementations I found looked hideously complicated (or just hideous), not necessarily correct, and/or used out-of-date programming languages and styles. It therefore seemed like a good idea to create a clean, simple “reference” implementation of this algorithm, using a contemporary and widely known programming language and style.

## Solving a 1993 Programming Challenge in 2022 (Updated)

I recently came across a collection of old (1990s) “programming challenges”. I thought it might be amusing to tackle one of these challenges using technologies from the period in which they were posed, and compare the solution to one using contemporary techniques. In other words, do the same problem in C and Python.