Setting Up the Game


While you can use any computer to host a RoboRuckus game server, this guide describes how to setup a dedicated game server on a Raspberry Pi with its own Wi-Fi network. A Raspberry Pi with ARMv7 or better is required by ASP.Net. The Raspberry Pi 2 running Raspbian Stretch is recommended as the Raspberry Pi 3 has not yet been tested (specifically, while most things should work fine, changes, like to the interface names, may need to be made in order to get the Wi-Fi working). This guide also assumes you already have some basic familiarity with the Linux command line. If you’re unfamiliar with the command line, these two guides are a good introduction, and more general information can be found at the official Raspberry Pi documentation.

Materials

Setting Up Raspbian

Following these instructions, download and install Raspbian (preferably the lite version) onto the SD card, and insert the card into your Raspberry Pi. You can either hook your Raspberry Pi up to a keyboard and monitor (via HDMI) to do the set up, or connect to your Raspberry Pi via SSH (see these instructions for SSH). Either way, an Internet connection is required for setup.

To connect via SSH (“headless” mode), connect your Pi to your router via an Ethernet cable then use this Raspberry Pi finder to locate your Pi and note its IP address. Click on the Terminal button to connect via SSH and open a command line. Use raspi-config to expand the file system and optionally setup the internationalization options and change the user password.

Setting Up the Access Point

Before rebooting and reconnecting to your Pi, plug in the Wi-Fi adapter. Boot up your Pi and configure it to be an access point using this guide, making the following changes to the instructions in the guide’s various sections (double-clicking on a code block below will make it easier to copy):

Setting up DHCP server

Change these lines from the guide:

To this:

When editing the /etc/default/isc-dhcp-server file, change it so that the two lines with INTERFACES in them resemble the following:

Then run the command sudo rm /var/run/dhcpd.pid.

Set up wlan0 for static IP

For this section, skip the guide’s instructions and edit the /etc/network/interfaces file to add the following lines to the end of the file, skipping any duplicate lines that already exist in the file:

Then run the command sudo ifconfig wlan0 192.168.3.1 and reboot your Pi.

Configure Access Point

Change these lines from the guide:

To this:

This will create a Wi-Fi access point called RoboRuckus with no password. You can setup a secure network if you want by using the following configuration and changing the passphrase to whatever you want:

You will also need to update the BotCode.ino to use WPA by changing:

To this:

The sections titled Configure Network Address Translation and Update hostapd should be skipped.

Follow the rest of the guide as written. After completing the above steps and rebooting your Pi, you should now see a new Wi-Fi network called RoboRuckus, which you should be able to connect to, but it won’t provide any Internet access.

Setting Up DNS

You can set it up so devices connected to your Raspberry Pi can access the game server by visiting the address roboruckus.com. To start, you’ll need to set up dnsmasq by running the following command:

Edit the dnsmasq configuration file by running:

And add the following lines to the bottom of the file:

Press ctrl+x and y to close and save the file.

Next run:

And add the following line to the bottom of the file, then close and save it:

The next step is to install nginx and configure it as a reverse proxy. Run the following commands:

Then create a new nginx site called roboruckus:

Add the below to the contents of the file:

Save your file and restart your Pi to get dnsmasq and nginx working.

Hardware RNG

While the RoboRuckus game already uses the RNGCryptoServiceProvider class to provide high quality random numbers for dealing cards, you can further improve the entropy pool on the Raspberry Pi by enabling its hardware RNG. The following is based on these instructions, and only works on a Pi 2 or earlier, if you have a Raspberry Pi 3 that same link has other instructions that should work.

First, install the RNG-Tools:

Next run:

And add the below line to the bottom of the file:

Close and save the file, then run:

And set the contents of that file to:

Close and save the file, then reboot to activate the RNG. Whether this makes any real difference remains to be determined, but it can’t hurt.

Setting Up .Net

ASP.Net Core does not currently have official support for Mono (and .Net Core does not yet officially support ARM). However, the wonderful ASP.Net community has created some work-arounds which are detailed here.

Installing Mono

Getting Mono working is, unfortunately, not as trivial as it should be, but it can be done by entering the following commands in order (hat-tip to Lyle for providing the Mono and libuv solutions):

Installing libuv

Next, libuv needs to be downloaded, compiled, and installed using the following commands:

Setting Up ASP.Net

The hackiest part of all this is getting ASP.Net to run on ARM, with major thanks to techcap for detailing this solution. Some of these steps may be unnecessary by now, but they don’t seem to hurt. Enter the following commands on the Pi, ignore any errors about things already existing:

Setting Up RoboRuckus

Now that the environment is set up, download the RoboRuckus Git repository, saving the file to your computer. Using SFTP, connect to your Raspberry Pi. Extract or open the zip file and copy the folder RoboRuckus from RoboRuckus-master/PiReady/ to your Raspberry Pi home directory. Then run the following commands:

Server Running

A successfully started RoboRuckus game server.

To stop the game server press ctrl+c. If the server starts and exits without problems, congratulations, your game is good to go!

Note: There is currently a bug in the SignalR library used that will cause the program to hang when exiting. To properly shutdown the game server use the following commands:

After that, the game server should be able to be started again if desired.

Command-Line Arguments

RoboRuckus accepts a number of optional arguments to change the game mode when you launch the program. In general, these arguments can be mixed in any order without problems. To use arguments, add them after the prgram name when launching RoboRuckus, as follows:

Replace arg1 and arg2 (or as many arguments as you want) with one or more of the following options:

Botless Mode

Argument: botless

You can run the game in a “botless” mode, for playing the game without physical bots. This will add six “virtual” bots to the game so you can test and play just with a computer, phone, or tablet, but no physical bots needed. You cannot mix the botless mode with physical bots.

Edge Control

Argument: edgecontrol

By default, when a robot is supposed to drive or be pushed off the board, the physical robot will actually drive off the game board. This is to make room for other bots that might need to drive into that space, and to remove it from the game until the game master can re-enter the bot into play. Using edge control, when a robot is supposed to drive off the board it will only drive up to the edge of the board instead, the game will then pause for a few seconds and display a message for the game master to remove the robot from play before the game continues. This is useful when, for whatever reason, you don’t want or can’t have the robots driving off the board at all. It is still recommended to have some sort of barrier around the edge of the board to prevent the bots from accidentally driving off the board.

Compiling for the Raspberry Pi

Since the server code for RoboRuckus is written using the .Net Framework it can run on almost any modern system, including MacOS, Windows, and Linux. You can download the project solution from our GitHub repository and compile it for the system you’re running on using Visual Studio (or Visual Studio Code for MacOS and Linux). Compiling it to run on the Raspberry Pi is, however, more difficult. Here are the steps that you can take to compile RoboRuckus for the Raspberry Pi (these instructions should also work for any ASP.Net program you want to run on a Pi). Note that this only works from a Windows computer running Visual Studio.

The first thing you should do is copy the System.Runtime.InteropServices.RuntimeInformation.dll file from the PiReady directory to someplace safe (or you can download it from our GitHub repository here, or from the NuGet repositry here).

Then, you need to publish the project by right-clicking on the RoboRuckus project name in the solution explorer and chosing publish. Select the ARMExport profile and clikc “Publish”. This will compile and copy the program to the PiReady folder in the solution directory on your computer. You can, if you want, create a new publish profile, just pick “Folder” as the publish target and choose where you want the output to be saved.

compile1

Publishing the project.

compile2

Selecting the ARM Export profile.

Compile3

Creating a new publish profile.

Lastly, you need to copy the System.Runtime.InteropServices.RuntimeInformation.dll file that was saved from above back to your publish directory. Once that’s done, you can copy the publish directory to your Raspberry Pi and run the program!