Skunkworks – Twitter Project – Battleship!!
Posted by Steve Lounsbury on December 14th, 2009
Ben Watts and I were grouped together for this round of Skunkworks. Our idea was to figure out a way to port the board game Battleship onto twitter. The primary way of playing the game had to include twitter, a web interface could be used to augment the experience, but a player should be able to play entirely through twitter.
Enter BattleTwip!
We refined the objective of the game to fit better with the social media aspects of Twitter. Typically, a battleship game is played between two players in close proximity. Twitter includes millions of users all around the world. To limit the game to the traditional two players would be missing the opportunity to take advantage of the potential players on Twitter.
In order to make games playable by more users, our solution was to pit all of twitter against the “twitter bot” running the game. Once a new game was created, twitterers could take shots at the board and the bot would inform them if the shot was a hit or a miss.
At this point, we designed a high level flow diagram for the game in order to better understand the work flow involved. Click here to check out the flow chart.
The twitter bot would monitor tweets from players and scan them for moves. Once adding those moves to the game, it would update the players of the progress by tweeting about it. This solved the challenge of being able to play entirely over twitter.
Playing over twitter is great, but can you really be expected to keep track of all your moves from a list of tweets? In order to make the game easier to track and more fun to play, we created a web interface to display the general progress of the game. This displays all the recorded hits so far, a player leader board, and the latest tweets from the bot.
The Twitter Bot
Here’s the basic logic the twitter bot follows on each run:
- Load the current active game from the database.
- Use the Twitter API to look for battleship “shots” in @replies and direct messages from twitter users. Shots are considered any string that specifies a point on the battleship board. Examples of shots are “A3″ and “J10″.
- If any messages come from Twitter users that the bot is not currently following, requests will be sent to the API to follow these users. This will allow them to direct message the bot in the future.
- The collection of moves gathered from twitter is added to the current game. These moves are classified into one of three categories: miss, hit and sink.
- After moves are classified, the bot will tweet about each one and indicate if it was a hit or sink. Misses are simply claimed to have missed and the board position is not indicated.
Web Interface
So, playing battleship solely over twitter is great, but it doesn’t really lend itself to seeing the progress of the game. For this, we created a nice web frontend that displays the game progress on a battleship game board.
The web interface is built on top of the Zend Framework and uses AMF to provide the communication between flash and the backend.
Avoiding Twitter Spam
A common complaint about twitter based games is the level of spam they introduce into your twitter stream. Games like @playspymaster came under a lot of scrutiny for this when first released. They have since cleaned things up.
In order to avoid spamming people from the beginning, the following policies were adopted:
- Users can play the game by replying to the bot, or by direct messaging it. This means your followers won’t hate you for playing the game.
- The bot doesn’t do any questionable stuff like tweet on your behalf or give you points for tweeting about it.
How about a demo?
Sure! It’s up and running at http://76design.com/battletwip. Have fun, but remember this is definitely not ready for prime-time at this point :)
Where to go from here?
Battletwip was a great experience. It was fun using the twitter API to create a game. I think it has potential to be used, so we’re going to let people play with it a bit and see what feedback we get. We don’t have any grand plans at this point, but we’ll see what happens!









