Hacking Roller Coaster Tycoon

Kevin Burke

@derivativeburke

12 Year Old Me

Author as a 12 year old

Goal - Build cool coasters via computer program

Might be tractable!

What is a cool coaster?

A really cool coaster

High Excitement/Low Sickness

Excitement/intensity ratings

How do you interface with the game?

Mario beating the game

How do you interface with the game?

Duck Hunt

Tracks are stored separately

Track designs are loadable

TD6 format

TD6 description
Source

Run Length Encoding

  1. Read a byte (x)
  2. If x < 0: Read next byte and copy it -1*x times.
  3. If x > 0: Read x bytes

Go Interfaces

Plan of action:

How to represent the track pieces?

Track Data (cont'd)

sawyer explains rct is in assembler

What is x86 assembler?

What is assembler cont'd

CPU registers + instructions

RCT Source Code

How do you find what you are looking for?

Link

OpenRCT2

Coming to a Platform Near You

NB: you still need the game assets

How do you test as you go?

How can you test as you go?

Call x86 subroutines

Finding Game Data - 2 Objectives

IDA Pro

IDA Pro

IDA (cont'd)

IDA Pro

Where Is Anything

IDA Pro

Track Data Has Consistent Order

Track Order

Track Formula

Good enough to make guesses

Guessing Track Data

Guessing Track Data (cont'd)

Guessing Track Data (cont'd)

Track guess table

A Good Guess

Too High Caption

A Good Guess

A Good Guess

A Good Guess (cont'd)

IDA Search screen

Rating Data

Rating Data

Rating Data

A Good Guess

Rating Data

Rating Jump Table

So what is "excitement"?

Excitement

Excitement (cont'd)

Intensity

Okay! Time to build an algorithm.

Pump the brakes

Track needs to be a complete circuit!

Complete circuit

Track needs to be a complete circuit!

Complete circuit
Source

Track can't collide with itself

Track can't collide with itself

This is a search problem

Analog = Protein Folding

Hard Math

Trim the problem space!

Using a genetic algorithm

Reproduction Strategies

Genetic algorithm cont'd

Goal: "Hello"

Starting Points

Evaluate Fitness

fitness("Lr2Kl")

How many characters would have to change?

fitness("HerKo")

How many characters would have to change?

Smaller distance from a "good" solution == better fitness

The fitness function is the most expensive part!

Algorithm

  1. Generate a random pool of strings
  2. Evaluate fitness
  3. Let the best ones "reproduce" & form next generation
  4. Repeat at (1)

Use track pieces instead of strings

Book - David Goldberg

Book

Selection

Mutation

  1. Generate random number for each track piece
  2. If random # < MUTATION_PROBABILITY
  3. Replace the piece with a different piece

Mutation (2)

  1. Generate random number for each track piece
  2. If random # < MUTATION_PROBABILITY
  3. Insert a new piece

Crossover

  1. Choose 2 parents via Select()
  2. Choose crossover point at random
  3. Return TrackA[0] + Track B[1]
  4. Return Track B[0] + Track A[1]

Crossover (2)

Occasionally, let the parents survive

Let's see it!

Generated Coaster 1

Generated Coaster 1

Generated Coaster 1

Partial coasters don't load

Lessons Learned

Data inconsistencies will kill you

Observance: Table driven tests

Table Driven Tests

Table Driven Tests (cont'd)

Lessons Learned

Future Work

Thanks to Kyle Conroy

Thanks!

Kevin Burke

github.com/kevinburke/rct

kev.inburke.com

kev@inburke.com

@derivativeburke


These slides are available at:

kev.inburke.com/slides/coasters

/

#