I am looking for some interesting projects to aid with my Haxe/OpenFL learning, and as a Go player, it’s only natural I’d like to build a goban.
Skip the bolded section if you know Go and want to get to the program planning:
For those who don’t know, Go is basically a board game played on a 19x19 grid in which black and white take turns placing stones (pieces) on the intersections of the board (not the squares) —on any spots they want.
The objective of the game is to end up having surrounded the most territory (intersection) in total with your stones. But stones can die (and when on the board, we call them “groups” even they’re alone). A stone has 4 liberties (spaces of life) around it (north, east, south and west), and is taken off the board when that number drops to zero—when there’s just one liberty left, it’s a state called “atari”, not that this matters at all. Groups extend their liberties by adding stones in a connected manner. Note that diagonal connection does not add liberties and is thus not true connection.
Go has very few actual rules, but I’ll mention them for avoiding design constraints in our design:
“ko” : If white or black captures a stone of the other player, but then that player could play right back into the spot where his stone used to be and capture white back, this is an infinite loop state called “ko” that is not allowed. Once the first person captures a stone in ko, the next player is not allowed to play there. They must play somewhere else for one turn, allowing the other player to fill the ko (put their own stone inside, turning it into a lump of one colour that cannot be played into anymore) or also play elsewhere. One strategy for fighting an important ko (if it’s worth a lot in the context of the board state) is to play a “ko threat”, a potentially meaningless move threatening to make a destructive/valuable follow-up and thus forcing the opponent’s hand. This makes a turn go by, so you can take the ko again if you like. This is just strategy I’m telling you all about.
Another rule is the “suicide rule”: You cannot play into a spot where your group would start off with zero liberties. You’re still allowed to play inside your opponent’s territory though, as long as you get liberties. This can be: invading to try to live inside, playing inside as an elaborate way of eventually capturing them, or playing stupid moves in their territory that simply become their prisoners. All of those are of course allowed.
The suicide rule does not apply when you would be capturing the opponent, thus freeing up some liberties for the stone being placed. This is allowed; the capture of them precedes the suicide of your stone. This work in “ko”, as explained earlier, a perfect example. Ko is when you play into a spot where you would have zero liberties, but can because your opponent’s stone is thereby reduced by zero liberties and taken off first.
At the end of the game, all of the enemy stones you’ve captured get added into the territory of that colour (on each empty intersection), thereby reducing it. In other words, each capture is worth one point of territory, but rather than adding to your score, it will reduce your opponent’s score (same thing though, right?). Remember that the stones you have on the board are not points, only the intersections they’ve surrounded for you are points (unless your groups are dead, in which case they should have been taken off the board before scoring so that the opponent can add them to the prisoner pile, then use them to fill up your territory).
Surrounding territory is a lot easier than capturing enemy stones, so in high-level games there are even some games where no one is captured at all. In most cases though, at least a few stones are captured in the course of a game. Since players know that each capture is just one point in value, they’ll often allow themselves to be captured because the best thing to do is always to take what’s worth most. Many moves to simply extend territory will be worth 10, 20, or even more points than that (in one move).
It gets complicated to explain life and death (eg. how one might survive invading enemy territory, and how one may be captured even if he/she had made some territory with the group), but we don’t need to get into that because it’s actually related to the suicide rule (just in a more advanced way).
Planning the program:
Let’s get straight to it - can some of you suggest the best way to implement a simple working Go board in Haxe / OpenFL? For example, starting with an abstract plan (how to make the board, how to make the stones, how to deal with the interactions (basic, Go-soecific) and getting more detailed after that. Please explain it in a way a Haxe/OpenFL noob can understand (I’ve done a little bit so far, but I’m still basically at the "let’s make a circle with a click event! " stage.
I would prefer solutions that are simple (if not elegantly simple), but I’ll accept anything as long as it puts me in the right direction and keeps this project small. This can be a group project though, so when thinkinf og it that way, I don’t mind complexity.