Saturday, August 20, 2016

How to Set Up a Civilization V Server

 Last updated: 5/16/22

2K Game's instructions on how to set up a Civ V server are unfortunately lacking, they literally just took a guide that one of the forum members wrote and made it the 'official' guide. While the instructions will get you on right path to initially getting the server SDK running, you will be plagued with crashes and errors. The reality of an SDK existing only for Windows and not Linux should be a forewarning for how buggy this software is going to be. After over a week of trying to figure out how to correctly configure a Civ server, I decided to make my own guide that I can reference and reiterate on in the future. Let me be the first to welcome all of you die hard Civ V fans, and those that are waiting for the two expansions packs to be released for Civ VI so you can actually play the game. Civ VI has now hit the price point of "we've released all the DLC so it's now permanently at least 50% off.

I like to play Civ with my friends, unfortunately we are not all able to play at the same time. Online play without hosting your own server means that other players cannot connect and disconnect at will, and that turn timers are only measured in seconds rather than hours, which can be a problem if you like to take breaks and play a game that can span over a few days. This mode we are going to set up is called Pitboss mode and offers players the most versatility and control when playing online with friends. Below you will find the steps to get started.

Installing for the first time:

1. Ensure that network port 27016 is open to UDP communication on the server's router. Consult your router manual for instructions. The dedicated server does not use Steam's NAT punch-through facilities, so turn on port forwarding and make sure that you are allowing
2. We're going to skip the email settings for now, and come back to that later.
3. Install Sid Meier's Civilization V SDK. This can be found in the Tools section of your Steam Library.
4. Launch Sid Meier's Civilization V SDK.Make sure that *everything* successfully installs. One problem I experienced early on was that the specific version of .NET Framework was not installing successfully; I was getting an error message every time it tried to install. In that case there ended up being an issue with my installation of Windows and I had to reformat.
5. Select Dedicated Server from the SDK Launcher. Once Civ boots successfully you can exit out of the game for now.

Running a Pitboss game without crashing:

- Set the server application to run in fullscreen mode with the flag --window max or --window full with either your Steam Launch Options or in the Window's application's properties screen. For some reason players ending their turn wont be recognized server side until the game window is put into focus on the server. So your screensaver for example will interfere with the game.
- Run at a lower resolution. Also turn down all graphics to their minimum setting.
- Leave the game on the player list; no map view. After all looking at the map would be cheating.
- Use the Server specific launcher in the SDK menu. 
- Run Steam in offline mode.
- On default windows update will restart your computer at 3AM. You will need to configure this so that you don't need to restart your game every other morning or so.

Setting up email notifications: 

The instructions for setting up an email notification on 2K's forums are correct. However you will still have to change some settings in Gmail once you have followed the steps provided. After getting the server options set up in the SDK you will need to log into Gmail and go to Settings>Forwarding and POP/IMAP. Here you need to disable IMAP.

After that you will need to go to the My Account page for your Google account (NOT Gmail, but the Google account itself). From there you need to go to My Account>Sign-in and Security>Connected Apps and Site and then turn on the option that says Allow Less Secure Apps. Otherwise when the turn bot goes to do its thing, you will just get an email instead saying that an unsecure app is trying to access your Gmail. This most likely happens because the emails sent out by your server are unencrypted.

This is what a turn notification looks like:

The game name reflects my frustration of dealing with over a week of server crashes.

Since the SDK tends to crash when Steam is in online mode, Steam notifications aren't really an option. As a result getting email notification on your phone is probably the best way to go about turn notifications as of right now.

The Server Application Get Stuck at "Retrieving Host Information":

On Windows 7 and Windows 10 the only solution to this problem for me was to get the server application to run via the Civilization V SDK launcher by starting it in Steam. Initially when I clicked "Dedicated Server - Launch a Pitboss server" from the SDK launcher nothing would happen. I also noticed that when I right clicked on the icons that I could create a shortcut for all the other applications, but not the CivilizationV_Server icon.

**I have no idea why this works** but you have to cut (not copy) the CivilizationV_Server application from the "..\SteamLibrary\steamapps\common\Sid Meier's Civilization V SDK" directory into the "..\SteamLibrary\steamapps\common\Sid Meier's Civilization V" directory. Then run the SDK launcher again and try to make a server shortcut. This time it should work. Then copy (not cut) the CivilizationV_Server application back into the \Dedicated Server directory. This trick worked for me on two separate machines. In all my years of tech support...

Once you launch the application you should only be on the retrieving host information screen for literally one second. A Windows Firewall popup should appear asking you if you want to allow the application to speak to the Internet.

Setting the Sid Meier's Civilization V SDK application to be run as an administrator might help. However you do not have to do this for the CivilizationV_Server application.

How can I run the game in a cloud server:


Someone by the name of CraftedCard developed a Civilization 5 dedicated server application that is runnable on a headless GPU-less Linux machine. Which means that you can now run the application  on a cloud server with no graphics card (you're still going to have to run the Civ server app using Wine even though the Civ client app runs on Linux). Benjamin Jordanou-Bailey has written an excellent guide on how to do just that here if you need a little hand holding with the setup. This is an excellent guide for someone who is new to spinning up cloud machines and containerization. The readme of CraftedCard's repository also has some interesting note on issues they ran into when developing the application, something you'll appreciate if you got this far. 

At the time of writing this article only Vanilla Civ V works using this method. 


Joining a pitboss game:

If you encounter a bug where a player or two are getting "error joining multiplayer session" it is probably because they don't have some small chunk of DLC that the game was hosted with. In this case it's best to remove that DLC option from the settings menu, even if you aren't using it. Otherwise the game may boot into vanilla Civ. The easiest way to tell if this happens is if you get the loading screen in the background that looks like the Atlas statue, and on game start you wont see tourism or faith.

If you listed your game as private other players will need to type in your IP and hit enter to connect. Otherwise if you are playing on a computer behind the same router or network as the server you will be be able to find the game listed under local network.

Sunday, November 17, 2013

Radio Lab Epidoes on Morality



NPR's Radio Lab show recently did a whole episode on Morality. The highlight of the show was a segment done by Amy O'leary in which she describes a game she played in elementary school called Homestead, described as a cross between Dungeons and Dragons and Monopoly, and how she managed to completely control the game and the other "citizens" (starts at 37:20). You can listen to the whole episode for free here.

Wednesday, July 3, 2013

Exploiting Blogger For Passwords

Disclaimer: I do not recommend doing this, and I am not responsible for any trouble you get in for doing this. This post is for educational purposes only. ETC ETC

While working on my site I stumbled upon a way one could harvest Google account passwords from a simple blog account. By setting up a Blogger page, you have the option to include a Google Friend Connect "Join this site" button widget complete with profile pictures of other members who have joined the site.

Look familiar?

At first, I was hesitant to post this, because this site uses the Google Friend Connect widget. Then I realized that no one has used to feature in almost a year, and that the number of users using the service have dropped off, while traffic to the site remained steady. That doesn't mean one could do this with any other sort of connect feature websites often have (Facebook, Reddit, etc).  Pointing out such flaws will hopefully make such services much more secure in the future, as it will hopefully be corrected in some way.

Clicking on the blue button prompts the user to input a Google, Twitter, or Yahoo account login and password. By simply misdirecting the path of the follow URL, one could then spoof the login page so that the information entered follows through to  malicious site. All one has to do is replicate the Google service login popup. No URL is displayed during the whole process.

Such a method has been used before. Mistyping the Craigslist URL might bring you to a page notifying you that you need to update your version of Adobe Flash. Everything from the color scheme used, the font, and the installer are all reminiscent of what Adobe uses for their flash program.

uh oh...

Of course, the URL supersavings.glidehomes.com should be a giant red flag! Following through with the install will almost certainly lead to viruses/maleware/adware. Another approach of this technique is exploited by the torpig botnet. Which university researches were able to take control of. THey learned that the botnet was spoofing online banking logins for major banks on the infected computers, then sending the login information to whoever owned the botnet. Pretty scary stuff.

Did Bots in Quake 3 "Learn" Pacifism?


Anon supposedly recreated the ending of Wargames


No. A 4chan post has been circulating the Internet recently, claiming that after four years on a server full of bots in a Quake 3 death match game, the bots learned that the best strategy was not to kill each other. Huffington Post jumped on the story, although they later updated the page admitting the story was a hoax. However, they did not explain why the story was fake. A major news outlet jumping on an anonymous 4chan copypasta should be a reflection of the current state of news today. 

The original 4chan thread. Click for large.
A whole thesis was published by ID Software in 2001 detailing the build and intricacies of the bots. Furthermore, in 2005 the Quake 3 source code was released under the GNU license, meaning anyone with a compiler could dig through the code. This should give us the tools necessary to scrutinize these claims.
Let us first take a look first at the original post:

"Quake 3 bots were designed off an artificial neural network.
They would effectively "think" to figure out the best way to do things. 
They would see which tactics worked and which didn't.
The longer they played the more they would learn about you, figuring out your patterns, and this would apply to other bots aswell. For all intents and purposes they were one of the first learning AI in a game.

When I found out that I set up a Quake 3 arena server on my pirating server just to have 16 bots over and over just to see how good they would get. 
I set the server up 4 years ago, it's been running the entire time, I forgot about it until this thread. I'm gonna go check on them."
From page 13 of the thesis on Quake AI:
Although neural networks can be useful in several areas in bot AI they are not used for the Quake III Arena bot.
John Carmack even tweeted a response to the claims being made:


The bots are programmed to react to players given reaction time and accuracy constraints given the particular map. The bots DO have an internal representation of the each map given the "volume" of the map. They are not self learning, and they do not aggregate information for use later. "Learning" might not even be an appropriate context for what the bots do. Instead, having your bots standing around is much more consistent with having a bug in the code. For example, the files could have reached a max size limit, and just stopped.

If each of his bot logs are 256 megs each, and there are 16 bots, loading 8 gigs of ram on a 32-bit computer game is implausible in the first place. Even if this guy had over 8 gigs or ram in his computer, he simply could not load all of that bot data in the first place. While the data could be loaded as needed into the rom, the thesis specifically states that not being able to load such specific data in a fast paced game was a limitation of the game, and why a neural network could not be used. Once again, from page 13 of the thesis:
It is also possible to train a neural network during gameplay, which allows the bot to acquire all kinds of knowledge. However training of a neural network is often a time consuming process. The learning capabilities of the neural network will often have to be limited due to the time constraints in a real-time application like a game.
Finally there are other aspects of the story that are bizarre. Who has a server running for four years and forgets about it? During that time the game never crashed; the electricity never went out? No screenshots or video of this situation exists? The particular conditions should be replicable, and could possibly take much less time than4 years to replicate. I am not saying that such a situation of pacifism is implausible, but this story is clearly a hoax.

Quake has almost always been predominantly a multi-player game, with AI rarely being a focus in lieu of graphics, networking, and game-play elements. The bots could still do some pretty impressive things however. They were able to parse per-determined chat sentences given certain environmental characteristics (p.57).

ex. 1

if
environmental change
then
if
bot wants to
chat
then
choose initial chat
use random strings in chat message
replace synonyms in chat message to add variation
output chat message
endif
endif
 
 ex. 2

if
bot receives a message
then
replace synonyms in the message
interpret message using match templates
if
match is found
then
perform action
else
if
messages is a chat message from another player
then
if
bot wants
to reply to this message
then
find a reply chat
use random strings in chat message
replace synonyms in chat message to add variation
output chat message
endif
endif
endif
endif
As mentioned before, the bots DO react to players given reaction time and accuracy constraints and traverse "nodes" in relation to the current map. In this way, the bots do "think", but they do not "learn". AI programming is still being developed interdependently for contemporary first person shooters, and none of them have replicated anything like this. It is not to say that something like this could never happen. But one should keep in mind the disclaimer pasted across the top of some 4chan boards. "The stories and information posted here are artistic works of fiction and falsehood. Only a fool would take anything posted here as fact."