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 Core. 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. Alternatively, you can refer to this guide for various methods of connecting to a Raspberry Pi.

If you’re using a Raspberry Pi 3, you can disable the Bluetooth and built in Wi-Fi radios by editing the config.txt file by running sudo nano /boot/config.txt and adding the following lines to the bottom of the file:

Press ctrl+x and y to save and close the file. If you’re planning on using the on-board Wi-Fi you can omit the second line.

Setting Up the Access Point

Before rebooting and reconnecting to your Pi, plug in the Wi-Fi adapter. The below instructions, based on this guide, will setup and configure the Raspberry Pi access point (double-clicking on a code block below will make it easier to copy):

First, run the following commands:

Setting up DHCP server

Edit the dhcpd.conf file by running following command sudo nano /etc/dhcp/dhcpd.conf. Find the lines that read:

And change them to read:

Next, find the lines that read:

And change them to read:

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

Save and close the file, then run the sudo nano /etc/default/isc-dhcp-server command. Edit the file so that the two lines with INTERFACES in them resemble the following:

Save and close the file, then run the command sudo rm /var/run/dhcpd.pid.

Set up wlan0 for static IP

Run the sudo nano /etc/network/interfaces command and add the following lines to the end of the file, skipping or replacing any duplicate lines that already exist:

Save and close the file, then run the commands:

Configure Access Point

Run the command sudo nano /etc/hostapd/hostapd.conf and change the contents of the file to match the following:

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 instead and changing the passphrase to whatever you want:

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

To this:

If you want to use the Raspberry Pi’s built in Wi-Fi, omit the line reading driver=nl80211 in each case.

Save and close the file then run the command sudo nano /etc/default/hostapd. Find the line that reads:

And change it to read:

Be sure to remove the # at the start. Save and close the file then run the command sudo nano /etc/init.d/hostapd and change the line reading:

to:

Then save and close the file. Restart your Pi and your access point should now be working.

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 (you may need to flush your DNS cache on the computer connecting to the Raspberry Pi server to get this working; the ipconfig /flushdns command will do this in Windows). 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:

Then save and close 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 lines 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.

Raspberry Pi 2 Instructions

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.

Raspberry Pi 3 Instructions

If you are using a Raspberry Pi 3, enter the following commands instead:

Reboot to activate the RNG. Whether this makes any real difference remains to be determined, but it can’t hurt.

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:

Game Server Running

A successfully started RoboRuckus game server.

The chmod 755 RoboRuckus command only needs to be run the first time you start the game after coping the files over. To stop the game server press ctrl+c. If the server starts and exits without problems, congratulations, your game is good to go!

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, separating each with a comma) 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 Core program you want to run on a Pi). Note that this has only been tested on a Windows computer running Visual Studio, but should still be feasible from MacOS or Linux using the alternative publish command below.

First, if you didn’t install it when you installed VisualStudio, you’ll need modify your install to include the .Net Core SDK, or you can download and install the .Net Core SDK for your platform from here. You’ll also need to install Node.js since NPM is used to manage JavaScript libraries. Once NPM is installed, either from the Package Manager Console in Visual Studio or from the command prompt in the solution directory, run the command:

Next, you need to publish the project by right-clicking on the RoboRuckus project name in the solution explorer and choosing publish. Select the ARMExport profile and click “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. Be sure to select “linux-arm” as the target runtime and set the deployment mode to “Self-Contained”.

Publishing the project.

Selecting the ARM Export profile.

Compile3

Creating a new publish profile.

Compile4

Publish profile settings.

Alternatively, you can run the following command from the command prompt in the project’s solution directory:

Once either of those is done, you can copy the contents of the publish directory to your Raspberry Pi and run the program!