Search

Wednesday, August 22, 2012

Day 14: Liberties.


Now that I have the group, I can count liberties of the group. It is basically the same of finding groups. This time I will replace the while with the boolean variable with a for that covers the group array and if something surrounding the stone is a 0, then add it (if it was not added before).

Thing I noticed: There is a BIG bug I found. I don't know how I didn't see this before... Coordinate to position method is not working with numbers with more than 1 digit :(

Added a method to write the liberties number and coordinates.

Update: Solved the bug, just changed: 

row= Integer.parseInt(String.valueOf(coordinate.charAt(1)));
With:

row=Integer.parseInt(coordinate.substring(1,coordinate.length())); 

Next post will be about killing stones.

No comments:

Post a Comment