Skip to content

Instantly share code, notes, and snippets.

@kevinburke
Last active August 29, 2015 14:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinburke/11202552 to your computer and use it in GitHub Desktop.
Save kevinburke/11202552 to your computer and use it in GitHub Desktop.

RCT via Computer

The goal is to write a genetic algorithm that generates really cool looking Roller Coaster Tycoon coasters. Eventually you can optimize for various things

  • Coolest roller coaster that fits in some bounding box

  • Coolest roller coaster under $1000 in game money, etc.

Progress so far

  • I've written a parser for the TD6 ride file format used in RCT2, including a decoder for the custom run-length-encoding used by RCT2 to compress track files. This means I can load existing rides into memory in Go, and also see what parts are necessary for a ride.

  • I've begun work on serializing designed rides to disk, however it is a little complicated because there's an unknown checksum value attached to each ride.

  • I've read parts of the RCT2 exe binary to figure out how track pieces connect to each other - each track piece has flags like "this piece starts out on flat ground", "this piece ends with a left bank" etc. This work has gone into OpenRCT2. https://github.com/IntelOrca/OpenRCT2/commit/75dc8243c4c3bd6eccd92bc8dc6bbfde666299d9

  • A basic coaster drawing library.

WIP is here: https://github.com/kevinburke/rct-rides

To do

  • I need a way to visualize rides so I can see the progress of my genetic algorithm. Since I am completely unfamiliar with the graphing libraries involved (and graphing anything really) I have a 2D image viewer for viewing slices of a ride (currently, height over time). I'll need to implement some kind of isomorphic 3D viewer to get a sense for how "cool" the ride actually is.

  • I need a good fitness function. This I think will be the trickiest part. How do you encourage rides to be complete circuits, while also realizing that growing in complexity could take rides away from the end point?

  • I probably need to reverse engineer more data from openrct2.exe. I don't have any data about required headway for a track piece, or the physics engine.

  • I need to actually write the genetic algorithm components - mutate, crossover, etc.

    • For mutate, etc, how to decide which track piece to choose? For example, maybe there's less chance of randomly choosing a vertical loop and more chance of choosing a uphill or downhill.
    • If the mutation changes a straight piece to a curved piece, do I rotate all of the other track pieces (prolly away from the track's end), or put up with random discontinuities in the middle of the track?
  • I need to add collision detection and gravity checking, eg the ride can't go further uphill than it started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment