private int killOtherColorGroups(GoMoveClass move_val, GoGroupClass my_group_val) { int count; count = this.killOtherColorGroup(my_group_val, move_val.X() - 1, move_val.Y()); count += this.killOtherColorGroup(my_group_val, move_val.X() + 1, move_val.Y()); count += this.killOtherColorGroup(my_group_val, move_val.X(), move_val.Y() - 1); count += this.killOtherColorGroup(my_group_val, move_val.X(), move_val.Y() + 1); return(count); }
private GoGroupClass insertStoneToGroupList(GoMoveClass move_val) { GoGroupListClass g_list; if (move_val.MyColor() == GoDefineClass.GO_BLACK_STONE) { g_list = this.blackGroupList(); } else if (move_val.MyColor() == GoDefineClass.GO_WHITE_STONE) { g_list = this.whiteGroupList(); } else { this.abendIt("insertStoneToGroupList", move_val.MoveInfo()); return(null); } GoGroupClass group = g_list.FindCandidateGroup(move_val.X(), move_val.Y()); if (group == null) { group = new GoGroupClass(g_list); group.InsertStoneToGroup(move_val.X(), move_val.Y(), false); g_list.InsertGroupToGroupList(group); return(group); } group.InsertStoneToGroup(move_val.X(), move_val.Y(), false); int dummy_count = 0; GoGroupClass group2; while (true) { group2 = g_list.FindOtherCandidateGroup(group, move_val.X(), move_val.Y()); if (group2 == null) { break; } dummy_count += 1; group.MergeWithOtherGroup(group2); g_list.RemoveGroupFromGroupList(group2); } if (dummy_count > 3) { this.abendIt("insertStoneToGroupList", "dummy_count"); } return(group); }
public void EnterBattle(GoMoveClass move_val) { this.debugIt(true, "enterBattle", move_val.MoveInfo()); this.BoardObject().AddStoneToBoard(move_val.X(), move_val.Y(), move_val.MyColor()); GoGroupClass my_group = this.insertStoneToGroupList(move_val); if (my_group == null) { this.abendIt("enterBattle", "fail in insertStoneToGroupList"); return; } int dead_count = this.killOtherColorGroups(move_val, my_group); if (!my_group.GroupHasAir()) { this.removeDeadGroup(my_group); } if (dead_count != 0) { if (move_val.MyColor() == GoDefineClass.GO_BLACK_STONE) { this.BoardObject().AddBlackCapturedStones(dead_count); } else if (move_val.MyColor() == GoDefineClass.GO_WHITE_STONE) { this.BoardObject().AddWhiteCapturedStones(dead_count); } else { this.abendIt("enterBattle", "bad color"); } } this.abendEngine(); }