What I've been up to

I’ve not posted anything in some time so I thought I’d prepare an update. Overall, this year, I decided to focus on two themes:

  1. Return to a topic I’d worked on previously but did not complete.
  2. Look into topics I’d been thinking about for some time but hadn’t started on.

Basically, rather than embarking on completely new areas of study, I would like to consolidate what I know already.1

I’ve completed a few projects since the start of the year and some remain unfinished. Let’s look at them then.

Reviewing some old projects

So, how to approach these themes? One idea I had was to revisit some books I’d not finished reading or had read but felt I had not fully appreciated. I looked through several books but the one that I’ll discuss here are:

While I revisiting these books, an idea developed.

Search for success

As I read through Kopec’s book, I had a small brainwave while reviewing the section on algorithmic search. Kopec demonstrated how various search algorithms work. He wrote a programme that generates a maze with a randomly assigned starting point and goal. The idea being to show how different algorithms locate the goal. What intrigued me about this example was the simple ASCII graphics Kopec implemented to show how the various algorithms navigate the maze. They reminded me of old-school dungeon crawlers (by the way I never actually played these back in the day, I might be old, but not that old.)

My idea was to extend this code by allowing a player to navigate the maze themselves and see if they could find the goal in fewer steps than the algorithms - to ‘beat the algorithm’ as it were. I’ve already written up this project here.

Complex thinking

My second project in this area was less successful. This effort focused on Think Complexity, a book I’ve been trying to work through for some years.

For some context, Think Complexity is a kind of follow up to Downey’s excellent Think Python 2 . Think Python is an outstanding introduction Python. It has a rather academic approach so might not be for everyone but it does live up to its subtitle: How to think like a computer scientist. After reading through it, you really do get a sense of what it’s like to think about computing at a very high level.

Think Complexity is rather different. While also quite academic, it serves as an introduction to Complexity Science (also called Complex Systems). With this focus, the code does not occupy the centre stage, rather it’s more a means to an end i.e. making explicit some concepts from Complexity Science. Hence, if you decide to read Think Complexity, my advice is don’t to worry too much about the code, just focus on the underlying concepts.

Entering the sugarscape

Turning to my project idea. I wanted to extend the code related a chapter on a concept known as sugarscape. A sugarscape is a large grid where cells (the agents) consume “sugar” around them. Allocation of sugar is semi-random, with sugar appearing in random locations, but the amount of sugar present is adjusts according to the behaviour of the agents. The agents moving to where the sugar spawns. Some agents have better vision than other meaning they can identify where sugar is located at a greater distance so they find the sugar more quickly.

As you might expect the agents tend to congregate where the sugar is most plentiful until it is all consumed and then the process repeats as sugar is assigned to different cells.

Where this gets interesting is when you introduce a lifespan to the agents. What happens then is not only do agents tend to congregate around where the sugar is most plentiful, but an inequality tends to develop with certain agents having access to sugar then others throughout their lifespans.

This might sound rather complicated but the code is quite readable.

Eyes bigger than your stomach

Looking at the code, as far as I can tell, Downey implements numpy arrays to generate the sugarscape grid and used dictionaries to keep track of how the sugarscape changed as time progresses.

So how did I attempt to gamify this code. My idea was to assign the user a single agent to observe across it’s lifespan. The user would observe ultimately how well the agent did in the sugarscape across its lifespan.

This might not seem like a particularly interesting or interactive game, but I felt the project could exploit a tendency in many games to anthropomorphise simple characters. One classic example of this would be the Tamogotchi craze of the mid-nineties.

Ultimately however, I found this this idea too tricky to develop. The main issue wasn’t so much with the code sugarscape code but an extension to Matplotlib that Downey wrote. Looking at this I’m not clear how it interfaces with Matplotlib and figuring that out might take quite some effort. Currently I don’t want to focus on Matplotlib. But visualisations are something I have an interest in so I might return to it at some point3.

What’s next

Well now that I’ve looked at some older topics, I want to turn to some things I’ve been thinking about but haven’t yet got around to. I won’t spell out exactly what I’ll be working, but there will be something to do with functional programming and something to do with array programming.

What I've been up to by William Samuel McDonald is licensed under CC BY 4.0

Footnotes

  1. I’m a big fan of the podcast Corteks and advocate their New Years Resolution alternative Yearly Themes concept

  2. Think Python will have new a new edition later this year

  3. Incidentally one of my favourite podcasts, Oxide and Friends, recently had a great episode on data visualisations.

education

programming

python