raganwald / wood_and_stones

Use your iPad as a Goban
http://raganwald.github.com/wood_and_stones/
29 stars 2 forks source link

Wood & Stones

Go is "an ancient oriental board game for two players that is noted for being rich in strategy despite its simple rules." I tried to learn Go recently, and it was a rich and rewarding personal experience to struggle with my inability to play at even a novice level. I received a lot of great feedback about that post, including a nice comment from Dave Peck, who pointed me to his weekend project, Dave Peck's Go.

The sense of adventure in finding things out can be experienced in many different ways. Learning to play less poorly is one way. Another is to write a game playing algorithm, something that has fascinated me since I wrote a Maharajah and the Sepoys playing game in BASIC back at St. Andrews' College in 1977. A third is to write a server that adjudicates play between two humans. This is clearly less difficult but still provides opportunities for creativity and expression, which is why it is a favourite interview question.

So, here is "Wood & Stones," a pass and play local web application that adjudicates a game of Go between two players. This is an ongoing work, with both feature design, UX design, and software design changing on an almost daily basis. That is a long-winded way of saying that IMHO the code is nearly complete crap. It is as if you picked up an architect's sketch pad and looked at a page to find it covered with scribbles and cross-outs.

This is written specifically for the iPad at this time. I also test it on OS X Safari. Updated stylesheets for the iPhone/iPod Touch are in the works. I have made no attempt to test it on any other OS or browser. This is a pass-and-play application: It's for playing face-to-face with someone, not for playing the computer or playing with someone over the Internet (Issue 250). It turns an iPad into a portable go board that knows something about legal moves, can set up pieces for you, and allows you to go back and review the game.

help with playing

To start a new game, open Wood & Stones using your iPad (it used to work just fine on iPhone, but I haven't gotten around to selecting the correct style sheet depending on whether you're on an iPhone or an iPad. Issue 275!):

Start

If you want, you can give nicknames for each player. If you don't, you will be "Black" and "White" respectively.

Choose game to play, a board size, and setup. "Classic Go" is exactly what you think it is. The other options are why I had the stones to call this "Wood & Stones." Click "play" and you can start your game.

White to Play

In direct violation of The Design of Everyday Things, Wood & Stones is an experiment with removing the visible affordances in the User Interface. I am trying to make as much as possible work with gestures like swiping the screen or drawing simple symbols.

When it's your turn to play, tap the intersection where you wish to play a stone. If your play kills any of your opponent's stones, they will fade from sight. If you like your play, pass the iPad to your opponent and it's their turn. If you don't like your play, "scrub" the board by swiping rapidly from left to right to left three or more times. It will be your turn again and you can tap a different intersection. You can undo multiple times if you want.

To pass, draw an "X" using three continuous strokes of your finger:

Pass Gesture

If it is the second pass, you will be asked to confirm that you wish to end the game. Yes, you can scrub to undo a pass. If a game ends with two passes, it's up to you and your opponent to figure out who won.

history and info

If you would like to see a history of the game, you move backwards in time by swiping from left to right. This is like moving the film so that the past becomes visible. Each swipe from left to right moves back one move. You can move forward in the history by swiping from right to left. Once you have returned to the current move, swiping right to left does nothing further.

You can see the game's current status by swiping towards the bottom of the screen:

Show Info

The game info will slide down from the top of the screen:

Game Info

To go back to the play of the game, swipe towards the top of the screen:

Return to Play

zooming and dragging

With larger boards, it can be a challenge to tap the correct stone location on an iPhone or iPod Touch. To zoom in, hold your finger or mouse down on the board. After a moment, the board will zoom. While zoomed in, you can tap to place a stone or drag the board to pan it around. When zoomed in, you cannot go back or forward in the history as the swipe becomes a pan. To zoom back out, hold your finger or mouse down again.

On multi-touch devices, you can also use the pinch gesture to zoom in or out.

games with standard rules and victory conditions

The application is specifically written to support other games, most of which are documented on Sensei's Go Variant Page. Each game offers a variety of setup options. The most 'normal' games to the Go player are those that have the exact same rules and victory conditions, namely territory plus captures. They differ only in how the board is set up at the beginning of play.

Classic: This is the standard game of Go with the standard options for setup: Either black plays first, or black is awarded a handicap of between two and nine stones and white plays first. Handicap stones are placed on the Hoshi points in the conventional manner. Wood & Stones does not score the game but it will end the game after two consecutive passes.

Free Placement: This is also the standard rules for Go, however if black is granted a handicap, black plays the stones wherever he likes rather than having them placed on the standard Hoshi points. For example, if black is given a handicap of three stones, he will play the first three moves in a row and then white will play and the turns will alternate in the normal fashion for the remainder of the game.

More Setups: Once again the rules are the standard rules of Go, however the initial setup differs radically from tranditional Go. The options include:

games where white is trying to live

Some games have standard rules but different victory conditions. A number of these games share the common theme of a struggle for white to survive against crushing odds. In these games, white wins if he can create life. Black wins the moment there are no white stones on the board.

other games with non-standard victory conditions

games with slightly different rules

code confessions, a/k/a estimating the WTFs per LOC

This is my first jQuery project, and it shows. I'm also using jQTouch, although I'm using less and less of it as I get more comfortable with Mobile Safari. I've picked up a few other jQuery plugins, including my own iGesture for gestures like swipes and scrubs.

license terms

(c) 2010 Reg Braithwaite. All rights to the entirety of the program and the parts I have written are reserved with the exception of specific files otherwise licensed. Other licenses apply only to the files where they appear. This may change in time, check back.

Exemptions include iGesture and Dragscrollable, which I have licensed under the MIT license, plus various jquery plugins written by others.

All of the images used in the main game board are modified versions of files Dave Peck found on the Wikimedia Commons. These are distributed with the Creative Commons Attribution 2.0 ShareAlike license. Some other images were hand-drawn by Dave Peck, who put them under the Creative Commons Attribution ShareAlike 2.0 license: http://creativecommons.org/licenses/by-sa/2.0/