Tiger Slug – Limax Maximus

Side view of the Tiger Slug

I disturbed this fellow while gardening today. He took off at speed across my lawn but since he is a slug I had plenty of time to get my camera a snap a few shots.

This is Limax Maximus – the Tiger Slug (or Leopard Slug depending on whether you like the striped tail or the spotted mantle) and they are impressively large. My garden is full of them. Most slugs I kill on sight, but I leave the Tiger Slugs alone because they supposedly kill other garden pests. Besides, they give me a slow moving target to practice macro photography.

Front view of the Tiger Slug

Arrrggh, it’s coming right for me!

Book Review : Two Non-Fiction Books on Destruction

The Wizard of Lies By Diana B. Henriques

A relatively recent book on the Bernie Madoff Ponzi scheme, including information straight from the man himself. I got this hoping for an exciting and twisty crime story about a master criminal, but it turns out the Madoff’s scheme was stupidly simple – he lied about some stuff and keep lying. He wasn’t even very clever about it, but somehow managed to keep the house of cards upright for decades.

Henriques’ book covers a huge amount of ground – going back to Madoff’s childhood upbringing to his peak as a pillar of the New York community. A huge amount of research has been distilled into a very readable story – just about everyone who ever met Madoff seems to have been interviewed, and enough time has passed that the full effects of the scam have been revealed. I just wish that the crime was more ingenious.

Recommended if you like this sort of thing

Death From the Skies! By Philip Plait

Plait runs the popular Bad Astronomy blog which is far more interesting than it has any right to be, this book is even better. There are many books that seek to explain the wonders of the universe in an entertaining way, but Death From the Skies! is the only one that takes the “How could this kill us all” approach. From supernovas to comets, Plait runs down the numbers and details exactly what would happen to the Earth should such misfortune strike (spoiler: it doesn’t look good).

Plait clearly explains the concepts behind familiar astronomical terms and breaks down the magnitude (usually way to large large) and probability (usually not small enough) of each occurrence. It’s all very entertaining, but not something you want to read straight before going to sleep.

Highly recommended

Book Review : Cryptic and Oceanic – Two SciFi Short Story Collections

Cryptic : The Best Short Fiction of Jack McDevitt

Cover of Cryptic by Jack McDevittA mammoth collection of scifi short stories by the prolific Jack McDevitt. McDevitt has an old-fashioned manner and his stories remind me strongly of the tales from the 50s and 60s that I grew up reading – this is not a bad thing.

Not every story is a corker, but most are good and some are downright excellent. My one complaint is that they tend to be rather constant in tone and style, I finished the book yesterday and the stories are all starting to blend together in my head.

Recommended if you like this sort of thing

Oceanic By Greg Egan

Cover of Oceanic by Greg EganAnother collection of Scifi short stories, this time by Greg Egan. Egan is a programmer, and his stories are hard-as-diamond tales of artificial life, strange physical frontiers behind every atom, and clear-eyed researchers heroically hunched over keyboards in darkened rooms. Great stuff, and this collection really shows his ferocious imagination and range as a writer. The title story (full text here) in particular is a very well done piece that packs a lot of depth into a few pages.

Highly recommended

Reading Old Books

I have been going through a phase of reading old, out-of-copyright books – partly because I find it fascinating to see how various literary forms evolved over time, partly because if you go back far enough the books read like science-fiction – alien concepts and strange customs abound, partly because it allows me to affect an air of being well read, but mostly because you can download them for free from Project Gutenberg and I am a cheap bastard.

A Voyage to the South Sea by William Bligh

Cover of A Voyage to the South SeaA while ago I read The Bounty by Caroline Alexander, a modern account of Captain Bligh’s famous-for-all-the-wrong-reasons expedition to Tahiti aboard The Bounty. It focused mainly on what happened after everyone got home again. This book is the tale told by the man himself, compiled by Bligh from his logs kept during the voyage and it is a fascinating read. Even if there wasn’t a (spoiler alert!) mutiny, it would make for a cracking story as Bligh has an eye for both nautical detail during the voyage and a keen interest in how Tahitian society (very different to the English system) worked after The Bounty arrives.

And breadfruit, the dude was obsessed with breadfruit.

Once the mutiny occurs, the story turns into an epic struggle of survival as Bligh and his few remaining crew find that people treat you differently when you turn up on their island without a fully armed three-masted collier anchored just outside their reef.

It is a real pleasure to drop into the world of a competent person doing an interesting job. Since it is taken directly from his meticulous logs there is a charming matter-of-fact style as things unfold without foreshadowing or subplots. The one problem for a modern reader is that it is almost impossible to avoid hearing the text being read in James T. Kirk’s Captain’s Log voice; the style is exactly the same.

A Journey of the Plague Year by Daniel Defoe

Cover for Journal of the Plague YearThis early novel in the form of a diary purports to be a day-to-day account of the life of a young London man during the 1665 outbreak of the black plague as people were dying in their thousands. Defoe did actually live through the plague but he was only 5 at the time, so the story is fictionalized but obviously carefully researched. Defoe uses the experiences of the narrator to highlight how various aspects of society (the rich, the poor, etc) reacted to the plague, maintaining a detached tone while horrible things are occurring on all sides. The thing that struck me the most was the general atmosphere of resigned bewilderment that permeates the book – nobody in pre-germ theory London really understands what is going on but society continues on as best as it can while people are dropping dead and whole streets worth of houses are empty or contain only corpses.

After reading lots of disaster fiction (The Day of the Triffids, Dawn of the Dead, etc) I was heartened to see that people do not automatically devolve into angry, paranoid mobs during a real life events that kill a large percentage of the population, although plenty of isolated complete bastardry apparently will occur.

The Battle of the Safes, or, British Invincibles Versus Yankee Ironclads by George Augustus Sala

And now for something completely different. During the Paris Exhibition of 1867 a public relations spat broke out between a British firm of safe makers and an upstart American firm as to who made the safest safes. This was apparently a big deal in an age when people kept large amounts of cash on hand.

The American firm challenged the British to a public demonstration where each firm nominated a crack team to break into the other’s safe in the shortest possible time. Everything should be simple but the Americans (boo-hiss) keep changing the rules in their favour. Eventually the contest comes to an unsatisfying conclusion but everyone can see that the British (yeay!) have scored a great moral victory.

This is a short, enjoyable, one-sided account of an inconsequential event, filled with all kinds of intrigue and skullduggery. Nothing really gets resolved but it doesn’t matter unless you are really into safes (and the illustrations are great.)

Illustration from The Battle of the Safes - the American safe lies open

Capturing Video at the Speed of Light

When I was a child I used to amuse myself by imagining how things would look if light moved at a few meters per second. I thought it would be cool if you could walk into a dark room, turn on the light and watch as the light spread throughout the scene. Wielding a flashlight would be interesting – you could easily make curved beams.

Now these guys have built a camera fast enough to show the same effect:

Of course, they do cheat a bit by only taking a 1 dimensional slice at a time and relying on the fact that they can repeatably fire identical pulses of light to make their images. Still this is exactly what I imagined it would be like.

Now someone needs to build the high wattage laser targeting system capable of taking out houseflies without blinding humans that I invented when I was 9.

Foo Fighters

I unexpectedly went to the Foo Fighters concert yesterday.

Panoramic Photo of Auckland Foo Fighter ConcertClick to enlarge

Unexpectedly because I wasn’t planning on going, but a friend had to pull out and I bought her ticket. That was also unexpected, because I don’t really dig the Foo Fighters.

I mean, I think they are OK. Acceptable. Competent. But lacking in that spark that I look for in a rock band.

The weather was not good, it had rained all afternoon and Western Springs Raceway was already soggy when we turned up so we staked a spot on the terraces and watched the support acts. We missed local heroes, Cairo Knife Fight, a band I know nothing about except that bFM name checks them constantly but never actually plays their tracks.

The second support act was Fucked Up – a canadian punk/death metal outfit who should have been terrible but come over very well. The lead singer left the stage and spent most of the set wandering around the crowd hugging people and occasionally drinking their beer between verses.

Next came the highlight of the evening for me – Tenacious D. For a joke band they did a tight set and Jack Black is genuinely funny on stage.

Finally, the Foo Fighters. Although they are not my favorite band, you have to respect a group that are prepared to play for almost 3 hours, even if 20 minutes of that was Dave Grohl nattering to the crowd. They played all their hits (after 17 years they have had quite a few) and seemed pleased to be here. The crowd loved it and even the rain let off to let them play. I can understand why Grohl is so popular, he comes across as a sincere and decent person. In my book that is a strike against him as a rocker, but I seem to be outnumbered.

Despite the rain I had a great time at the Foo Fighters. Not enough to buy their music, but I certainly got my money’s worth.

Jumping Frogs – Using Python to Solve Puzzles

A few months ago I came across the following puzzle in a video game I was playing:

The starting position for the siz frogs puzzleThree frogs are happily hopping along a narrow board together when they meet another group of three frogs traveling in the opposite direction. These frogs can only move in the direction they are facing, and only if there is a space directly in front of them. Additionally, a frog can jump over the frog in front but only if there is clear space on the other side to land in.

How can the frogs (moving one at a time) pass each other and continue on their way?

Of course, this is a hoary old puzzle that most people come across and solve as children. It should be only a couple of minutes work with a pen and paper to confirm that it is possible to exchange both sets of frogs but I wouldn’t be much of a programmer if I used a piece of paper where hundreds of dollars of computer equipment would do just as well.

To solve a puzzle like this programatically requires three things: a representation of the current state of the problem, a way of generating every possibly legal move from a given position, and a way of figuring out when is a good time to stop.

Firstly, the representation of the board is a simple python list:

1
start = [1, 1, 1, 0, -1, -1, -1]

Frogs traveling right or left are represented by “1″ and “-1″ respectively. Empty spaces that frog can move into are represented by “0″. The advantage of this representation is that you can calculate the new position of a frog by:

1
newPos = pos + (representation * distance)

where pos is the current index in the array, distance is the size of the hop (either 1 or 2) and representation is either 1 or -1.

Next, we need a way of generating legal moves for a given position:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def legalMoves(board):
	moves = []
	for pos, piece in enumerate( board ):
		jumpmove = pos + (piece * 2)
		move = pos + (piece)
		if ( piece == 0 ):
			continue
		if (not (( jumpmove < 0 ) or ( jumpmove >= len(board)))):
			if (board[jumpmove] == 0):
				t = list(board)
				t[pos] = 0
				t[jumpmove] = piece
				moves.append(t)
		if (not ((move < 0) or ( move >= len(board)))):
			if ( board[move] == 0):
				t = list(board)
				t[pos] = 0
				t[move] = piece
				moves.append(t)
	return moves

Now we need a way of keeping track of all board positions we have seen, so once we find the target we can print the states that led to the solution:

1
2
3
4
5
6
7
8
9
10
11
def evalAll( current, target ):
	next = []
	for a in current:
		n = legalMoves(a[-1])
		for q in n:
			t = list(a)
			t.append(q)
			if ( q == target ):
				return t
			next.append(t)
	return next

This code keeps a list of lists, each sublist being it’s own list of the sequence of moves investigated so far. For each sequence of moves, the next legal moves are discovered and new sequences are added to be investigated the next time this function is called. Technically this is called a breadth-first search because at all of the current legal moves are investigated before moving on the next stage. This is a very simplistic way of doing the job, but in this case the puzzle is small enough that it works well enough.

Finally, a simple wrapper that we can use to set things up and return the final result.

1
2
3
4
5
6
7
def solve(start):
	temp=[[start]]
	end = list(start)
	end.reverse()
	while(temp[-1] != end):
		temp = evalAll(temp, end)
	return temp

So now we can do this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
print solve([1, 1, 1, 0, -1, -1, -1])
 
[[1, 1, 1, 0, -1, -1, -1],
 [1, 1, 0, 1, -1, -1, -1],
 [1, 1, -1, 1, 0, -1, -1],
 [1, 1, -1, 1, -1, 0, -1],
 [1, 1, -1, 0, -1, 1, -1],
 [1, 0, -1, 1, -1, 1, -1],
 [0, 1, -1, 1, -1, 1, -1],
 [-1, 1, 0, 1, -1, 1, -1],
 [-1, 1, -1, 1, 0, 1, -1],
 [-1, 1, -1, 1, -1, 1, 0],
 [-1, 1, -1, 1, -1, 0, 1],
 [-1, 1, -1, 0, -1, 1, 1],
 [-1, 0, -1, 1, -1, 1, 1],
 [-1, -1, 0, 1, -1, 1, 1],
 [-1, -1, -1, 1, 0, 1, 1],
 [-1, -1, -1, 0, 1, 1, 1]]

Success!

You might say this is a waste of time since you figured out the problem in your head. Good for you, but try this on for size:

1
[1, 1, 1, 1, 1, 1, 1, 1, 0, -1, -1, -1, -1, -1, -1, -1, -1]

Stuff from my Old Hard Drive

I don’t usually keep a lot of files around. When I get a new computer I don’t tend to copy all my documents across – anything I haven’t looked at for a couple of months is probably not worth the fraction of a millimetre it takes up on the platter. On the other hand, some things I can never bring myself to delete. Here is something I rediscovered the other day:

This is one of the first MODs I wrote back on the Amiga. I never had a sampler or a very large collection of instruments, but I loved mucking around with MED trying to get a pleasant sound out of the 4 channel 8-bit sound. It is often said that there is a lot of crossover between programming and music, and the soundtracker clones of the 90s made that explicit which is possibly why I enjoyed it so much. Now days I can fire up GarageBand any time I want with any number of sampled instruments. I could say that I regret not having the time to produce music as an adult but the truth is that the inspiration isn’t there any more – my interests have moved in other directions.

Although none of my MODs ever sounded anything like as good as the music from the games and demos of the time, I am still pretty pleased with this one. It must date from form 6 (I was 16) which makes it vintage 1991. Listen to the sound of 20 years ago…

Jungle Drums MP3
Jungle Drums OGG

What I Did on my Holidays – Labour Weekend 2011

I have lived in Auckland for 14 years and never been further north than Waitangi. A trip north was long overdue.
Looking over the Hokianga Horbour towards the giant dunes
This is the view from Opononi, looking across the mouth of the Hokianga Harbour towards the giant dunes. For $25 you can catch a water taxi to the other side where you can get dropped off with a board perfect for sliding down the steep banks. It sounds painful, but the sand is very soft and you can easily control your speed if not direction.

On a whim, we went to a slightly out-of-the-way shop called Labyrinth Woodworks & Maze (that isn’t a link, it’s a time corridor back to 1996) which turned out to be quite a find. It is a small building filled with the most amazing collection of puzzles and brainteasers I have ever seen, curated by a very passionate puzzle-lover who was only too keen to demonstrate his wares.

A small Japanese Puzzle BoxI have wanted a Japanese Puzzle Box ever since I saw one in a book when I was a child. Now I have one – it takes 10 cunningly concealed steps to open. If I ever go back to Labyrinth Woodworks I will buy the deluxe 21 step box.

Down the road a little way is Waipoua Kauri Forest, home to some very large trees including Tãne Mahuta, which is very, very large indeed.
Tane Mahuta
This is a terrible photo-montage I stitched together using Hugin, it in no way conveys just how big this tree is. I kept expecting a bunch of blue-skinned Navi to show up to defend it.

Sunday night was spent in Doubtless Bay, which was also very nice but not quite as wild and interesting as the west coast. We did take the time to visit Cable Bay, a beautiful beach with pink sand. It is supposed to be packed in Summer, we found it almost deserted (which suited us just fine.)

Full of Piss and Vinegar

I don’t usually pay much attention to the big NZ political blogs. At best, the usual suspects are occasionally insightful, but more often they suffer from varying degrees of simple minded egotism and/or outright vileness. However, like the million monkeys writing Shakespeare that they as a group resemble, every so often someone hits one out of the park:

It’s hard work at the best of times for political parties to attract good candidates. But it’s doubly so for the two main parties, because all the smaller parties are so quick to secure the urine-drinking bank-robbing identity-thieves, leaving National and Labour only the boring and sensible candidates to choose from.

Apart from the woman-bothering expense-rorting ones, those who end up in Parliament for the Nats or Labour often lack colour, but that’s probably because they’re not drinking their own piss

The rest of it is well worth reading as well.

This election is going to be like the Rugby World Cup – pretty much a foregone conclusion but the also-rans will provide much entertainment.

Book Review : House of Leaves

House of Leaves By Mark Z. Danielewski

A young man named Johnny comes into possession of a large cache of papers written (or dictated) by a elderly, blind and recently deceased man. The papers make up a nearly complete book, and Johnny devotes his live to putting it all in order. The book the old man was writing is an analysis of a film, The Navidson Record, a documentary about the strange goings on in a family home that is much, much bigger on the inside than its exterior walls can possibly encompass.

Most of the text of House of Leaves is from the old man describing the film (which, being blind, he has never seen) and adding his ridiculously footnoted academic criticism over the top. Despite being fascinated, Johnny, as self appointed editor, feels free to add his own rather more sarcastic and down-to-earth commentary on the plot, as well as long passages documenting events in his own life. Compiling the old man’s notes is taking a toil on Johnny’s mental state, and his additions get more disjointed and alarming.

House of Leaves is a hard book to pin down. The story within a story that The Navidson Record supposedly tells is a fairly standard horror tale of a spooky house, but it is filtered through at least 3 unreliable narrators before we find out anything. Johnny points out that many of the old man’s references are completely made up, and the film possibly never existed. But Johnny himself admits to the reader that he is an expert liar and occasionally adjusts the text. The appendix is filled with “supporting documents” that obscure things every further.

The format of the book itself is worked into the story. Like the house, the interior of the book is slightly too large for the cover. During the more weird passages the flow of text breaks up as paragraphs flow at weird angles or jump across pages at speed. Parts of the text are struck out (Johnny explains that the old man deliberately blotted out some pages with ink) leaving us to guess at the contents.

Parts of the book are incredibly funny, excellently parodying dry academic criticism. The plot of The Navidson Record itself is suitably creepy. Johnny’s tale of woe is a very dated I-take-drugs-and-fuck-a-lot-of-strippers-but-I-really-don’t-enjoy-it first-person narrative that just screams 90s fiction, but the fact that he is probably lying to the reader about much of it makes it a little more interesting. If nothing else, House of Leaves adds a little mystery into what can be a very obvious genre.

Recommended, I think