Archive for October, 2010

Oct 24 2010

More comic generation work, finally

Published by Dougal under Programming

I’ve spent the last few days heavily reworking my comic book generation code in order to finally get over some of my conceptual and logistical humps. I’m not yet at the stage where I have redone all my undoing, ie I’ve taken the entire contents of the cupboard and spread it out across the floor in order to tidy up. :-) So it doesn’t compile at the moment.

Placing speech bubbles has always been the nub of this program and one that I’ve never satisfactorily solved. Last time I tried simulated annealing but was never able to come up with good heuristics to guide the evolution of a solution. I’ve still got the code, so I may experiment with it in the future if I have the inclination.

The current angle of attack is more straightforward. Speech bubbles can be placed at any point along a set of “arms” which emanate from the character. (I was actually thinking about the clip clock we have on our kitchen wall when I imagined this.) For simplicity’s sake the arms are the four compass points and their intermediate diagonals.

I’m then just searching through each speaker’s arms for the first valid position and trying again with the next speaker until all the elements in the panel are done. If at any point we can’t place an element I’m just backtracking: depth-first search on element positions.

I haven’t got to the stage where I can see output from this approach but there will inevitably be problems. The most obvious at the moment is that the search stops when all elements can be placed, rather than being in their optimal positions. As always it comes down to the thorny problem of teaching the computer what “optimal positioning of speech bubbles” actually means. And sadly I don’t have an answer, though every new approach I take results in some interesting ideas. This is inevitably what happens when you try to automate artistic judgement.

For now I will follow the worse-is-better dictum and stop fiddling with speech placement until the rest of it is in place. I’m currently looking at the next stage in the pipeline, putting the graphics together. As with all things graphics-related there’s a lot of fiddling with co-ordinates and printing out (x,y) values and munging in order that various primitives (drawing ellipses, rectangles, text) all work off the same origin. Hopefully I’ll soon have some clean abstraction so that the elements I want will be drawn where I want them. Til next time!

Comments Off

Oct 20 2010

A game of Global Microbiological War

Published by Dougal under Family, Reviews

It was Helen’s birthday two weeks ago and one of the surprise hits was a board game I bought on a whim, because the gaming style intrigued me. I haven’t been able to track down the original discussion again, but somewhere on Reddit there was a thread about Monopoly and a commenter suggested that (paraphrasing) “competitive board games are old, you need to get into co-operative gaming”. Into what?

The game recommended as a good example of this style was Pandemic, which I bought and I’m happy to say it’s brilliant. The rules seem very complex on initial read-through but they are very quick to internalise — everything makes sense and there were only a couple of occasions on our first game where we consulted the rules for clarification.

So what is it? The idea, contrary to most board games, is that the human players are working as one team, against “the game”. It’s still a turn-based game, but each person co-ordinates their behaviour with their fellow players. You play the game on a map of the world, showing a network of cities joined by air and road links. At the start of the game a selection of random cities are “infected” with four diseases (coloured cubes). The aim of the game is to discover a cure for these diseases before a critical proportion of the world is infected.

You discover cures by gathering resources together in one place, much like building houses and hotels in Monopoly. In order to stave off disaster you must travel the world treating disease victims until you have enough resources to find a cure — but every time you travel somewhere or treat a disease, you’re wasting time that might have been better spent on researching a cure.

And while all this is happening the diseases don’t stand still. Each time a player’s turn ends there is an infection stage where all the diseases that have taken hold will spread further. Every so often (more often if you’re playing by the difficult rules) an “epidemic” hits, which basically ramps up the danger level and reinfects all the cities you thought you’d treated.

The night after Helen’s birthday we invited Mat round for tea and then we made a valiant attempt at this game for the first time. We played three games that night with the “easy” rules and lost all three games. In the final game Helen had the resources ready for a cure, and it was my turn directly before her “winning” hand could be played. And I pulled an epidemic card which totally wiped us out. That was the closest we had come and the intensity of knowing how close we were to a cure was incredible. The feeling of co-operating against a stack of playing cards is a strange one but the rules are beautifully defined to simulate the ebb, flow and violent resurgence of infection counts so you quickly get immersed in the reality of the game.

I don’t know how much other co-operative games hit the mark but this one certainly does and I am really looking forward to getting another crack at it. It seems like there are a million games out there which don’t get the publicity of Monopoly, Risk and Cluedo but which are maybe more fun. I remember with great fondness the games of Settlers of Catan we used to have in the flat when I was in university. Then there is Mille Bornes, the 1000-mile imaginary race which is like a card-based version of Mario Kart. What crazy games have you come across that should be more widely known?

PS. I just came across this board game recommendation site which lets you enter games you like and one you dislike, and matches you up to user preferences on BoardGameGeek.com to select some likely interesting titles. I found out about it through this post by the developer, telling its history.

PPS. The line of the game for me was when Helen turned to Mat and said: “Are you Green? I’ll meet you in Cairo!”. It’s like being a jet-setting heroic scientist in your own living room.

3 responses so far

Oct 18 2010

Keeping moving and choosing a direction

Published by Dougal under Life

I saw The Social Network last night, a dramatised story based on the founding of Facebook. I probably wouldn’t have seen it without a push, though in the end I enjoyed it. I was worried it would concentrate a bit much on the lone-genius/American dream storyline, which gets a bit tedious after a while. The real story is always more interesting and nuanced than “man has idea, man implements idea, man makes millions”.

The actual story was told as a courtroom-flashback, through two different lawsuits that were brought against the main founder. There is a brief nerd-montage at the beginning of the film in which the protagonist pulls an all-nighter at the code face after breaking up with his girlfriend. This bit was… strangely enjoyable, and may even have made programming seem slightly fun to a lay audience, as the voiceover runs through the various means by which he swiped photos from the internal pages of Harvard’s house websites. Some of it was accurate, some of it was strangely divorced from reality. (I have never known an emacs user to actually shut the program down, never mind admit to something requiring a session in emacs. This is not how people talk! Next time you head outside will you think, “oh, we need more milk, I’ll need to spend another session in my shoes”?)

The film is not the point here, so if you want analysis wait for Nick’s 15 Word Review. The point is that I realised that (a) the excitement of programming has been missing for a while and (b) I’m not quite sure what I’m doing with myself these days.

Obviously, and foremost, I want to support Helen as she works her way through medical school. But that’s just a by-product and not something to do. Secondly I’d like to be happy doing whatever I’m doing. But what that whatever is I’m not really sure.

I read this post earlier today, about a programmer who has given up their job to travel around the US, blogging and coding and seeing the sights. Well that sounds really grand, doesn’t it?

Though to be honest a big part of the draw to me is the coding, and I’m not even sure why, because when I’m sitting on my own I find it difficult to work on some of my own projects. The idea of having such leisure time to just go off and travel without worrying about getting back to work or study is another good chunk of the attraction.

This paragraph in particular called to me:

I met a young man named Dustin, who shared his dreams with me. He comes from a family of cops but always wanted to be a schoolteacher — 7th grade science. For various reasons, Dustin never achieved his dream. It makes me sad to think about passions lost or ignored.

I’m not sure, though, what my passion really is, or what I’m hungering to do. I envy Helen her eventual discovery/admission of wanting to study medicine. Not because I want to be a doctor but because it seems she really has uncovered a passion which was obscured. By contrast, I am drifting, and mostly happy to drift.

After this page of fruitless introspection I think it’s time to counter with something positive. I’ve picked up where I left off with an old programming project, and I’m otherwise getting more stuff done during the day. Nothing outlandish, just little bits of housework, fixing things and generally interacting with my surroundings a bit more. It’s gotten much colder in the past couple of weeks, so keeping moving is becoming a priority. Here’s to keeping moving.

2 responses so far

Oct 16 2010

Some new timewasting opportunities

Published by Dougal under Blogging

It’s time to mention a few blogs I have been enjoying recently.

  • Emily did a fantastic post (with graphs!) about the minimum-alcohol-pricing legislation which is definitely worth a look. I’m a little bit disgusted at the way the newspapers have been flat-out lying about the effects this kind of legislation would have.
  • Someone’s lit a fire under Nick’s, uh, editor and he’s started posting like a fiend. Also he seems to be writing a development blog which generally makes for good reading in my opinion. Your opinions on the matter may vary. The new stuff starts here where the long-dormant Clockwork Aphid name is revived. A long time ago I even made a clockwork aphid logo, so I’ll see if I can root it out and donate it to the cause.
  • Ben Lippmeier has also started a development blog for DDC, his strict variant of Haskell. I enjoyed following his deep-dives into the bowels of GHC while porting it to SPARC so this one should be interesting.

Comments Off

Oct 14 2010

More Napoleonic military stories

Published by Dougal under Books

This month’s book group find was A Close Run Thing, the adventures of Cornet Matthew Hervey of the 6th Light Dragoons during the events of the Napoleonic War(s), particularly Waterloo. Hervey comes across as a nice person, what Sharpe would refer to as a killing officer, not a murdering officer.

It bears a lot of comparison to Sharpe, except Hervey is a proper bastard officer rather than a soldier raised from the ranks. Hervey is the most junior officer in his regiment, but as is customary for this type of novel he excels himself and is frequently highlighted to the senior commanders for promotion. But since Hervey is the son of a country vicar, and therefore not very rich compared to many of the other officers, a lot of the book is concerned with the commission system, and being able to afford a promotion that is offered.

He also dwells a lot on duty, especially in his brief stint in Ireland where his role appears to be military muscle to allow factors to throw people off the land. He gets in a bit of trouble for being a gentleman rather than a thug, though it all works out in the end. He’s a quick lad though somewhat dim when it comes to affairs of the heart.

The story was fairly easy to follow though the occasional deep-dive into horse terminology left me a bit lost. Still, as long as you basically know what a horse is you can follow along reasonably well. It’s not a very action-packed story, as it basically spans the last battle before Napoleon is exiled to Elba, and the battle at Waterloo after his return, and the period of peace-time in the middle. So the middle chunk is Matthew Hervey in England and Ireland, not officially at war. I’ve not read Sharpe or Hornblower, only seen the TV adaptations, but I get the impression that they tend to be more action-packed than this, or at least more intriguing.

Comments Off

Oct 13 2010

Mysterious cakes with cryptic messages

Published by Dougal under Baking, Family, Food

It was Helen’s birthday last week and, as per tradition, she took cakes to work her tutorial group at university.

She was too busy studying so I made the cakes (this was okay, as in recent years she has ended up making cakes for me to take to work on my birthday, so this was repaying the favour), and had a bit of fun with them.

I had been following one person’s escapades with baking cakes inside cakes, such as brownie inside muffins (really) and thought I would take a first foray in that direction. I made some fairly plain cupcakes but buried some chocolate balls (slightly larger than a malteser) inside each one. The chocolate balls were Hallowe’en treats that each came individually wrapped in “eyeball” tin foil. Then when I was trying to work out how to ice them Helen suggested using icing pens to write on them. Then she went to bed and I sat down to work some words out.

Eyeball Hallowe'en chocolates

My first thought was to take Word of the Day for Helen’s birthday for the last ten years (I had ten cakes to decorate) but I couldn’t easily find a list going back that far. The easily-searched sites (like wiktionary) weren’t established long enough to have ten years of archives!

My second thought was nonsense words, and this was even harder. I would have to look through the published works of Lewis Carroll and Edward Lear in order to find some really good ones. Good nonsense words, ones with a nice feel and pleasing sound, are harder to find than you might think.

In the end I settled on cake words. What I actually did was search the installed dictionary for some nice cake words, and then fill in a few more from memory. (I didn’t like griddlecake or coffeecake and thought the latter should probably be two words.)

$ grep cake$ /usr/share/dict/words
cake
cheesecake
coffeecake
cupcake
fruitcake
griddlecake
hotcake
pancake
shortcake

Once I had my words I removed the cake part and iced the remaining prefix/suffix onto each bun. So I had a bunch of cakes with the words “pan”, “beef”, “short” and so on.

Decorated "cake" cakes

Now Helen tells me that when she opened the tin on the following day no-one could understand what these words meant. They sat and thought and came to no good conclusions, until someone finally said:

Well, I’m going to have the “beef” cake — oh

I was glad to have provided a little bit of mystery. :-)

One response so far

Oct 07 2010

Learn Web Development in PHP in 24 hours

Published by Dougal under Programming, Work

NB: I wrote this some time ago. I didn’t get through to the next round of interview.

I just spent the last ~24 hours writing the biggest chunk of PHP I’ve ever had to work with. This isn’t much of a record, as up until now I’ve never done any PHP/web work outside of the occasional excursion into the WordPress plugins to debug problems. So I went from no PHP experience to writing a simple web app, which gave me quite a feeling of accomplishment.

This was all part of an interview for IDE Group. A fortnight ago I went for an interview, and then they sent me a problem to code the solution for. The problem involved setting up a database for users and related data, querying and updating it via web forms and so on.

Since this was the first time I’d ever done something like this (ie web programming) it was a massive learning experience. Every few steps I rediscovered things, like the need for session management, or data validation procedures, or authentication processes, and so on. There were many many things that I just had to skip over for being too cumbersome to implement quickly — a proper DB schema with validating constraints rather than a jumbled mess, salted-hashed passwords in the database, web pages that conform to any standard, never mind a recent one. The list goes on.

But I tried to get the basics done. I specifically wanted to concentrate on security of the application, since that’s something which is important for the integrity of the application. I didn’t want Little Bobby Tables to make a mess of my database. To that end I was really limiting in what counted as a valid username/password character. I didn’t know how to properly validate password data so I went the route of only accepting alphanumeric sequences. Little Bobby Tables wouldn’t be able to sign up, but at least the DB should still be standing if he tries. The web page itself looked very 1994. No CSS for you!

I handed in my solution about a day after receiving the problem. I was worried that taking this long would count against me, but there was nothing I could really do about that since I didn’t have any experience in what I was doing. I spent a lot of time researching each step and a lot of time debugging because of complete unfamiliarity with the language. The problem statement suggested a couple of frameworks for “bonus points”, though I didn’t use them. I considered that learning how to set up, integrate and use two additional systems over and above what I needed to get the job done would really have killed me.

In hindsight it seems this was the wrong choice. I have since learned from the interviewer that other candidates took much longer (about 3 days in one case). My thinking at the time was that anyone who knew what they were doing would get the whole thing finished in a working day so I wanted to give myself no more than 50% over that. I didn’t want to hand in something really slick that took me a whole week longer than everybody else, so I erred on the side of speed.

In future maybe I will be less cautious about investing extra time, though maybe there won’t be a future. These programming problems don’t seem very common in the UK. Anyone else done this kind of “interview homework” problem before? I can see why they are useful but I can also imagine they would be impossible for someone in a full-time job.

Comments Off

Oct 01 2010

Potluck trials

Published by Dougal under Food, Life

We’ve been doing this book group thing for over a year now and one thing that’s become really obvious is the way that potluck events don’t scale. Or at least, the way we do them ends in tasty tasty disaster.

The problem is that each person brings a dish which is enough food for more than one person. Nobody wants to supply enough pasta salad for only two or three people if there’s eight people in the group. So each person caters for their own conception of the group. (Last time I made a dozen pretzels, because I didn’t want anyone to go without. But there’s a good amount of eating in a pretzel…)

If there’s three people and each brings enough for three people it works out fine. Each person eats a small portion of three different dishes. If there are six people each person will attempt to get six different portions onto their plate. Now a portion has a reasonable lower limit, and so people just end up piling their plates higher. They just have to eat more if they want to taste everything. Then there might be things which are just very tasty, and so people go back for seconds. I mean, it’s just sitting there in front of you, it would go to waste otherwise, starving children in Elbonia, etc.

And then you realise that some of the group brought chocolate cake, brownies, fruit pies and you haven’t even seen that stuff yet. Your stomach is folding around the edge of the table and you’re worried about being charged for two fares on the bus home.

So you have to exercise terrifying self-constraint with portion size or — gasp — not taste some of the dishes. Potluck events are a menace to waistlines and dignity everywhere.

5 responses so far