This documentation is for an old GraalVM version. See the latest version.

Running Optcarrot

Running the Demo #

Start by installing GraalVM.

Then add GraalVM/bin in PATH (or use a Ruby manager):

export PATH="/path/to/graalvm/bin:$PATH"

You also need to install SDL2:

  • brew install sdl2 on macOS
  • sudo yum install SDL2-devel for RedHat-based Linux
  • sudo apt-get install libsdl2-dev for Debian-based Linux

Then clone the optcarrot repository:

git clone https://github.com/eregon/optcarrot.git
cd optcarrot

Then you can play the Lan Master game.

On Linux:

ruby --jvm bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes

On macOS, you need an extra flag, --vm.XstartOnFirstThread, for the GUI to appear:

ruby --jvm --vm.XstartOnFirstThread bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes

Note: --audio=none is used since the audio it not nice at non-60FPS speeds.

To play, use keys 17 (not on numpad) to scale the screen, X for OK/turn right, S for turn left, arrows to move around, and Q to quit.

More information can be found in this blog post.

Here is a recording of a talk running the demo on TruffleRuby and MRI.

Running on Other Ruby implementations #

You can also run it on MRI for comparison. You will need to install the FFI gem with:

gem install --user ffi
ruby bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes

You can also run it on JRuby if desired:

jruby bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes

Running as a Benchmark from the TruffleRuby Repository #

If you have a local checkout of TruffleRuby, you can also use the version of OptCarrot under bench/optcarrot. See the Benchmarking documentation for details.

Connect with us