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?

Google AppEngine

Wednesday, April 9th, 2008

Yes, everyone else has blogged about it, but I figured I would too.

I’ve had a long interest in python, and now at my new job I’m able to occasionally write some python scripts, as well as working with one of the best python programmers I’ve met, who introduced me into the London Python Developers meetups.

Anyway, since then I’ve been increasingly interested in django. as a web project I’ve wondered how appropriate it would be to develop an MMOG in Django, but I’ve been held back by not wanting to spend extra money on django hosting.

The good news is that Google’s AppEngine is free for small to medium traffic and datastores, and reading the license appears to have no issues with you using it for commercial purposes, and it uses a modified version of the Django framework. (Modified because it uses Google’s BigTable rather than a full relational database)
I’ve signed up for a beta account, but am on the waiting list, if I get an account I’ll try to create a basic MMO in it and let you know how it goes.

For web based independent games creation this could be a lifeline, providing free or cheap hosting. From now on you’ll be writing your high score tables in python on Google’s servers I’ll bet!

A life of quiet desperation

Monday, December 3rd, 2007

I read PostSecret, and it often makes me realise how many people out there are leading lives of quiet desperation, lives where they have questions, or just don’t know what to do.

My aim in making games is to provide people with something to do, something to give people a respite from that life, and to escape somewhere better. Maybe even a place where they can explore some of their issues.

What are you making games for?