Playing Gwent on your Raspberry Pi
This is going to be a long read anyway, so I’ll assume you know what Gwent is, and what a Raspberry Pi is, but if you don’t, check out the links.
Reddit user /u/exane made a wonderful copy of Gwent and hosted it online, though due to legal reasons, it soon went down. Luckily, however, exane made his work open source (‘open source’ is a term used to describe software which is free and modifiable by anyone), meaning that you can download it for yourself and play at home.
Being a huge fan of Gwent, it was disappointing to see that someone made it and that I didn’t even get a chance to play, so I set out to set up exane’s Gwent clone with very, very basic understanding of how the Raspberry Pi’s Linux branch Raspbian actually worked. I figured things out as I went along, making for a very satisfying learning experience which I’ll try to collect, step by step, here. Take note that, because I knew practically nothing of how anything works, this guide will probably start off pretty basic.
This is a write up of how I did this, and how I did it is probably not the best way out there, but it worked just fine for me.
Likewise, be wary of the fact that this game was shut down pretty much the day it went big on Reddit, therefore it’s not finished or fully polished, and you might encounter bugs and errors.
The legality of this is questionable. The game was taken down by CDPR, and therefore following anything I’ve written here, you are following at your own risk.
Firstly, (this step isn’t entirely necessary, but it saves a lot of time in the future) you should assign your Pi a static internal IP address. IP addresses allow your router to differentiate between all the devices that connect to the internet through it. A static IP address means that your Pi will always have the same address every time it connects to your router.
Go to 192.168.0.1 in your internet browser to open your router’s interface. Now, each internet provider’s router’s interface will be different. I have a Sky router, so that’s what the screenshots will be of. My Raspberry Pi was already connected to 192.168.0.17, which is conveniently out of the way as I don’t have 17 devices connecting to my router anyway. So, by setting a static IP, I’ll ensure that my Pi always connects to 192.168.0.17.

Go to the Advanced tab right at the top, then go to the LAN IP Setup tab below it. You’ll see a section titled Address Reservation, and an “Add” option below it. Again, this won’t be the same in all routers, so you’ll have to find out how your router works on your own. Upon clicking “Add”, you’ll get this screen:

Tick the dot next to your Raspberry Pi, and everything will be filled out automatically. Press “Add” again, and you’re sorted. Now, turn to your Pi.
Relevant deviation here. You’ll want to download PuTTY on your PC. Putty allows you to connect to your Raspberry Pi from your PC and use its command line remotely, meaning that you don’t have to constantly switch between the two.
Having just found out your Pi’s IP address, make a note of it as it’ll come in useful when launching up Putty. Fill out Host Name with the IP address, make sure Port is set to 22, and Save the session to save you having to type out the IP every time you launch Putty.

After pressing Open, Putty will attempt to connect to your Pi, and if successful, you’ll be met with this screen:

The default username is ‘pi’, and the password is ‘raspberry’. The password prompt won’t display anything you type in, so don’t worry when the command line doesn’t respond to your inputs. When you’re done, press enter. Finally, you’ll have access to your Pi’s command line straight from your PC.

Another relevant deviation. You’re not going to need this program until much later on (and even then, it’ll only make things a little simpler), but it’s nice to know about it if you don’t already.
TightVNC is similar to Putty in that it allows you to control your Pi remotely. However, whereas Putty is command line exclusive, TightVNC streams the desktop of you Pi to your computer, so that you can use it just like your Windows computer.
All you need to do is type in:
sudo apt-get install tightvncserver
let it install, then simply type in the command line
tightvncserver
to turn it on. It’s worth taking a note of what comes up after “New ‘X’ desktop is raspberrypi: ”

Download TightVNC for your PC too from here. Open TightVNCViewer, and fill out the box accordingly.

Change the ‘x’ in the screenshot for the number that appeared when you ran TightVNCServer on your Pi. So in my case, that’ll be 5901. Press ‘Connect’, and you’ll be greeted with your Pi’s GUI (Graphical User Interface).

Now, back to setting your Pi a static IP address.
I found a great guide on ModMyPi that’s easy to follow and explains everything succinctly (screenshots included), so go ahead and check it out here: http://www.modmypi.com/blog/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address
So, exane’s Gwent is a web app, meaning it’s played in your internet browser. The Pi acts as a server, sending information to and accepting information from the clients. To allow the Pi to act as a server and handle information between users, you’ll have to download a program called ‘Apache’, a web server. In Putty, enter the following into the command line:
sudo apt-get install apache2 -y
‘sudo’ is short for ‘Superuser Do’, and is similar to granting Administrator privileges in Windows.
‘apt-get’ is the program which handles installing packages, and ‘install’ is an instruction you give to ‘apt-get’, effectively saying “I’m the boss here, apt-get, you install apache2”. The ‘-y’ flag tells the Pi to answer ‘yes’ to prompts that ask “Are you sure you want to install this?”.
Once this is finished, you can enter your Pi’s IP address into your browser and see Apache’s default web page.

Go back to the command line and type in the following:
cd /var/www
‘cd’ stands for ‘Change Directory’, and is how you explore folders and their files using the command line. Whatever is in the /www/ folder will be displayed when you go to your Pi’s IP address in the browser. If you type in:
ls -l
the command line will list every file in the current directory, its permissions, owner, and date created. Here, you should see only one file: “index.html”. You can type in:
sudo nano index.html
to open the file with the text editor, ‘Nano’. Using Nano, you can edit the file and get it to display anything you want. When you’re done editing the file, press Ctrl + X to save and close the file, then refresh your browser to see the updated version of the webpage. That’s irrelevant though, you’ll want to type in:
sudo rm index.html
to remove the file, as we don’t need it for this.
When exane first released the Gwent files, they came with zero instructions on how to get everything to work. I spent hours trying to reverse engineer some sort of solution to no avail. I made a thread on Reddit, and sooner or later, exane actually got back to me and updated the readme.txt with relevant instructions. The following is just a guide to clearing up any kinks in his instructions, some problems that I came across, and their solutions.
Next port of call is downloading the files required for Gwent. exane stored them on a code repository called “Github”, and that’s where we’ll get it from.
Make sure you’re still in the /var/www directory and enter the following:
git clone https://github.com/exane/gwent.git
This’ll create a new folder called ‘gwent’ and download all files to it.
One of the requirements to get it all to work is ‘node.js’, so that’ll be the next thing we approach. Downloading Node is a little different to downloading Apache, but I can’t really explain why, so just stick with it.
Make sure you’re out of the Gwent directory by typing in:
cd
Now, type in:
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb
‘wget’ is similar to ‘apt-get’ as they both deal with downloading files. Press enter and it’ll start downloading and installing. Once it’s done, type in the following to check that it’s installed.
node -v
This should display Node’s current version.
The next requirement is GraphicsMagick. There wasn’t a definitive guide for installing this that I could find, but I managed to figure it out.
Much like with Apache, type in:
sudo apt-get install graphicsmagick
Wait for it to install, and you’re all done.
From what I gather, Node has many different modules you can download to add specific functionality. To make Gwent work, you have to download a few of these modules. Luckily though, the modules that it depends on are listed in the files and can be downloaded automatically. When I first downloaded the modules and tried running Gwent, I was hit by a bunch of errors. I found that installing the modules to the Gwent folder, rather than installing them globally, fixed the problem. So, to do that, you’ll have to type in:
cd /var/www/gwent
then,
npm install
‘npm’ stands for ‘Node Package Manager’, and is what handles downloading Node modules. The ‘install’ instruction simply asks it to download all the modules that are listed as required in the game’s files.
Once that’s done, type in:
npm run gulp
Both of these took my Pi a considerable amount of time to complete. There’s a programming error in gulpfile.js that makes the Pi not realise it’s finished everything and just seemingly hang, but that’s not the case. I’ve already ran ‘gulp’ so my screenshot will look a little different, but once it reaches “…build/main.css reloaded.”, you’re good to go. Press Ctrl + C to close the process and regain control of the command line.

There’s another slight programming error that I’ve come across. When you open up the game, it will look for the Card images saved as x.PNG, while the ‘gulp’ process saves them simply as x.png. Open up TightVNC, click on the Filing Cabinet at the top, then open the ‘/’ folder, then ‘var’, followed by ‘www’, and finally ‘gwent’. Then, open the ‘public’ folder, and go into ‘build’. Hopefully, here you’ll see a bunch of .png files.

One by one, you’ll have to right click on them and change the ‘.png’ to ‘.PNG’, like on the picture above.
This is the home stretch now. If you want to only play Gwent with people connected to your router at home, back out of the /build/ folder to the /public/ folder, right click on ‘Config.js’, then ‘Text Editor’, and change the IP address following “hostname” to your Pi’s, like this:

Feel free to close TightVNC now. Go back to Putty, make sure you’re in the gwent directory by typing in:
cd /var/www/gwent
and then launch the Node server by typing in:
node server/server.js
If everything went okay, you should be able to enter your Pi’s IP address in your browser, followed by “/gwent/public”, and, finally, play a round of Gwent.

Hosting Gwent to play with people over the internet will be a little bit more complicated. This will require forwarding ports in your router and is one of those things that I, again, can’t demonstrate for everyone. My screenshots will only represent the way my router works, but if you use some initiative, you should be able to figure it out yourself.
If you noticed in the pictures above, “Config.js” has the default port set to ‘16918’ so we’ll stick with that one to save time, but feel free to change it if you want. I didn’t personally change the port, but exane mentions that:
“If you have to change port than make sure you change the port on your server as well.
You find the server port in /server/server.js on line #18 “app.listen(#port)”
Port forwarding is a way of sorting data that comes to your router from the internet. We can tell the router to forward the data that comes to port ‘16918’ to our Raspberry Pi, as it knows exactly what to do with said data.
Again, go to 192.168.0.1 to access your router settings. With my Sky router, you have to first add ‘Services’. You can find this under “Security” right at the top, and then “Services”.

I’ve blanked out my other services to stay on the safe side. The bottom one matters the most anyhow. These screenshots are representative of what your screen should look like if done correctly (other than the blank spaces, as those are my own services I’ve censored).
As an irrelevant aside, you can forward port 80 to make your Pi into a form of cloud storage. With port 80 forwarded, whenever I visit my external IP (go to Google and type in “What is my IP?” to find this out), everything that is in the /www/ folder becomes visible here, as such:

Take note that most routers have dynamic IPs that change every set period of time, so visiting this IP wouldn’t return anything.
Upon clicking “Add a custom service”, I’m met with this screen that I’ve filled out accordingly:

With the service made, then go to “Firewall Rules”, which gives me this screen:

I’m not entirely sure if forwarding an outbound port has any effect but I do it regardless. When you click “Add” in the “Outbound” section, you’ll be met with this screen:

When you click “Add” in the “Inbound” section, you’ll be met with this screen:

Again, I can’t account for how other routers work, but if you fill everything out in a similar fashion to me, you should be fine.
Lastly, you’ll have to turn back to TightVNC, and go back to the “Config.js” file I mentioned before. Again, Google “What is my IP?”, and change “hostname” to the IP that appears on Google. From there, you’ll have to turn to Putty and type in:
node server/server.js
And now, hopefully, anyone that also knows your IP will be able to connect and play with you.
Again, the legality of this is questionable.
If you’ve made it this far… well, thanks for reading! It’s been wholly satisfying, both figuring out how to get everything working, and writing this up. It took me the best part of a week, but it’s been worth it :)