« What The MashupMid-Week Rant »

ZooElite AI Development: R&R

03/01/10 | by Charlie [mail] | Categories: TTD AI

Rest and relaxation...oh I wish...nope, this time it's RAILROADS!!! Last time I showed you how we placed bus stations, this time I'm going to give you an inside look at where ZooElite decides to put railroad stations. This is all subject to change, but the general idea will stay the same. Full info after the jump!

...

So the first thing to note, is that I realized how awesome human beings are while attempting to do this. There is simply no way that an AI could ever plan a better station setup than I could. Here's one of my favorites from an old game:
Handmade Station
Now that whole mess is one station, and if you look, you'll see a lot of 90 degree turns, which isn't optimal...but I managed to get three different lines to converge in this little basin in between two cities. There is literally only one possible way to get this mess to work with all the hills and cities around.
When I first started working on building a station, I knew I had to give up hope on building masterpieces like this. What I did want, however, was a configuration that was flexible, reusable, simple and compact. In the end, I drew up two different station designs:
Terminus Setup

Pass-Through Station

Above is a terminus setup, and below is a pass-through setup. The difference being fairly obvious I hope. So the reason I chose these configurations is that they are pretty straightforward (Algorithmically) but also expandable. If we got lucky, these stations could both be expanded without destroying any existing track.

Obviously expanding isn't an ideal solution, so these stations are all built within a function which can take any number of platforms and platform lengths and create a similar station. The station will grow and shrink accordingly. So why not make a 10 platform station? Well the downside to the very, very large stations shown is that it will be hard to find a plot that large close to a city. Due to the complexities of sizing these stations, the search process is a little involved.

First, we start by establishing how large a plot we need. This can be quickly computed based on the number of platforms and lengths we want. Terminus stations automatically have bus stations attached to them. So in the end we need a plot equivalent to the red rectangle below:

Rail Plot Allocation

You'll notice that the Light Blue Box is the road infrastructure hookup leading to the city, and the yellow part is the rail hookup leading to the outside world. But the space that's in neither box still must be clear, even though we don't use it. In order to accurately determine usage, we'd need to evaluate each tile of each potential placement...which doesn't work terribly quickly. So I fudged it a bit.

Once we get rid of unbuildable plots, we still have hundreds of potential plots, so we score each of these placements on a variety of metrics. I.E. How much would it cost to level the plot, how close is the plot to the town, and how many passengers would the station itself pull? The last two are not always correlated, and are weighted differently to promote placing stations in between two close towns so that we can use one station for multiple cities if they are close. We then check to see if a vertical or horizontal placement is most efficient, and send the plot to be built on

What's cool though, is that once the plot is selected the algorithm will automatically try to face the station away from the city, because otherwise the tracks would be facing the wrong way and chaos would ensue. In the end, we have some rail station which is ready to accept passengers and send them out into the world:
Finished Setup

Hope you enjoyed that little overview of how stations are placed and built. There's a lot of little things to finish up now, and they aren't terribly interesting...but maybe we'll do a little update over break or have my partner tell you about his network planning algorithm (Which is REALLY awesome)...till then!

Permalink

No feedback yet

A collection of musings from my time at Yale along with some thoughts about my "Freshman year of life" in San Francisco.

Search

XML Feeds

powered by b2evolution CMS