Natural Election was inspired by our work on Hashtag Dungeon and Jordan’s work on the Twitter Aviary, a third year academic project at The University of Lincoln with Hitpoint Games as the client. We were sitting at the National Videogame Arcade in Nottingham about a week before the election and we were discussing what special things we could do for the election - we could cannibalize the analysis code from the Twitter Aviary to mock up a little game that analysed Twitter data about the general election.
Initially we thought about making a Space Invaders or Asteroids clone for the game, this would have been pretty simple to mock up in Unity’s 2D engine and we could have polished it up really nicely. Kieran suggested we try to make it more politically-oriented by creating a virtual parliament where MPs from all the different sides would beat the crap out of one another a la Gangbeasts - we all loved the idea so we set to making it.
Kieran’s initial idea was that since we have this real time Twitter data coming in “lets see if we can't pseudo predict the results” the goal wasn't necessarily to try and accurately predict the election, but instead what if politics was decided just by a big ol’ brawl that would hopefully be fun to watch.
Within a day or so Kieran had mocked up a houses of parliament with a bunch of funny-looking ragdoll MPs with heads the shape of burgers. The MPs essentially flopped towards one another like drunkards, flailing their arms in desperate attempts to smack each other around the face. It was awesome.
To show the Twitter connection more in the game we considered including some Twitter data such as the tweets themselves, display names etc however we decided against this as the game was going to be on public display and we did not want to risk having certain types of content appearing as the interactive exhibit would potentially be viewed by children.
Meanwhile, we had Alex Saye (who is currently working with us on Utopia-N, a game that uses Wikipedia data to source all its events) to program an awesome smart camera. He worked very hard to make it look as if it was being controlled by a news reporter - the camera would randomly zoom in and out and occasionally shook from side to side as it orbited the environment.
At this point it made sense to polish the game up a little by replacing the weird burger people with something slightly more relevant to the theme. Amelia George quickly built us a new model politician, who was based on Nintendo’s Miis and we popped that into the game as a replacement. The model had a grayscale suit on so we could change the colours to the relevant parties. We also added artwork by Jeff Strider to improve the UI and make it look less completely awful to look at.
Once the game was finished, I ran over to The National Videogame Arcade to hook it up to the big screen. We streamed the game over the whole day so people could watch the battle anywhere in the world. The game was well received by people within the building. We even had it played by comedian Dara O’Briain who was visiting the building on the day.
The Gritty Details
The API Search
To receive the #GE2015 tweets we used the Twitter API, specifically their search API which limited us to 100 tweets returned per call and 180 of those calls per 15 minutes. There were two reasons why we settled on the search API, firstly we already had the code available from the Twitter Aviary and secondly the game was wave based which meant it was suited in a way.
We could have used Twitter’s streaming API but decided against it due to time constraints mainly. We would have also been receiving a lot of data that we did not need as we only wanted the last 100 tweets.
We added the ability for people to tweet to the hashtag #NVAElection in order to spawn “super politicians” that would have higher health and attempt to turn the tide in favour of the tweeter’s chosen party. These super politicians were bigger than the rest of the politicians and we hoped they’d be noticeable above the rest of the fighting.
While the search API met our needs for retrieving election tweets it was limiting when it came to retrieving user tweets to the #NVAElection hashtag. To obey the rate limit rules for the API we had to set the search for every 25 seconds which meant in some cases there was a significant delay from a user posting a tweet to them seeing something happen on the screen.
This problem was exacerbated by a bug where super politicians would not be counted if the round ended before the tweet was found as the last found tweet time was reset at the end of each wave meaning they would not be counted.
It would have been great to make the super politicians a little more obvious. It was often the case people would tweet one in and they wouldn’t be able to see it in the massive cluster of politicians punching each other. If we’d had time I’d have looked at getting Amelia to design a politician with a fancy top-hat or a house of lords wig, either that or stick the party leader’s face onto the super politician’s face.
Not only were the super politicians not obvious enough, their announcement when spawning did not appear to be enough to give players the gratification of spawning one. When one was spawned their party name would flash the party colour, turn bold, show a ‘++’ for each new politician and fade back to how it originally was. Looking back we should have announced their entrance with either a bordered screen flash of the party colour or a literal announcement in the centre of the screen.
Order In The Court!
We wanted to make a unique interface for the game over at the NVA. Luckily we managed to source a gavel from the Galleries of Justice in Nottingham so that players could smack it and call the MPs to order. The main issue we had was trying to come up with a way to hook the gavel up to the game without making it obviously wired up and messy. We weren’t allowed to modify the gavel either because it was a “gift” apparently - so drilling holes into it was a no-go.
The first thing that sprang to mind was to hook the gavel up using foil and a MakeyMakey to send inputs directly to the computer, but this looked awful and tacky. We really wanted to hide the input method to make it look slightly more believable, so we looked at using piezoelectric transducers to detect the smacks on the gavel - this worked great for about half an hour before the wires snapped off and we couldn’t re-solder them on.
After these two methods failed miserably we decided to get a little bit more creative. We took inspiration from one of the exhibitions at the National Videogame Arcade which is all about jumping, in that exhibit there are pressure sensing mats to jump on made from foiled paper and foam, so we made a tiny version of one of these mats to go underneath the gavel. This worked wonderfully and we settled on that.
Everything Slowed Down...
We had the game running the night before the election day as a means of testing but to also collect some data so the game already had data to show to the early visitors to the NVA. This brought a bug to light where after a certain amount of waves the game would begin to slow down until at one point the game stopped. So the night before at 00:00 we had to very quickly try and find out why and get a new build ready and sent to the guys at the NVA.
We did this by adding some optimisations throughout the code that we didn’t have time to do before hand due to a deadline at 18:00 to get the game up and streaming. As we wouldn’t have any developers on site until later in the day we also added options to limit the amount of politicians that would spawn after a #GE2015 search.
The next morning the game was back up, streaming and playable with the new build. However further into the day the game began to slow down again. So the National Videogame Arcade crewmembers had to periodically reset the game throughout the day; luckily it wasn’t too frequent.
So what was the problem? 7 days (the excuse used for much of the project). When we were spawning in politicians we were assigning the colour of the spawned politician from a prefab which meant we were creating a new material each time. We learned after the event that Unity does not garbage collect materials and you have to unload them manually (or write better code).
Rather annoyingly a single line of code fixed the issue:
We could call that line at the end of each wave and the slowdown was removed. However with more time we would rather create a material and cache it for each party at the start of the game.
At times due to how our politicians were acting in the game environment our choices were limited which at times did create interesting and funny outcomes but also some interesting solutions.
As we were using rigid bodies and forces to move the politicians a traditional navigation mesh was out of the question as it would have made the movement to rigid and perfect when we wanted a different look to the game. Without one politicians would get stuck behind benches which would lead to politicians getting stuck in the benches. To solve this we added ‘push zones’ on the floors in between each bench so that if any politician was in that area they would always slowly be pushed towards the aisle.
Winning Was Unclear...
We also found that people who weren’t watching the win counter or were unfamiliar with the game were unsure who had won at the end of a round. This is because when there are only politicians from one party left, they all disappear ready for the next wave.
What we should have done at the very least is have a notifier on the screen stating which party had won. However to stay with the game’s theme what we would have done given more time is make the winning party do a little dance and cheer before disappearing and then start the next wave.
The Results Are In...
Shortly after the polls had closed at 10 PM we also stopped the game and the stream. In total the game ran for 634 waves, 16 waves short of 650 which interestingly is the amount of seats in the House of Commons; this was actually unintentional.
After stopping the game we created a graph to represent the wins of each party which included the percentages of wins. The next day when the results of the polls had been collated and a winner announced we compared those values to the values which the game produced. In the game the Conservatives won 36.9% of the time and in the polls they managed to secure 36.8% of the votes. A 0.1% difference! We were curious as to if the game would be close with any of the results but we did not expect it to be that close.
While the results were accurate for Conservatives the others varied in terms of accuracy. Green party was completely off and was the largest outlier in terms of accuracy to the real results. We assume this has something to do with the political makeup of Twitter users.
We are looking to develop this little game a bit further before the next election. We’re also looking at wiring it up to this year’s E3 hashtag to see which company “wins” the popular support of most Twitter users. We’d also like to hook it up to Twitch so that people watching the game streaming can interact with the game more directly.
If you're interested in knowing more about our projects including Natural Election then you can get in contact with any or all of us on Twitter:
We'd love to hear from you!