IoGame

Ward Cunningham
January 30, 2004


IoGame is a small multi-user web-based computer game inspired by the card game Target and written as an entry for the first Io game programming contest. Click the illustrations in this document to see screen shots I made after my first of three coding weekends. You click the play buttons underneath goal cards to play matching cards from your hand. Goals vary in value so it may be worth delaying play until more valuable goals or better cards are available. Multiple players can retrieve hands from the same server and play them against the shared goal cards. In-memory records keep score for each visitor until the server is restarted. Check the IoGame's wiki page to find a game or see other's high scores.

Io supports a coroutine style threading that simplifies synchronization. Web requests are handled serially except for the statistical simulation associated with goal explanations. This computation allows other requests to be serviced between simulated hands.

Expect tracebacks when you play obsolete cards. These errors are harmless. I left this output in the game to show what my debugging environment looked like. Try mangling a url to get one for sure. Return to play to continue your game. The game is as much about learning Io as it is about playing cards. The objects link on the about page will show you what is going on inside by tracing through memory listing each object it encounters along with all the data in its slots.

You can get my BSD licensed source. Use it to makeup your own goals and play them with your friends. If you have ioServer running, try typing this at the command line to load and launch an IoGame server on your own computer.

	doString (
		URL clone setURL (
			"http://c2.com/~ward/io/IoGame/iogame.io"
		) fetch asString
	)
It will say "start" when it is done running its self-tests. Use http://localhost:8080 as the url to talk to your new game server.

The game's about page cites the inspiration for IoGame, Andy Daniel (spelt correctly now) and Steve Dekorte, the inventors of Target and Io respectively.
The page also says a few nice things about me, of course. Thanks are also due Josh MacKenzie of ThoughtWorks for pointing out Io. "Read about it on your own wiki" he said.

Those who read the source will notice that the program includes an innovative implementation of unit-testing that blurs the line, as Io does, between compile, build and run-time. The program was written using this and what I'll call the Test-Accelerated Development (TAD) method.

This is the build script I used. When it detects new source it logs the change, diffs the source, and restarts the server. Here is a transcript recorded while several new features were added. (Try view source if your browser doesn't display the transcript as text.)

Unlike traditional TDD, I wouldn't write tests until I felt myself slowing down. (Don't try this until you're good at TDD or you won't know what feeling your missing.) Slowdown happens soon enough but with fast compiles and the on-screen change log I never got so stuck that I couldn't assert my way out of it.