Example #1
0
        /**
         * This method will remove a captured group
         * Each stone in the group is removed from the board and added as a liberty for all other groups
         */
        private void Capture(AbGroup capturedGroup, State color)
        {
            foreach (Coord coord in capturedGroup.GetStones())
            {
                // Update the board and add the capture
                _gridStones[coord.Column, coord.Row] = State.None;
                _gridGroups[coord.Column, coord.Row] = 0;
                switch (color)
                {
                case State.Black:
                    _capBlack++;
                    break;

                case State.White:
                    _capWhite++;
                    break;

                case State.None:
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(color), color, null);
                }
                // Update all groups liberties/adjacent data
                foreach (Group g in _groups.Values)
                {
                    g.RemoveStone(coord);
                }
            }
            // Remove the group from the board
            DeleteGroup(capturedGroup);
        }
Example #2
0
        public override void MergeGroup(AbGroup slaveGroup)
        {
            _stones.UnionWith(slaveGroup.GetStones());
            _liberties.UnionWith(slaveGroup.GetLiberties());
            _adjacent.UnionWith(slaveGroup.GetAdjacent());

            foreach (Coord coord in _stones)
            {
                _liberties.RemoveWhere(c => c.Row == coord.Row && c.Column == coord.Column);
            }
        }