Archive for the 'Misc' Category

Twitter

Monday, April 28th, 2008

So I’ve gotten a twitter account (twitter.com/mibgames if you care) and I’ve noticed a couple of things.

I get followed occasionally by a complete stranger, and I look at their profile.  Some of them are following nearly 2000 people.  Surely that defeats the point of twitter?  I follow only people I either personally know, or people I admire in the podosphere and feel they might say something interesting. But other than that I’m only interested in kearing what interestng people have to say.

Secondly, Twitter came up trumps the other night on Launch night at the Guardian.  We had a question that we couldn’t answer, and were worried about something.  I twittered to one of the devs on the team, and lo and behold 5 minutes later he walked into the office to find out what we wanted.  It turned out he was in the pub just down the road, and got my twitter so popped in to see if he could help.  It was a moment that I don’t think I’ll ever forget.

Non greedy matching in vim

Wednesday, April 16th, 2008

If you want to match something in a line in vim, and have had problems.

Something like

aaabccbaaaabccbaaabccbaaaa

and you want to extract the first bccb from the string and replace the line with only the match. (say getting the link portion of weblinks from some source html)

you would be forgiven for doing

:s/.*b(.*)b.*/1/

Thats what I did and to my suprise it provided me with the equivalent of ccbaaaabccbaaabcc

The reason for this is that the b at the end of the match matches the last b in the string, and the .* is greedy and matches as many characters as it can.

The answer is to use the magic \{-} match, this does the same as * but means do it with a least matching algorithm.

:s/.*b(.{-})b.*/1/

does exactly what I expected, returning cc for this line.

Web MMO - Defining the map

Sunday, April 13th, 2008

My current technical challange is how to define the map. I’m not entiurely decided what is going to be the most efficient method for doing so.

If this was a desktop game, I would have a map structure that kept track of the terrain and any strange features, but didn’t keep track of objects, creatures or anything else. Instead I would have a dictionary of location coordinates to lists of objects, so to draw a map location we would do something like…

drawTerrain(Location.all().filter("coords =",xy).get().terrain)
for object in Object.all().filter("coords =",xy).fetch(100):
drawObject(object)
for creature in Creature.all().filter("coords =",xy).fetch(100):
drawCreature(creature)

But I’m worried about the performance, as we would make three database calls there. On the other hand trying to denormalise a potential list of objects into the Location class seems to be excessively hard given the type restrictions on what can go into a BigTable (We’d have to use a list of Strings, and stringify each object / creature).

If I accept that the above code is the right way to draw the creatures and objects, I know we’re only doing 3 gets to the database. But we’re going to have to do that bit of code for every mapsquare that the user can see that we want to draw.

So if the user is at 8,3, we need to draw the squares [(7,2), (8,2), (9,2), (7,3), (8,3), (9,3), (7,4), (8,4), (9,4)] at least, and that assumes we dont also draw every square that the user has visited. To get the terrain information for each square at least will require 9 database calls.

So how to denormalise it? Well I think I might have a solution, although it may be ugly. If I split the terrain into say 5×5 blocks, so each block fo 25 tiles is a single super cell, I can store the terrain as a fixed width list or string, so Cell 1 has the terrain list of [1,1,1,2,2,1,1,2,2,3,1,1,2,2,2,1,1,1,2,1,1,1,1,1,1] which if laid out looks like

[
1,1,1,2,2,
1,1,2,2,3,
1,1,2,2,2,
1,1,1,2,1,
1,1,1,1,1
]

So now, to get the terrain information for a single location, we only need to load up our cell, and then index into the cell a number of times.

You see this sort of thing happen in real 3d MMORPG’s where it is called Zoning. Our worst case scenario is that the user is at one of the corners of a Cell, in which case they can see into 4 cells around them. The bigger we make the cell, the less likely that becomes, but the more data we need to put into the database, which may not be a problem, but also the bigger memory footprint we need to get the data back out (costing time and memory when we do our actual get).
For this game, I think we are probbaly going to generate a fairly small island map, say only a few hundered squares wide and high, so cells of around 50 or 100 in width is probably around the right number, giving us tens of cells, but thousands of actual locations.

Recent command history

Friday, April 11th, 2008

mib@mibsvr01:~$ history|awk ‘{a[$2]++} END{for(i in a){printf “%5d\t%s\n”,a[i],i}}’|sort -rn|head
91   vi
86   ls
53   sudo
46   cd
44   python
43   svn
19   git
11   ps
10   rm
10   mv

mib@cathy-laptop:~  history|awk ‘{a[$2]++} END{for(i in a){printf “%5d\t%s\n”,a[i],i}}’|sort -rn|head
77   ls
47   vi
31   mplayer
25   cd
19   aptitude
18   sudo
12   cp
9   cat
9   ant
8   python

Dead laptop

Wednesday, April 9th, 2008

My laptop died last week.  Luckily someone here at work had an IDE to USB adapter, so I got all my data off, including the very important Jonathan Coulton videos from his recent UK show (Excellent).

So now I need to find a new laptop.  Given that I’m still on a budget, I need to decide between something like  the Dell Vostro 1000 or the eee.

With the Dell laptop, approx 170 +VAT +  50 Shipping, I get a 3GHz sempron, 1 gig of memory, 80 Gig hard drive.

But I’ve used my wifes laptop, which was similarly cheap, and it just feels like using the machine trhough treacle, and it’s heavy.

With the eee, I only get a 900MHz Celeron, 512M of memory, and a 4Gig flash drive.  But it weighs less than a kilogram, and is £215 picked up from toysrus. (Cheapest place I’ve seen it so far in Cambridge)

What to do?