Remaking an Old Game in OCaml

I’ve starting blogging about a side-project of mine. Hopefully I’ll find the time to write some further entries in the series, including about reverse engineering a binary with IDA.


(maybe you forgot the link to the code: gh/rails)

I’ve tried to install the deps[1], and I get this error with integers.0.5.1:

/usr/lib/gcc/i586-mageia-linux-gnu/8.4.0/include/stdint.h:9:16: \
  fatal error: stdint.h: No such file or directory
# include_next <stdint.h>
$ ll /usr/lib/gcc/i586-mageia-linux-gnu/8.4.0/include/stdint.h
-rw-r--r-- 1 root root 328 Mar  4  2020 /usr/lib/gcc/i586-mageia-linux-gnu/8.4.0/include/stdint.h
$ ll /usr/include/stdint.h
-rw-r--r-- 1 root root 8.3K Jun 22  2021 /usr/include/stdint.h

[1]: ppx_derivers, optint, seq, csexp, ocamlbuild, stdlib-shims, sexplib0, integers, owl-base, cmdliner, cppo, conf-libffi, result, either, ocaml-compiler-libs, bigarray-compat, topkg, ctypes-foreign, dune-configurator, ppxlib, astring, ctypes, iter, gen, containers, checkseum, base, ppx_deriving, ocb-stubblr, tsdl, containers-data, decompress, ppx_sexp_conv, ppx_compare, lens, imagelib, ppx_hash

I haven’t really made the code easy to install. Hopefully tonight I’ll have time to do so and I’ll see if there are really any potential dependency conflicts.

The deps are not really hard to install while we only require one command with opam for that, it’s only that there is a compilation error.

Well I can tell you my main dependency versions (I’ll be adding them to an opam file soon):

tsdl 0.9.8
owl-base 1.0.2
ocaml 4.13.1
iter 1.4
imagelib 20210511
gen 1.0
containers 3.7
containers-data 3.7
ppx_deriving 5.2.1
ppx_hash 0.15.0
lens 1.2.5

All other packages are requirements of these main ones.

I added an opam lock file. You should be able to install all the dependencies using just the opam switch create . --locked command.

Ok, I have finally succeed to compile it: I switched to an ocaml 4.14 switch in opam, and then there was no compilation errors anymore with all the dependencies.

So now I have a binary that I can run, but when I run it I get the error:

Sys error: "./data/EASTUS.PIC", no such file or directory.

I was trying to figure out if your game was worth to be added in the ocaml-awesome-gamedev repo?

(also if someone could tell me what would be the right name for this repo: “ocaml-awesome-gamedev”, “awesome-gamedev-ocaml” or awesome-ocaml-gamedev"?)

I was also trying to figure out if the game would be worth to be adapted to be compiled with rescript to get an html5/canvas game that everyone could play with in a browser.

I recently made some experimentations with it, and the beginnings are promising.

I also wrote a tutorial, 1) with a snake example, and 2) with a platformer example where you see how to make something like this.

I thought the platformer will be slow because MariOCaml is very slow on my old and small computer, but it’s not slow at all, even with a bigger canvas.


The engine expects the files from the original Railroad Tycoon to be placed under ‘./data’. The game unfortunately isn’t sold on any digital storefront nowadays.

The data directory indeed contains 3 files, but not this one.
Maybe you forgot to include it?

Check github/rails/data/, it only contains:


I tryed to find EASTUS.PIC with google, but it doesn’t seem to be available anywhere.

From the screenshots and the yt video it doesn’t look like something very difficult to re-create.
Look at undune2 or mindustry on, players can even be happy with big pixels, or you can just display squares at early dev steps that can be replaced by graphics after.

Do you know the website

1 Like

The first version is an exact replica of Railroad Tycoon (with some modern UI conveniences) and therefore needs the game files, similar to the way OpenXcom, OpenApoc and Julius work.

After 1.0, I’ll change/improve the graphics and then I can distribute them as well.