Paul Boxley

Boids

I've always been fascinated by emergent behaviour, there's something cool about simple rules resulting in a complex outcome. I think that Boids is a really good way of demonstrating emergent behaviour.

Boids is an artificial life program, developed by Craig Reynolds in 1986, which simulates the flocking behaviour of birds.

I decided to put together a 2D version of Boids using HTML5 canvas. Click the "Start" link below to see them start moving.

StartStopReset

The boids above follow three very simple rules (that you can switch on and off):

(This isn't a rule, it just helps visualise who's a neighbour!)

What's going on here

I start by creating 30 boids, each with a random starting position and direction.

On each frame, each boid investigates its neighbours and figures out the average directions of those that are reasonably close (within 100px) and those that are too close (within 30px).

If the first rule is enabled then the boid will rotate itself slightly towards the average direction of the reasonably close boids.

If the second rule is enabled then it will rotate itself slightly away from the average direction of the very close boids.

If the third rule is enabled then it will also survey all the boids on the canvas, figure out where the highest population of boids is and rotate slightly in that direction. This is useful for the boids that occasionally disappear off on their own and would otherwise fly off in a straight line forever (which isn't a huge problem in this example, since boids reaching the edge will wrap around to the opposite edge).

It's quite fun disabling the 2nd rule, watching the boids squish up close to each other, and then enabling it again to see them all fly away from each other.

Source code

The source code is available on my github page. It's written in coffeescript and is hopefully fairly self explanatory. I tried making some docco docs but that didn't go very well. Hopefully I'll get them up soon.

Let me know if you have any questions or suggestions @baxt3r

[ Tweet about 'Boids' ]   [ Permalink to 'Boids' ]

An explanation of the IceCube Neutrino Observatory

I stumbled across this lovely explanation of the IceCube Neutrino Observatory via Reddit.

[ Tweet about 'An explanation of the IceCube Neutrino Observatory' ]   [ Permalink to 'An explanation of the IceCube Neutrino Observatory' ]

2,048 Tweets

211 tweets! Hooray!

It's been about a year since I hit 1,024 tweets. In that time a few things have changed; after four years working for the Forestry Commission I left to join the guys at ASMALLWORLD building and maintaining a huge Rails app.

I wondered what my mood had been within this period. One extremely unscientific indicator of mood is emoticons.

Emoticons

As you can see, I have been mostly :), occasionally :D, sometimes :( and hardly ever D: which is exactly how things should be, so that's good.

Retweets

Over the past year I've averaged 2.61 tweets a day.

229 of those tweets (about 22%) have been retweets. That's higher than I thought it would be, so I had a look at who I'd been retweeting:

Of the 229 retweets that I've made, 128 of those, or 55%, were retweets from users that I've only retweeted once. I don't even follow most of them. I wasn't aware how often I retweeted retweets, but the data suggests I do it quite a lot!

Of the people that I've retweeted three times or more, here's who I've retweeted the most:

I've colour coded the charts to group people together.

At the top of the retweets is @saveourforests. This is actually an account I registered myself during my time assisting in the Save Our Forests campaign while at the Forestry Commission, so there is a little bit of self-promotion going on here, but since its creation the account has been updated almost exclusively by Tony, a former colleague, so I don't feel too guilty! And it was (and is) for a good cause!

Following on from that there's a good mix of people from ScotRUG and work who tend to say amusing or interesting things, and of course my girlfriend Lindsey, aka @Daily_Madness, who I am obliged to retweet from time to time to stay in her good books ;)

My @notch retweets are due to my recent Minecraft addiction. The less said about that the better.

Mentions

Mentions are more varied than retweets, probably because I'm more likely to have a conversation with most people than retweet them.

My colleagues @mungler and @mr_urf top the mentions chart, followed almost exclusively by members of ScotRUG and the Guild Wars Wiki, the only notable exceptions being my friend @mikos who is not a ruby developer (shock horror) and @Daily_Madness.

Hashtags

I feel like I have to mention hashtags since they're an important part of Twitter, but it would be pointless creating a chart for them since I only tend to use them as jokes.

The only two that I seem to have used seriously are #yaypril 3 times and #scotruby 7 times.

Language

My most used word is "I". I'm so egocentric. This hasn't changed from last year.

But short words aren't very interesting, so instead I examined my most used longer-than-four-letter words:

My most used words actually seem really positive! In fact you can almost read that last chart as a sentence.

I tend to say thanks a lot in real life, but I didn't realise this had carried over into Twitter.

I also probably say "awesome" a little too much. I am trying to replace this with "splendid".

Summary

I'm not sure if analysing my tweets is a normal thing to do. I'm pretty certain it isn't. But it's quite fun to look closely at something that you've been doing almost absent-mindedly – like reading too much into people's doodles or trying to predict the future by examining the remnants of a cup of tea.

Thank you to my Twitter followers/followees for a year full of :), here's hoping for another 2,048 mostly happy tweets!

[ Tweet about '2,048 Tweets' ]   [ Permalink to '2,048 Tweets' ]

If this then that

Ifttt is a website that lets you set up tasks of the form "If this then that" where "this" is a trigger and "that" is an action. Some popular tasks include:

Ifttt has managed to simplify the interface between a number of popular web apps so that you can set up a whole host of tasks with the minimum of configuration. And even better, once you've created a cool task you can turn that into a "recipe" and share it with other people.

Really good stuff.

[ Tweet about 'If this then that' ]   [ Permalink to 'If this then that' ]

Real time face substitution

Put together using mostly open-source tools.

[ Tweet about 'Real time face substitution' ]   [ Permalink to 'Real time face substitution' ]

What in the name of Sir Isaac H. Newton...

I'm not often fussed about shoes, but I want a pair of these.

[ Tweet about 'What in the name of Sir Isaac H. Newton...' ]   [ Permalink to 'What in the name of Sir Isaac H. Newton...' ]

Games I've been playing

I don't write about games very often, so here are a few games that I've been playing recently and why I like them.

From Dust

By Eric Chahi and Ubisoft Montpelier, From Dust is a god game, playing like a modern Populous. In fact it feels lot like a Peter Molyneux game except with more emphasis on helplessness than on morality.

Despite having the ability to manipulate the elements at whim, you soon discover that it's very easy to upset the balance of nature – blocking the flow of a river for some short term gain can quickly lead to bigger problems when the river breaks its banks.

This is a game about order and chaos, and about the difficulty of regaining control over a badly planned situation. I don't want to give any examples in case I spoil the fun, but trust me when I say it's clever and infuriating in equal measure.

Bastion

Bastion is a top down action RPG in which everything that you do is narrated.

Having someone describe your every move is weird, but it adds an interesting dimension to the game. The narrator tells the story as someone who has already experienced it to the end, occasionally hinting at what the future holds, leading to a sense of foreboding.

Child of Eden

I love Tetsuya Mizuguchi, the creator of Rez, and while Child of Eden isn't dramatically different from Rez in terms of gameplay, being another on rails shooter, it is certainly better looking than its predecessor. Where Rez was minimalist and polygonal Child of Eden is decadent and organic.

Another game based on Mizugughi's obsession with synesthesia, this time the conceit is that you are saving a developing artificial intelligence called Lumi from a destructive virus:

Child of Eden thrusts you in the center of a battle to save Project Lumi, a mission to reproduce a human personality inside Eden, the archive of all human memories.

Much like Rez, the plot doesn't really matter. Child of Eden manages to put me into "the zone" like few other games are capable of.

Minecraft

I know I'm late to the party but I've been playing Minecraft a lot recently. So far I have a little house, a pet wolf and a farm. I also found some iron the other day. I have a new appreciation for Creepers, possibly the most terrifying creatures ever imagined.

Here's a picture of my wolf and my farm, and an axe that I'm holding.

A picture of my wolf and my farm, and an axe that I'm holding

[ Tweet about 'Games I've been playing' ]   [ Permalink to 'Games I've been playing' ]

Jonathan Blow – How to program independent games

Jonathan Blow, creator of Braid, gave a talk to UC Berkeley computer science students on his style of programming.

Most of the talk is about the aesthetics of code, and about how it's possible for an individual to write the ~90,000 lines of code needed to write a game like Braid.

There is some great advice on ways to code to get things done, but probably the most important thing that Blow says isn't really about programming at all (transcribed below):

Back when I was an undergraduate the Internet existed but it really wasn't the thing that we have now. There wasn't that much of substance online then. Now of course the Internet is huge and it's in everybody's life and it's full of all these people saying things and trying to share information with each other, and I think what happens very often is that you read something somebody said on the Internet and you're like, yeah I get what that guy is saying but he's wrong, or yeah I get what that guy's saying, he's right, but I already knew that and he's stupid, I know better than that now.

Please entertain the idea as you go out into the world that usually neither of those things are true, usually you don't actually understand what the other person is saying. They may be using words where you think you understand each individual word, but the way that they interpret their phrase is different to the way you interpret their phrase and this leads very quickly to problems and it can prevent you from coming to a better understanding of computer science.

Worth a listen, especially for the context surrounding this section that really emphasises the point.

[ Tweet about 'Jonathan Blow – How to program independent games' ]   [ Permalink to 'Jonathan Blow – How to program independent games' ]

NY Times on Dwarf Fortress

A happy dwarf

I love Dwarf Fortress, and the New York Times have a feature on it.

[ Tweet about 'NY Times on Dwarf Fortress' ]   [ Permalink to 'NY Times on Dwarf Fortress' ]

Git caret and tilde

I spent a little bit of time playing with Git today, specifically the way that the ^ (caret) and ~ (tilde) work and thought I'd document it here in case I forget.

The short version

If you want a deeper explanation skip down to "The long version".

ref~ is shorthand for ref~1 and means the commit's first parent. ref~2 means the commit's first parent's first parent. ref~3 means the commit's first parent's first parent's first parent. And so on.

ref^ is shorthand for ref^1 and means the commit's first parent. But where the two differ is that ref^2 means the commit's second parent (remember, commits can have two parents when they are a merge).

The ^ and ~ operators can be combined.

Here's a diagram showing how to reference various commits using HEAD as the starting point.

Referencing commits from HEAD using ~ and ^

The long version

I've created a dummy repository with several commits in it.

$ git log --graph --oneline
* 8329384 Seventh commit
*   f5717b0 Merge branch 'my_branch'
|\  
| * 956c87d Fourth commit on a branch
* | a8fe411 Sixth commit
|/  
* c7c2590 Third commit on a branch
* 86362ff Second commit on a branch
* 748855b First commit on a branch
* 1855b25 Fifth commit
* 67cf3a7 Fourth commit
* ea29778 Third commit
* 28c25b1 Second commit
* cd00b76 First commit

Starting at the bottom, the early commits were made straight onto master.

The commits starting at 748855b and moving up to c7c2590 were made on a branch and merged into master, but no changes had been made on master in the mean time.

The commits a8fe411 and 956c87d were made on separate branches at the same time. They were merged together in commit f5717b0.

Finally, 8329384 was committed straight onto master.

We can use git show to look at individual commits.

You'll already know that HEAD points to the tip of the current branch:

$ git show --oneline HEAD
8329384 Seventh commit
...

Putting the caret symbol (^) next to a commit means the parent of that commit. So the following will show the parent of HEAD:

$ git show --oneline HEAD^
f5717b0 Merge branch 'my_branch'
...

HEAD^ is shorthand for saying HEAD^1, which literally means show me parent 1 of that commit. You can also say HEAD^2 but in this instance it won't make any sense:

$ git show --oneline HEAD^2
fatal: ambiguous argument 'HEAD^2': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

Because HEAD only has 1 parent.

But f5717b0, the point where the two branches were merged, has two parents, one on master and one on the branch:

$ git show --oneline f5717b0^1
a8fe411 Sixth commit
...

$ git show --oneline f5717b0^2
956c87d Fourth commit on a branch
...

The tilde symbol (~) works in a similar way. In fact HEAD~ will reference the same commit as HEAD^:

$ git show --oneline HEAD~
f5717b0 Merge branch 'my_branch'
...

Again, HEAD~ is shorthand for HEAD~1, but here this means the first ancestor of HEADHEAD~2 is not the second parent of HEAD but the grandparent of HEAD:

$ git show --oneline HEAD~1
f5717b0 Merge branch 'my_branch'
...

$ git show --oneline HEAD~2
a8fe411 Sixth commit
...

$ git show --oneline HEAD~3
c7c2590 Third commit on a branch
...

As you can see, 956c87d Fourth commit on a branch is not visible when using the tilde operator. This is because the tilde operator always presumes you want to view the first parent's parent.

To access the second parent's parent the tilde and caret symbols can be combined:

$ git show --oneline HEAD~1^1
a8fe411 Sixth commit
...

$ git show --oneline HEAD~1^2
956c87d Fourth commit on a branch
...

In this way you should be able to reference any commit in your repository's history.

[ Tweet about 'Git caret and tilde' ]   [ Permalink to 'Git caret and tilde' ]
On page 1 of 18 Older