• Stars
    star
    124
  • Rank 288,207 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Creating cool coasters for Roller Coaster Tycoon

What is it?

The goal of the project is to generate cool looking roller coasters via a genetic algorithm. Something like this:

The coolest coaster ever

What's been done so far?

Here's what we have:

  • A list of all of the track pieces used in the game and metadata about them (elevation change, left/right etc)

  • A way to read rides from the game, and serialize track data generated outside the game to be used in the game.

  • Some library functions to make vector math easier (e.g. after this track piece, what is the new location and orientation of the car?)

  • A basic genetic algorithm with mutation, selection, crossover, and a fitness function.

  • Results of every experiment are recorded to disk. There's a server you can use to view the results of experiments, and which has an easy "convert to TD6" button.

What needs to get done?

  • Tracks currently don't load in the game because the collision detection algorithm isn't correct. The experiment runner will report 0 collisions, but tracks will fail to load because there is actually a collision. You can verify this by printing out the individual track pieces, starting the game and attempting to rebuild the track. I'm not sure how best to fix this than by attempting to fix individual instances as they pop up.

  • The fitness function does not have enough inputs. Specifically, it currently checks whether a track is a complete loop and doesn't collide with itself. It could check:

  • The fitness function is currently very slow. Need to run the code with pprof to figure out what exactly is slow, and then improve its performance. The existing code is extremely dumb - it runs sequentially in one thread. Likely there are some easy improvements to be made by using more than one CPU at a time.

  • The server can display track data but the camera is out of position, so sometimes the track is not visible. It would be really neat to be able to better see track data outside of the game.

  • The genetic algorithm will probably need some tweaking once the fitness function has more parameters. This is hard to evaluate right now.

Installation

You need to have Go installed (I use Go 1.5, but it should work with any version). Once you do that, run:

go get github.com/kevinburke/rct

Once you've downloaded the source code, run make install to ensure all third party dependencies are downloaded.

Check you have a valid install by running: make test. You should get output like this:

go test -timeout 1s \
		./bits/... \
		./genetic/... \
		./geo/... \
		./image/... \
		./rle/... \
		./server/... \
		./td6/... \
		./tracks/...
?   	github.com/kevinburke/rct/bits	[no test files]
ok  	github.com/kevinburke/rct/genetic	0.011s
?   	github.com/kevinburke/rct/genetic/get_latest_track	[no test files]
?   	github.com/kevinburke/rct/genetic/get_old_experiments	[no test files]
?   	github.com/kevinburke/rct/genetic/run_experiment	[no test files]
ok  	github.com/kevinburke/rct/geo	0.010s
?   	github.com/kevinburke/rct/image	[no test files]
?   	github.com/kevinburke/rct/image/above_runner	[no test files]
ok  	github.com/kevinburke/rct/rle	0.011s
?   	github.com/kevinburke/rct/rle/decode_td6	[no test files]
?   	github.com/kevinburke/rct/rle/encode_td6	[no test files]
?   	github.com/kevinburke/rct/server	[no test files]
ok  	github.com/kevinburke/rct/td6	0.010s
ok  	github.com/kevinburke/rct/tracks	0.008s
?   	github.com/kevinburke/rct/tracks/branch_factor	[no test files]

(Some of the packages don't have tests unfortunately)

Running experiments

You should be able to run new experiments by typing make experiment. This will place new experiments in subdirectories in /usr/local/rct. It should also give output in the console that looks like this:

run_experiment --package-root ~/code/go/src/github.com/kevinburke/rct
Experiment exp_ddc75161-8370-4ead-aa76-71ebdb59f1d5
======================================
Iteration 0: 500 members, best member iter_d667e484-ef33-40cd-ad30-52d5e6a90036 has score 1680000, median 1527000, worst has score 172000
Iteration 1: 500 members, best member iter_d667e484-ef33-40cd-ad30-52d5e6a90036 has score 1680000, median 1517000, worst has score 172000
Iteration 2: 500 members, best member iter_7f34d78b-4e1e-4be2-b17f-d46b51fa065d has score 1672000, median 1443000, worst has score 172000
Iteration 3: 500 members, best member iter_9cbedb01-9447-40b0-9973-aeb4af67faf5 has score 1672000, median 1443000, worst has score 172000
Iteration 4: 500 members, best member iter_9cbedb01-9447-40b0-9973-aeb4af67faf5 has score 1672000, median 1554000, worst has score 172000

Start the server by running make serve and you should be able to view your experiment by browsing at localhost:8080.

Package Layout

There are a few different packages in here.

  • genetic - implementation of a genetic algorithm to build coasters. Hopefully this can become a better implementation than just RCT specific but there are other genetic algorithm implementations for Go at the moment, so this is not a huge priority.

  • exe_reader - Reads the RCT2 exe and prints out metadata about track segments.

  • rle - deals with run length encoding of RCT files (so they can be read/written in the game). More info in the specific package.

  • td6 - a td6 file is a RCT ride file. This package encodes/decodes raw TD6 file data into Go structs.

  • image/* - turns track data into pretty PNG files. Hasn't been touched in a while and only ever implemented a 2d viewer. Decided to try using three.js instead, for greater compatibility and access to a better feature set.

  • bits - convenience functions for dealing with bits.

  • wip/* - various "discovery" scripts that read bytes from openrct2.exe dealing with track data. Shouldn't need to touch this, we might need to clean it up at some point because Go complains about the number of main files in this folder.

Donating

Donations free up time to make improvements to the project, and respond to bug reports. You can send donations via Paypal's "Send Money" feature to [email protected]. Donations are not tax deductible in the USA.

More Repositories

1

hamms

Malformed servers to test your HTTP client
Python
1,218
star
2

doony

UI Improvements for Jenkins
JavaScript
970
star
3

nacl

Pure Go implementation of the NaCL set of API's
Go
540
star
4

ssh_config

Go parser for ssh_config files
Go
386
star
5

go-bindata

A small utility which generates Go code from any file. Useful for embedding binary data in a Go program.
Go
330
star
6

hulk

In-browser JSON editor
JavaScript
312
star
7

sshpass

Mirror of http://sourceforge.net/projects/sshpass/
Shell
199
star
8

hostsfile

go tool for working with /etc/hosts files
Go
131
star
9

tecate

Figure out when your HTML is busted
JavaScript
110
star
10

customize-twitter-1.1

Add your own custom CSS to modify the Twitter Embeddable Widget
JavaScript
91
star
11

tss

Go port of moreutils/ts
Go
43
star
12

swish

Switch SSH settings between Github profiles
Go
38
star
13

travis

Command line client for interacting with Travis CI
Go
19
star
14

handlers

Useful HTTP middlewares
Go
19
star
15

gitopen

Open one of your remote URL's in your browser
Python
17
star
16

rest

Go REST helpers
Go
14
star
17

sll

Strip long lines from output
Go
14
star
18

multi-emailer

Send personalized email messages to multiple email accounts (e.g. City Council members)
Go
13
star
19

2013

Flat UI website redesign
HTML
12
star
20

differ

Go
12
star
21

read-mongo-logs

Tail Mongo database logs
Go
11
star
22

gitlab

Command line tool for waiting for Gitlab pipelines to complete
Go
11
star
23

ansible-go

Go
9
star
24

rct-rides

working with roller coaster tycoon saved ride format
Go
9
star
25

weirdfortune

the unix fortune program, now with weird twitter
Python
8
star
26

snapchat-friends

surprise, your friend network is public
Python
8
star
27

proto-make-example

Makefile
8
star
28

gobike

Go
6
star
29

ynab-go

YNAB Go Client, including a detailed age of money calculator
Go
6
star
30

write_mailmap

Easy generate an AUTHORS file from the Git commit history
Makefile
6
star
31

metrosolver

Finding optimal Mini Metro routes
6
star
32

google-oauth-handler

HTTP middleware for handling Google authentication
Go
5
star
33

targets

I am the next coming of John Carmack
C#
5
star
34

go-random-project-generator

Random project name generator (like Github or Heroku app names)
Go
5
star
35

twilio-jsonapi

A JSON convenience wrapper for the Twilio API
Python
4
star
36

godocdoc

Start godoc and open a HTTP server to the homepage
Go
4
star
37

isec2

Go library that reports whether you are running in EC2
Go
3
star
38

envdir

Go port of djb envdir
Go
3
star
39

vault-go

Better Hashicorp Vault client
Go
3
star
40

public-comments

I write letters to local governments and post them here
Go
3
star
41

clipper

API for retrieving Clipper Card data (and parsing Clipper Transactions)
Go
3
star
42

talks

Talks I give at conferences
3
star
43

goodmorningcmc

Python
2
star
44

circle-webhook

webhook server and JSON parser for circle ci webhooks
Go
2
star
45

gerrit-heroku

Attempting to run Gerrit on Heroku
Makefile
2
star
46

slides

Presentations
HTML
2
star
47

write_config_from_env

Pull env vars into a config file
Go
2
star
48

humanbench

Human-readable benchmark output
Go
2
star
49

tt

Better Node test runner
Go
2
star
50

jenkins

Open Jenkins urls from your command line
Python
2
star
51

haa

CA Housing Accountability Act Resources
2
star
52

stubhub-tickets

checking stubhub ticket prices
Python
2
star
53

tarbz2.com

Helping you remember which tar option to use.
ApacheConf
2
star
54

goose

Maintained fork of liamstask/goose that supports ALTER TYPE, CREATE INDEX CONCURRENTLY
Go
2
star
55

buildkite

Buildkite CLI tool
Go
2
star
56

chroma-markdown

Combined Markdown + syntax highlight HTML compiler
Go
2
star
57

gostdjs

The Go standard library, implemented in Javascript
JavaScript
1
star
58

old-county-road

JavaScript
1
star
59

generic-pool-timeout

JavaScript
1
star
60

oculus-rating-data

Working with Oculus rating data
Go
1
star
61

tarsnap-old-archives

Deleting old Tarsnap archives
Go
1
star
62

rustls-postgres

1
star
63

sample-html

sample html
1
star
64

local-servers

Making your local projects more browsable
Makefile
1
star
65

recompile

Concurrent recompilation of individual files (see README)
Go
1
star
66

Twilio-Python-quickstarts

Python quickstarts for Twilio
Python
1
star
67

flagr

Rearrange flags so the options come first
Go
1
star
68

delete-phone-numbers

Delete numbers from a Twilio account
Go
1
star
69

flot.selection.js

The Flot selection plugin, with draggable left/right edges
JavaScript
1
star
70

make

Go
1
star
71

javascript-ipython

ipython notebook for javascript
Shell
1
star
72

enable_pg_logs

Enable Postgres query logging
Go
1
star
73

ipv6-etc-hosts

Go
1
star
74

telapi-python

Tel API Python Helper Library
Python
1
star
75

lucifer

Hot, hot test reloading from Javascript
JavaScript
1
star
76

waterline-self-driving-car

1
star
77

newproject

1
star
78

bigtext

Go library to display text really big using Quicksilver on a Mac
Go
1
star
79

twilio_munischedule

Ruby
1
star