Search

Thursday, August 23, 2012

Day 15: Killing groups


Now that the engine can see groups and count liberties (and see where are the liberties), the obvious step is to see if a group is killed. Basically when someone plays the board will look using the ruleset if any group have 0 liberties. If it is the case, all those positions becomes empty (value of the position = 0), and the number of dead stones should increase to a "dead stones" variable for the outsider or the engine.

This is the "search for liberties" method (I didn't publish it yesterday, you have it now):



I need a new method in the ruleset that analizes a group and if it have 0 liberties will return true. Else will return false.




And, the board should be the responsible of killing the stones. So, in the board class, I create a method that given a color It should see if there is any group without liberties:



And the last step: in the main board, when someone plays something (that is not "pass" or "resign") it should first see if there is something dead for the opposite color that is played and kill it.

No comments:

Post a Comment