There are two primary ways to set up the game. The easier method is to use the Docker setup procedure to deploy the game server on a computer of your choice. Details for the setup method can be found on our GitHub repository. This requires you to have the robots and game server all connected to the same local network.
The second method is to create an all-in-one solution using a device like a Raspberry Pi. 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. 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
- Raspberry Pi 3 Model B+ (can also be purchased from Adafruit)
- MicroSD card >=8GB
- Wi-Fi adapter (must support being an access point)
- Power Adapter
- Micro USB cable (you may already have one)
- Raspberry Pi Case (optional)
- Ethernet Cable (optional)
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:
dtoverlay=disable-bt dtoverlay=disable-wifi
Press ctrl+x
and then 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:
sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install hostapd isc-dhcp-server libgdiplus
Setting up DHCP server
Edit the dhcpd.conf file by running following command sudo nano /etc/dhcp/dhcpd.conf
. Find the lines that read:
option domain-name "example.org"; option domain-name-servers ns1.example.org, ns2.example.org;
And change them to read:
#option domain-name "example.org"; #option domain-name-servers ns1.example.org, ns2.example.org;
Next, find the lines that read:
# If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative;
And change them to read:
# If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. authoritative;
Then add the following lines to the bottom of the file:
subnet 192.168.3.0 netmask 255.255.255.0 { range 192.168.3.12 192.168.3.200; option broadcast-address 192.168.3.255; option routers 192.168.3.1; default-lease-time 600; max-lease-time 7200; option domain-name "local"; option domain-name-servers 192.168.3.1, 8.8.8.8; }
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:
INTERFACESv4="wlan0" #INTERFACESv6=""
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:
auto lo auto eth0 iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 iface wlan0 inet static address 192.168.3.1 netmask 255.255.255.0 post-up /etc/init.d/isc-dhcp-server start pre-down /etc/init.d/isc-dhcp-server stop
Save and close the file, then run the commands:
sudo ifconfig wlan0 192.168.3.1 sudo systemctl disable isc-dhcp-server
Configure Access Point
Run the command sudo nano /etc/hostapd/hostapd.conf
and change the contents of the file to match the following:
interface=wlan0 driver=nl80211 # Only necessary if not using onboard Wi-Fi ssid=RoboRuckus country_code=US hw_mode=g channel=6 macaddr_acl=0 ignore_broadcast_ssid=0 ieee80211n=1 wme_enabled=1
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:
interface=wlan0 driver=nl80211 # Only necessary if not using onboard Wi-Fi ssid=RoboRuckus country_code=US hw_mode=g channel=6 ignore_broadcast_ssid=0 macaddr_acl=0 wpa=2 wpa_passphrase=passphrase wpa_key_mgmt=WPA-PSK wpa_pairwise=CCMP wpa_group_rekey=86400 ieee80211n=1 wme_enabled=1
You will also need to update the BotCode.ino file to use WPA by changing:
Serial.println(sendCommand(F("AT+CWJAP=\"RoboRuckus\","), F("\nOK")));
To this:
Serial.println(sendCommand(F("AT+CWJAP=\"RoboRuckus\",\"passphrase\""), F("\nOK")));
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:
#DAEMON_CONF=""
And change it to read:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Be sure to remove the # at the start. Save and close the file then run the command sudo nano /etc/init.d/hostapd
and make sure it has the line:
DAEMON_CONF=/etc/hostapd/hostapd.conf
Then save and close the file. Next run:
sudo systemctl unmask hostapd sudo systemctl enable hostapd sudo rfkill unblock wlan
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). You will need internet access on the Pi again to complete this section. Plugging the Pi into an Ethernet connection should work. To start, you’ll need to set up dnsmasq by running the following command:
sudo apt-get install dnsmasq
Edit the dnsmasq configuration file by running:
sudo nano /etc/dnsmasq.conf
And add the following lines to the bottom of the file:
address=/roboruckus.com/192.168.3.1 address=/www.roboruckus.com/192.168.3.1
Then save and close the file.
Next run:
sudo nano /etc/hosts
And add the following line to the bottom of the file, then close and save it:
192.168.3.1 roboruckus.com roboruckus
The next step is to install nginx and configure it as a reverse proxy. Run the following commands:
sudo apt-get install nginx sudo rm /etc/nginx/sites-enabled/default
Then create a new nginx site called roboruckus:
sudo nano /etc/nginx/sites-enabled/roboruckus
Add the below lines to the contents of the file:
server { listen 80; server_name roboruckus.com www.roboruckus.com; # Websocket support for playerHub connections. location /playerHub { proxy_pass http://127.0.0.1:8082/playerHub; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # WebSocket support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } # Redirect all HTTP traffic to Kestrel server. location / { proxy_pass http://127.0.0.1:8082; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Connection ""; } }
Save your file and restart your Pi to get dnsmasq and nginx working.
Hardware RNG
Note: This section is deprecated as modern Raspbian and Raspberry Pis have the hardware RNG enabled by default. You can safely skip this section in almost all cases.
While the RoboRuckus game already uses the RandomNumberGenerator 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:
sudo apt-get install rng-tools
Next run:
sudo nano /etc/modules
And add the below line to the bottom of the file:
bcm2708_rng
Close and save the file, then run:
sudo nano /etc/default/rng-tools
And set the contents of that file to:
HRNGDEVICE=/dev/hwrng
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:
echo bcm2835_rng | sudo tee /etc/modules-load.d/rng-tools.conf sudo modprobe bcm2835_rng sudo apt-get install rng-tools echo 'HRNGDEVICE=/dev/hwrng' | sudo tee --append /etc/default/rng-tools sudo systemctl enable rng-tools sudo systemctl start rng-tools sudo systemctl status -l rng-tools
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:
cd RoboRuckus/ chmod 755 RoboRuckus ./RoboRuckus
The chmod 755
command only needs to be run the first time you start the game after copying 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!
NB: Always change the working directory to the one containing the RoboRuckus executable before starting the game server, otherwise there could be errors with the path and loading certain files.
If you want the run the game as a service so it starts automatically when you turn on your Pi, while still in the RoboRuckus directory run these commands:
sudo ln -s $(realpath ./start_roboruckus.sh) /usr/local/bin/start_roboruckus sudo cp roboruckus.service /etc/systemd/system/ sudo chmod 755 /etc/systemd/system/roboruckus.service start_roboruckus.sh sudo chown root:root /etc/systemd/system/roboruckus.service sudo systemctl enable roboruckus
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 program name when launching RoboRuckus, as follows:
./RoboRuckus --options=arg1,arg2,...
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.
Logging
Argument: logging
Using this option will have the game record the starting and ending position of each robot for each round, as well as the moves (cards) that each player submitted for each round. This will allow you to compare the game state with what happens, which can be useful to see if the game is calculating the robot moves properly. The log will be saved as gamelog.txt in the same working directory as the game executable.
Show Registers
Argument: showreg
If you include this command, the game will display all the cards that the players picked for a register on the monitor page for a few seconds before each register starts. If the monitor page is displayed, this allows everyone to see a preview of all the moves each player picked. This does, however, slow the game down a bit as there is a pause before each register starts.
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. 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 or Visual Studio Code.
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”.
Alternatively, you can run the following command from the command prompt in the project’s solution directory:
dotnet publish RoboRuckus.sln -r linux-arm -o PiReady\RoboRuckus -c Release --self-contained -p:PublishSingleFile=true
Once either of those is done, you can copy the contents of the publish directory to your Raspberry Pi and run the program!