Bad typesetting
November 28, 2006
While I’m on the subject of writing, I thought I’d sneak in a note about typesetting. I’m a closet typesetting geek; you probably have to be to care about whether to use an en-dash or a plain dash to separate ranges of numbers, for example. In case you’re wondering: use an en-dash—the difference is appreciable.
There are some beautifully typeset books (TAOCP, for instance) and some really atrocious ones. One of the worst offenders is Just For Fun; Linus Torvalds’ autobiography. Its constant changing of fonts, font weights and styles appears to be the work of a rabid monkey on acid rather than an actual human typesetter. It’s headache-inducing at best, and very nearly made me put the book down and not finishing it.
Now, what this typesetting did manage was to make me remember the book. Unfortunately the only thing I can remember is that the typesetting was excruciatingly bad. From this I infer that the content wasn’t all that great, but that’s a blog post for another time.
I don’t quite know what came over me, I just needed to get this rant off my chest. My usual happy & chirpy tone will resume shortly.
Punctuation geekery
November 28, 2006
I must confess: I’m a bit of a punctuation geek. And no, I’m not referring to how missing or erroneous apostrophes leap out at me with such force that I immediately rush to enlighten the author of the offending text. Although they do that. Sometimes, however, I manage to suppress the urge to correct and just point and laugh instead. Alas, it is of my penchant for em-dashes, en-dashes and semicolons I speak; what is more, I know how to use them all correctly.
Personally I find that use of the em-dash and semicolon can lead to more naturally flowing and easily-read prose. However, I’ve often heard the opposite—even to the extent of an author being praised for writing a book without a single semicolon in it. (It turned out this was because his typewriter didn’t have one, otherwise he would gladly use it.) What say you, astute readers? Are semicolons and em-dashes an abomination? Do they impair reading? Answers in the comments please…
25 most played
November 28, 2006
Having realised that I almost exclusively use iTunes for listening to music, I’ve gone through my CD collection and ripped them at higher quality. You’d think this would use a lot more disk space, but it’s actually not very bad; I’ve taken the opportunity to go through and remove duplicates, which help.
I also had a look a playlist I’ve not noticed before—I cannot even remember if I’ve created it, or it’s some iTunes default list. At any rate, the list contains the 25 most played songs in my collection, and it is an interesting mix. The list contains: A Perfect Circle (8 songs), Anneli Drecker (1), Björk (4), Massive Attack (1), Paradise Lost (1), Tool (3), Ugress (4) and Vanessa Carlton (3).
Björk managed to slip four songs into my top six—very impressive. Jóga is in first place, followed by Play Dead; the fifth entry has Venus As A Boy, and Hunter takes sixth. What I find really peculiar is that while I like most of the work by the rest of the artists in this list, those songs by Björk are actually the only ones of hers I like. At all. It really is a love/hate relationship.
I was going to link to all the artists’ web-sites above, but showing my hippy nature (again—this is getting embarrassing) I chose to link only to Ugress because they have several songs available for download on their site, free of charge. Also, it’s not a crappy Flash site that invariably requires Flash version N+1, where N is the version you currently have.
Playing at the edge of AI
November 24, 2006
Reading Blondie24, where I got the title of this post from, got me exited about neural nets and genetic algorithms again. I always did found them fascinating, but I didn’t really have any practical use for them myself—until now.
My goal for the Cocoa games project, and ggtl before it, has always been to make building of decent computer game AIs very easy (for two-player zero-sum perfect information games, at least, which is actually a rather large group). My focus has been on the scaffolding—encapsulating the Alpha-Beta algorithm and letting developers focus on implementing its key components: detecting legal moves, applying a move to a state, and the evaluation function.
While the first two are quite uninteresting (they’re just game-specific scaffolding), the evaluation function is what really makes or breaks the resulting AI. Given an arbitrary state, this function must determine its fitness; how good or bad the state is. If you are an experienced player you might instinctively know if a given state is good, but it may not be a simple task to translate that to computer code. While computer games AIs have traditionally relied on exploiting knowledge provided by human experts, David Fogel and Kumar Chellapilla set out to see if they could create a program that could learn to play checkers on its own. To achieve this they used a genetic algorithm to evolve a neural net which they used as their program’s evaluation function.
David and Kumar were remarkably successful: Blondie learned to play checkers to a human Master level. If I could reproduce their results in a way that would work for a broader range of games, my goal of making board-game AI creation very simple would be largely achieved.
Fast forward a few months. I have implemented a neural net evaluation function for my Connect 4 game. The net is somewhat simpler in construction than Blondie’s, though I copied the techniques used for evolving it straight from the book. After 25 generations I stopped the evolution and played a game against the best neural net so far; it beat me hands down. Unfortunately, after 100 generations my best neural net still haven’t been able to beat the hand-rolled evaluation function I wrote for the game originally (I must have had a stroke of genius back then).
This is where I am currently at. I don’t want to release a game with an AI inferior to that in the previous version (it is available from subversion though), and I am currently experimenting with a few possible ways to improve the training of the neural net. Rest assured any progress I make will be the topic of future posts.
Development blog
November 23, 2006
I’ve started a new blog, skuggdev, in which I’ll post more development-related things. This should mean that this blog will contain less of that type of information. I dropped this experiment.
I’ve not decided yet if I should migrate some of the development-related posts in this blog over to the new one. What say you, my dear readers[0]? I’m terrible at making these decisions. Answers in the comments, please!
[0] My RSS stats says there’s enough of you to use the plural form… Get off my back already!
Generating bar charts with SQL
November 23, 2006
jerakeen pointed me to a post showing how you could Generate Simple Bar Charts From a MySQL Prompt. It’s a neat trick for quickly getting a feel for the distribution of values in a database. The post is MySQL centric, but you can do the same thing in any database. PostgreSQL’s REPEAT is very particular about being passed an INT, however, so you may have to cast the second argument:
SELECT foo_id, REPEAT('#', COUNT(*)::INT) FROM bar GROUP BY 1;
Perl testing trick
November 23, 2006
Have you ever found yourself creating a t/lib directory for modules used during testing? I know I have. Sometimes it’s tempting to just put these modules in your regular lib directory, to avoid cluttering your test files with boilerplate (say t/lib/Foo.pm is the test module you want to load):
use FindBin qw( $Bin ); use lib "$Bin/lib"; use Foo;
Here’s one solution: bastardise the name of your test module somewhat, and you can cut those three lines down to one:
use t::lib::Foo;
Perl will search for modules in the current working directory and will find your test module. The added benefit this has, of course, is to make it abundantly clear that this module is there for testing only.
Tax joy
November 21, 2006
Sometimes it is nice to get letters from the tax man. The letter I got today, for example, was very welcome. I’m sure the cheque of £1544.96 it contained had nothing to do with it. Nothing at all.
Cats and dogs
November 16, 2006
So somebody pointed me at a story in the Daily Mail, about a cat breeding with a dog. As you can imagine, it is high class literature. One of the comments amused me though, saying: think about the possibilities! So I did. And I’ve come up with one. Imagine, dogs that hide their shit like cats do, instead of shitting all over the pavements. The pavements and side streets I walk to work are a regular minefield; I have to walk with my eyes glued to the ground to avoid stepping in turds every few feet.
Increased congestion charge for “gas guzzlers”
November 14, 2006
Hurrah! The Mayor of London wants to increase the congestion charge for cars in carbon emission band G—so-called “gas guzzlers” or Chelsea tractors—in addition to withdrawing the 90% residency discount, for people living within the congestion zone, for such cars. From the article:
“Most vehicles that will be charged £25, in vehicle excise duty band G, are high-priced models,” the mayor said.
“Those who buy them can afford to choose from pretty much the whole of the mainstream car market but have chosen to buy one of the most polluting vehicles.”
As an added bonus the congestion charge will be lifted for cars in band A and B, which produce least carbon emissions.