tweetstones: Play a simple game via Twitter
It’s been a while since I did anything remotely interesting, insofar as software is concerned. it is for this reason that I present to you… Tweetstones!
What is it and how it works
Stones is a game, a variation of the mathematical strategy game called Nim. You can read about Nim on Wikipedia.
If you’re already familiar with the rules, you can skip ahead to gameplay specifics. All you’ll need to know is that this is a normal-play, three-heap game with a maximum of 10 items in the heaps (called piles here).
For those of you unfamiliar with the game, the play proceeds in this way: Player 1 challenges player 2 to a game. The objective of the game is to be the player to remove the final stone from the game board. A random number of stones will appear in each of the three game piles, and you take turns removing them until one of you takes away the last one and wins.
To show an example, let us say that I (sean) challenge my trusty imaginary friend george to a game. the stones appear, and I see that the first pile, Pile A, only has 1 stone. the second, pile B, has 5, and the third pile has 10.
George gets to make his move first, as I challenged him to the game. he decides to be greedy and empty out pile C - so he takes 10 stones away from it.
It now moves to my turn, but the piles are now 1, 5 and 0. C has been emptied, so my choices have been limited to 2 piles.
If I decide to take the single stone from pile A, play would shift back to George. In this instance, he’d be left with 5 stones but in only one pile, so he could quite easily empty the board and win, the lucky devil.
As you can see, the game play is quite straightforward. Stones is one of my trademark “hello world” programs - which means I’ve written it in numerous programming languages throughout the years. This one is a little different to the others i’ve done, though - you play it entirely through twitter!
Gameplay specifics
so now you know the rules. you’re dying to start playing, but haven’t a clue how to go about it. Well, never fear, because I am going to reveal all.
As already mentioned, this is a twitter game. you’ll need to follow tweetstones to play.
When you’ve done that, you’ll need to ask tweetstones to follow you. send a public tweet to tweetstones saying “follow me” and you should be ready to go. It will reply to you (so you’ll see it in your mentions timeline) and then you’ll know you can start.
To initiate a game, you send a direct message with the word “challenge” followed by a username. This is where things may be a little slow to start with because tweetstones needs followers and other people to get involved so you can play with them. if you try to start a game with someone who isn’t following tweetstones or hasn’t asked to be followed, it won’t work and you’ll have to try someone else.
This may slow your games to start with, but it means that if you don’t want to be bothered by the game, you can unfollow it and be troubled no longer. if you are following and are looking for players, keep an eye on Tweetstones’ tweets. it will announce each time someone wins a game and who they played with, so you can get some usernames that way.
If you’ve been challenged to a game you will receive a direct message with the numbers of stones in your piles. Playing the game is done through direct messages, so you simply respond with a command like “take 2 stones from pile A”, or “3 from C”, etc. You can send “show the piles” to refresh your memory on the numbers in each pile.
If you have requested a game with someone but they aren’t playing, you can use the “abort game” direct message to stop playing. Aborted games do not increase your win total or games played, but can become annoying for your opponents. For example if you started a game with me just as I went off to work, I may not respond for a good few hours. it is important to be patient. Remember that if you feel pestered you can simply unfollow the game to stop any and all requests; it is an opt-in bit of fun only.
Also worth remembering is that the game can only check for direct messages once in any 60 second period. Given the speed of the players it could therefore take a few minutse for each move to be processed. You should be sparing with your direct messages and wary of sending moves without having carefully read game updates lest you find yourself making mistakes!
Finally, of note is the fact that twitter, though very popular, can never be 100% stable. Sometimes messages won’t go through, may be delayed, or may not quite do what you expect. This is beta software, untried, untested, and written for a bit of fun and shouldn’t be relied upon for anything more serious than that.
All warnings out of the way, why not follow tweetstones, ask it to follow you and challenge someone? You might just win!
December 8th, 2009 at 4:48 pm
OK, have just followed tweetstones to give it a try. Just waiting for some user to challenge.
December 12th, 2009 at 3:21 pm
How did you program this? It would be cool to have an offline version, did you eve make one?
Thanks!