Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public void AddNewMoveAndFight(GoMoveClass move_val)
        {
            this.debugIt(true, "AddNewMoveAndFight", "Move = " + move_val.MoveInfo());

            if (move_val.TurnIndex() != this.theTotalMoves + 1)
            {
                this.logitIt("AddNewMoveAndFight", "duplicated move received *****************");
                return;
            }

            if (this.theGameIsOver)
            {
                this.abendIt("AddNewMoveAndFight", "theGameIsOver");
                return;
            }

            this.thePassReceived = false;
            this.BoardObject().ClearLastDeadStone();
            this.insertMoveToMoveList(move_val);
            this.FightObject().EnterBattle(move_val);
            this.theNextColor = GoDefineClass.GetOppositeColor(move_val.MyColor());
        }
Exemplo n.º 3
0
        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();
        }