There has been some criticism of the new design; visually, I think it looks great, but then I've always enjoyed websites that are clean and simple and uncluttered. My biggest complaints with the old design were that the masthead looked too busy, and there wasn't enough white space; both of these issues have now been addressed. (Although can we have the logo back in colour? Pretty please?)
The biggest advantage to the new site is with the outside links to other articles. Previously stuck in a sidebar to the right, they are now fully integrated into the main article listing - making them easier to see immediately, and also allowing comments. This clearly makes the site easier to run, and Chris Williams has made no bones about the fact that if the site was to return, it needed to take up less of his time. (Co-running a couple of websites myself, I fully sympathise.) This redesign solves that issue - now an interesting link can spark off a decent discussion rather than a full article, and the fact that a lively commenting community can fill in the gaps and make people come back to the site is vital when a site-runner is short on time. Moreover, there's also still room for full Drobe articles when time allows. A win all-round for everyone - or, at the very least, the best everyone was going to get in the current climate, as a return to numerous full-length updates from Drobe seems unlikely at this point.
I also personally like the disappearance of the comment and user ratings - I never found them especially helpful, and at times they almost felt like they were inviting trouble, rather than alleviating it. Maybe they'll come back in a future update - the launch article says some missing features are due back soon - but I really hope they don't.
Any bad things? Well, I can't say I like the linking of the headline of the launch article to an email address - I don't want my email client appearing unless I specifically want it to, and I don't really feel like having to check the browser status bar before clicking on every link. (I generally solve that issue on my websites by only linking email addresses to actual visible email addresses - but then I am a bit of a boring bastard.) Still, I don't expect this to be a major issue - most headlines will link to external articles or actual Drobe content, rather than email addresses.
A bigger disadvantage is the addition of threaded discussion. I've never liked it on websites, as I find it easier to follow all new comments on a discussion at the bottom of the page, rather than having to glance right through the list of comments. This is a personal dislike, though - many people love threaded discussion, and it does have its benefits too. It's certainly not something that would be easy to allow users to switch on and off - threaded discussion discourages the quoting of the previous comment, and so allowing users to switch it off would quickly render some comments unintelligable.
Still, overall, it's a great redesign. It would have been easy to give up on the site completely, or have unrealistic expectations of how much time you would actually be able to spend on the site to keep it running properly. The new look allows the site to be quickly updated, for commenters to keep the site interesting with new discussion - and also allows full articles to be posted as and when time allows. It's just great to have Drobe back again - hell, I haven't used RISC OS in ages, but I still drop in, because there's usually stuff worth reading there, external link or not.
And that bloody awful creased paper background has gone as well. Result.
On a TIB note, the irony is not lost on me that this is only the sixth article we've actually published on here this year. The idea of us being qualified to comment on how another site does is slightly laughable, admittedly. So feel free to laugh away - although we should have a fourth installment of our Building the Dream articles up soon.
There has been some criticism of the new design; visually, I think it looks great, but then I've always enjoyed websites that are clean and simple and uncluttered. My biggest complaints with the old design were that the masthead looked too busy, and there wasn't enough white space; both of these issues have now been addressed. (Although can we have the logo back in colour? Pretty please?)
The biggest advantage to the new site is with the outside links to other articles. Previously stuck in a sidebar to the right, they are now fully integrated into the main article listing - making them easier to see immediately, and also allowing comments. This clearly makes the site easier to run, and Chris Williams has made no bones about the fact that if the site was to return, it needed to take up less of his time. (Co-running a couple of websites myself, I fully sympathise.) This redesign solves that issue - now an interesting link can spark off a decent discussion rather than a full article, and the fact that a lively commenting community can fill in the gaps and make people come back to the site is vital when a site-runner is short on time. Moreover, there's also still room for full Drobe articles when time allows. A win all-round for everyone - or, at the very least, the best everyone was going to get in the current climate, as a return to numerous full-length updates from Drobe seems unlikely at this point.
I also personally like the disappearance of the comment and user ratings - I never found them especially helpful, and at times they almost felt like they were inviting trouble, rather than alleviating it. Maybe they'll come back in a future update - the launch article says some missing features are due back soon - but I really hope they don't.
Any bad things? Well, I can't say I like the linking of the headline of the launch article to an email address - I don't want my email client appearing unless I specifically want it to, and I don't really feel like having to check the browser status bar before clicking on every link. (I generally solve that issue on my websites by only linking email addresses to actual visible email addresses - but then I am a bit of a boring bastard.) Still, I don't expect this to be a major issue - most headlines will link to external articles or actual Drobe content, rather than email addresses.
A bigger disadvantage is the addition of threaded discussion. I've never liked it on websites, as I find it easier to follow all new comments on a discussion at the bottom of the page, rather than having to glance right through the list of comments. This is a personal dislike, though - many people love threaded discussion, and it does have its benefits too. It's certainly not something that would be easy to allow users to switch on and off - threaded discussion discourages the quoting of the previous comment, and so allowing users to switch it off would quickly render some comments unintelligable.
Still, overall, it's a great redesign. It would have been easy to give up on the site completely, or have unrealistic expectations of how much time you would actually be able to spend on the site to keep it running properly. The new look allows the site to be quickly updated, for commenters to keep the site interesting with new discussion - and also allows full articles to be posted as and when time allows. It's just great to have Drobe back again - hell, I haven't used RISC OS in ages, but I still drop in, because there's usually stuff worth reading there, external link or not.
And that bloody awful creased paper background has gone as well. Result.
On a TIB note, the irony is not lost on me that this is only the sixth article we've actually published on here this year. The idea of us being qualified to comment on how another site does is slightly laughable, admittedly. So feel free to laugh away - although we should have a fourth installment of our Building the Dream articles up soon.
Although this article could just be dismissed as me blowing my own trumpet, I'm hoping that it will serve a somewhat more useful purpose. Before, during, and after working on the map generator I've searched the Internet for examples of similar generators and failed to find any. Sure, there are odd bits and pieces - descriptions of simpler generators that have given me ideas on some techniques to use, or screenshots of sexy work-in-progress realtime generators, but no actual algorithms or code samples from generators that come close to the required complexity of my generator.
So hopefully this article will become a useful reference point for anyone else wanting to undertake the task of writing a city generator, whether they're targeting a grid-based world representation like mine or a vector-based one.
Apart from discussing the algorithms used in the generator (and why they're used) I'll also talk about the data structures that are used - so even if you're not interested in random map generators you should be able to find plenty of examples of uses for the data structures covered in the first Building the Dream article, as requested quite some time ago.
Why random?
This is the first question I asked myself - and the first question you should ask yourself if you're planning a random map generator (or any other kind of procedural content, really).
Figure 1
The Vice City map from GTA 1 - would you want to create a map as large and detailed as that? (Click for larger)
Although writing a map editor would probably take less time and effort than writing a map generator, I decided to go down the generator route. This is because I've tried creating a city by hand before, for GTA 1, and know that it's a lot of hard work. I'd be constantly scrutinising the map, wondering if two adjacent buildings are too similar to each other, or whether the road layout of the map feels right, or whether there's too much or too little detail in a certain area. And every time I need a new unique building for a mission I'd have to go back and rip an existing generic building out - potentially changing the layout of large areas of the map in order to make it fit correctly. So although writing an editor would be quick and easy, creating the maps would likely be not.
However a map generator, although it would take a certain amount of time and effort to get working right, could potentially spawn millions of detailed maps just at the click of a button, with minimal effort on my part to feed the generator with input parameters. This would be particularly useful since at the time I started I also had no idea exactly how many maps I wanted the game to have.
As an added bonus, writing a random map generator would also be a hell of a lot more interesting than a boring old level editor.The goal
Figure 2
Liberty City from GTA 1, rendered in full 3D with the Junction 25 editor. (Click for larger)
In the interests of keeping things simple and not reinventing the wheel, the DeathDawn map structure is based around that of GTA 1. GTA 1 was capable of providing large cities (about 1km square) to the player, using under 500K of storage for the map itself. Each city consisted of a set of cubes arranged in a 256x256x6 grid. In real-world terms the length of the side of each cube is around 4m (or at least that's the length I've based DeathDawn around). The cubes were fairly limited in what they could do - you could specify the textures of the 5 visible sides, and the slope of the top surface - but that's about it as far as architectural details go. In addition to the visible features of the map there were also certain invisible features - such as the content type of the block (solid, air, or water), and how the AI should behave (whether it's pavement and should have pedestrians walking on it, or whether it's road and should have cars drive along it - and in which direction). Uncompressed this data could easily be 6 or more megabytes in size, but by relying on the fact that most blocks are identical, and many vertical stacks of blocks are identical, the size can easily be reduced to under 500K, leaving much more space for textures and sound effects.
Although DeathDawn's map format is slightly more advanced than that of GTA 1, the goals are pretty much the same - for the map generator to produce a map typically 256x256 block-stacks in size, with as much building detail as possible, and with the right AI flags to allow for pedestrians and cars to spawn and find their way around the map. The generator should also be capable of producing any secondary data needed - such as the locations of traffic lights, train tracks, and the territories of the different facitons. It should also be able to add specific buildings to the map at the demand of the mission script, so that missions can use unique buildings if they want.Evolutionary development
Figure 3
Sample output of the MK 1 generator (Click for larger)
The MK 2 generator was designed as a partial restructuring, partial rewrite of the MK 1 generator, in order to solve all of the major bugs as well as provide scope for the addition of new features - such as hills, bridges, train tracks, and the mission buildings. Although the MK 2 generator managed to fulfil most of these goals, several design flaws became apparent during its implementation, the most important of which was that there was no way of guaranteeing that the mission buildings that were requested actually made it into the map.
And so the MK 3 generator was devised - a reordering of the stages the MK 2 generator goes through, in order to ensure as best as possible that the mission buildings will actually be placed. Plans are also being made to improve the MK 3 generator further, in particular to improve the level of detail and placement of regular buildings.
Note that the DeathDawn source code currently available on my site contains the source for the MK 2 version of the generator; however by the time this set of map generator articles is complete I'm planning on having the latest version available for your viewing (dis)pleasure.Overview
Figure 4
Sample output of the current MK 3 generator (Click for larger)
For this first article about the map generator, I'm going to be talking solely about the data structures that are used. Understanding the data structures is vital to understanding the flow of the generator as a whole. Later articles will go into more detail about each stage of the map generation.
If you're put off by all these wordy descriptions, don't worry, because there's a few diagrams at the end showing how everything fits together.The layer structure
First off there is the layer structure. This was introduced in the MK 2 generator as a way of tieing together various variables and structures that the generator uses.Aside: Why use a linked list and an array at the same time?
Throughout the code there are two basic ways in which the collection of cblocks are accessed:
Each cblock represents a city block; i.e. a plot of land with one or more buildings inside it, and surrounded by pavements and roads. Currently only one building is placed in each cblock, but this will likely change with the MK 3+ generator - take a look at figure 4 and you'll see how much empty space there currently is inside each city block.
typedef struct _cblock {
rect r;
rect br;
gdll *neighbours;
gdll_item *i;
zonedef *z;
struct _layer *l;
builddef *b;
int msi;
} cblock;
The edge structure is used to link neighbouring cblocks together, and dictates the locations of the roads and paths that run through the city.
typedef struct _edge {
gdll_item *a,*b;
corner *c,*d;
int type;
int weight;
short clip,dlip;
} edge;
As their names suggest, corners are the places where edges meet.
typedef struct {
struct _edge *edges[4];
short x,y;
int visited;
short w,h;
struct _layer *l;
int type;
} corner;
If all those data structures are confusing you, then perhaps these diagrams will help. Figure 5 shows how the different data structures fit together to represent different parts of the city. Figure 6 shows the actual relationships between the different structures, from the datas point of view (i.e. what pointers point to what).
Figure 5
How the data structures represent the city
Figure 6
How the data structures are related in code
The next article, due shortly after judgement day, will take a look at what constituted the MK 1 map generator - i.e. the city block placement, edge and node linking, and road weighting stages of the generator. If there's space I may also describe the algorithm used to paint the road navigation flags for the intersections.
The final episode airs on August 22nd at 7:30pm on Five. Go on, guess what it's about.
The final episode airs on August 22nd at 7:30pm on Five. Go on, guess what it's about.