Exemplo n.º 1
0
 public GoBlocksAdjacentCollection(GoBlockBase goBlockBase)
 {
     AdjacentBlocks = new List<GoBlockBase>(10);
     AdjacentBlocksPosition = new List<int>(10);
     AdjacentBlocksCount = new List<int>(10);
     Block = goBlockBase;
 }
Exemplo n.º 2
0
        // area of bottleneck
        public void AssignCell(GoBlockBase goBlock)
        {
            if (goBlock == Block)
            {
                return;
            }

            foreach (GoCell lCell in Neighbors)
            {
                Block.AdjacentBlocks.Minus(lCell.Block);

                //lCell.OnNeighborChange(Block, goBlock);
                if (Block != goBlock)
                {
                    lCell.Block.AdjacentBlocks.Minus(Block);
                    lCell.Block.AdjacentBlocks.Plus(goBlock);
                }
            }

            // update Zobrish Hash
            if (Color != goBlock.BlockColor)
            {
                Board.ZobristHash.Delta(Color, Index);
                Board.ZobristHash.Delta(goBlock.BlockColor, Index);
            }

            Block = goBlock;
            Color = goBlock.BlockColor;

            foreach (GoCell lCell in Neighbors)
            {
                Block.AdjacentBlocks.Plus(lCell.Block);
            }
        }
Exemplo n.º 3
0
        // area of bottleneck
        public void AssignCell(GoBlockBase goBlock)
        {
            if (goBlock == Block)
                return;

            foreach (GoCell lCell in Neighbors)
            {
                Block.AdjacentBlocks.Minus(lCell.Block);

                //lCell.OnNeighborChange(Block, goBlock);
                if (Block != goBlock)
                {
                    lCell.Block.AdjacentBlocks.Minus(Block);
                    lCell.Block.AdjacentBlocks.Plus(goBlock);
                }
            }

            // update Zobrish Hash
            if (Color != goBlock.BlockColor)
            {
                Board.ZobristHash.Delta(Color, Index);
                Board.ZobristHash.Delta(goBlock.BlockColor, Index);
            }

            Block = goBlock;
            Color = goBlock.BlockColor;

            foreach (GoCell lCell in Neighbors)
                Block.AdjacentBlocks.Plus(lCell.Block);
        }
Exemplo n.º 4
0
 public GoBlocksAdjacentCollection(GoBlockBase goBlockBase)
 {
     AdjacentBlocks         = new List <GoBlockBase>(10);
     AdjacentBlocksPosition = new List <int>(10);
     AdjacentBlocksCount    = new List <int>(10);
     Block = goBlockBase;
 }
Exemplo n.º 5
0
        protected void Update(GoBlockBase goBlock, SafetyFlag safetyFlag)
        {
            SafetyStatus lSafetyStatus = new SafetyStatus(safetyFlag);

            foreach (int lIndex in goBlock.MemberList)
            {
                Safety[lIndex] = lSafetyStatus;
            }
        }
Exemplo n.º 6
0
        //        public int NeighborCnt;
        public GoCell(int index, GoBoard goBoard, GoEmptyBlock goEmptyBlock)
        {
            Board = goBoard;
            Color = Color.Empty;
            Block = goEmptyBlock;
            Index = index;

            Board.ZobristHash.Delta(Color, Index);
        }
Exemplo n.º 7
0
//		public int NeighborCnt;

        public GoCell(int index, GoBoard goBoard, GoEmptyBlock goEmptyBlock)
        {
            Board = goBoard;
            Color = Color.Empty;
            Block = goEmptyBlock;
            Index = index;

            Board.ZobristHash.Delta(Color, Index);
        }
Exemplo n.º 8
0
        public int GetBlockLibertyCount(int index)
        {
            GoBlockBase lGoBlock = Cells[index].Block;

            if (lGoBlock.IsEmptyBlock())
            {
                return(0);
            }

            return(((GoBlock)lGoBlock).LibertyCount);
        }
Exemplo n.º 9
0
        public bool IsSameString(int index1, int index2)
        {
            GoBlockBase lGoBlock1 = Cells[index1].Block;
            GoBlockBase lGoBlock2 = Cells[index2].Block;

            if (
                (lGoBlock1.IsEmptyBlock()) ||
                (lGoBlock2.IsEmptyBlock())
                )
            {
                return(false);
            }
            return(lGoBlock1 == lGoBlock2);
        }
Exemplo n.º 10
0
        // area of bottleneck
        public void Plus(GoBlockBase goBlock)
        {
            if (AdjacentBlocks.Count == 0)
            {
                Block.Board.AllBlocks.Add(Block);
            }

            int iIndex = AdjacentBlocksPosition.IndexOf(goBlock.BlockNbr);

            if (iIndex >= 0)
            {
                AdjacentBlocksCount[iIndex]++;
            }
            else
            {
                AdjacentBlocks.Add(goBlock);
                AdjacentBlocksPosition.Add(goBlock.BlockNbr);
                AdjacentBlocksCount.Add(1);
            }
        }
Exemplo n.º 11
0
        // area of bottleneck
        public void Minus(GoBlockBase goBlock)
        {
            int iIndex = AdjacentBlocksPosition.IndexOf(goBlock.BlockNbr);

            if (AdjacentBlocksCount[iIndex] == 1)
            {
                AdjacentBlocks.RemoveAt(iIndex);
                AdjacentBlocksCount.RemoveAt(iIndex);
                AdjacentBlocksPosition.RemoveAt(iIndex);
            }
            else
            {
                AdjacentBlocksCount[iIndex]--;
            }

            if (AdjacentBlocks.Count == 0)
            {
                Block.Board.AllBlocks.Remove(Block);
            }
        }
 public GoCellUndoChange(GoCell pGoCell)
 {
     // save changable properties of original object
     Cell  = pGoCell;
     Block = pGoCell.Block;
 }
Exemplo n.º 13
0
        // area of bottleneck
        public void Plus(GoBlockBase goBlock)
        {
            if (AdjacentBlocks.Count == 0)
                Block.Board.AllBlocks.Add(Block);

            int iIndex = AdjacentBlocksPosition.IndexOf(goBlock.BlockNbr);

            if (iIndex >= 0)
                AdjacentBlocksCount[iIndex]++;
            else
            {
                AdjacentBlocks.Add(goBlock);
                AdjacentBlocksPosition.Add(goBlock.BlockNbr);
                AdjacentBlocksCount.Add(1);
            }
        }
Exemplo n.º 14
0
        public ColorEnclosedRegion(GoEmptyBlock goEmptyBlock, Color defender)
        {
            Board    = goEmptyBlock.Board;
            Defender = defender;
            Size     = 0;
            Version  = 2004;

            _RegionNbr = goEmptyBlock.BlockNbr;

            Members                = new List <GoBlockBase>();
            EmptyBlocks            = new List <GoEmptyBlock>();
            Neighbors              = new List <GoBlock>();
            InteriorAttackerBlocks = new List <GoBlock>();

            Is2Vital = TriState.Unknown;
            Is1Vital = TriState.Unknown;
            IsSmall  = TriState.Unknown;

            _EnclosedArea = null;
            _EmptyRegion  = null;

            Stack <GoBlockBase> lWork = new Stack <GoBlockBase>();

            lWork.Push(goEmptyBlock);

            while (lWork.Count != 0)
            {
                GoBlockBase lGoBlockBase = lWork.Pop();

                if (!Members.Contains(lGoBlockBase))
                {
                    Members.Add(lGoBlockBase);

                    if (lGoBlockBase.IsEmptyBlock())
                    {
                        EmptyBlocks.Add((GoEmptyBlock)lGoBlockBase);
                        Size = Size + ((GoEmptyBlock)lGoBlockBase).EmptySpaceCount;
                    }
                    else
                    {
                        InteriorAttackerBlocks.Add((GoBlock)lGoBlockBase);
                        Size = Size + ((GoBlock)lGoBlockBase).StoneCount;
                    }

                    foreach (GoBlockBase lGoBlockBaseAdjacent in lGoBlockBase.AdjacentBlocks.AllBlocks)
                    {
                        if (lGoBlockBaseAdjacent.BlockColor == Defender)
                        {
                            if (!Neighbors.Contains((GoBlock)lGoBlockBaseAdjacent))
                            {
                                Neighbors.Add((GoBlock)lGoBlockBaseAdjacent);
                            }
                        }
                        else
                        if (!Members.Contains(lGoBlockBaseAdjacent))
                        {
                            lWork.Push(lGoBlockBaseAdjacent);
                        }
                    }
                }
            }

            EnclosingBlocks        = new List <GoBlock>(Neighbors.Count);
            InteriorDefenderBlocks = new List <GoBlock>();

            foreach (GoBlock lGoBlock in Neighbors)
            {
                bool lFound = false;

                foreach (GoEmptyBlock lGoEmptyBlock in lGoBlock.AdjacentBlocks.EmptyBlocks)
                {
                    if (!EmptyBlocks.Contains(lGoEmptyBlock))
                    {
                        lFound = true;
                        break;
                    }
                }

                if (lFound)
                {
                    EnclosingBlocks.Add(lGoBlock);
                }
                else
                {
                    InteriorDefenderBlocks.Add(lGoBlock);
                }
            }

            if (EnclosingBlocks.Count == 0)
            {
                InteriorDefenderBlocks.Clear();
            }
        }
Exemplo n.º 15
0
 public GoCellUndoChange(GoCell pGoCell)
 {
     // save changable properties of original object
     Cell = pGoCell;
     Block = pGoCell.Block;
 }
Exemplo n.º 16
0
        // area of bottleneck
        public void Minus(GoBlockBase goBlock)
        {
            int iIndex = AdjacentBlocksPosition.IndexOf(goBlock.BlockNbr);

            if (AdjacentBlocksCount[iIndex] == 1)
            {
                AdjacentBlocks.RemoveAt(iIndex);
                AdjacentBlocksCount.RemoveAt(iIndex);
                AdjacentBlocksPosition.RemoveAt(iIndex);
            }
            else
                AdjacentBlocksCount[iIndex]--;

            if (AdjacentBlocks.Count == 0)
                Block.Board.AllBlocks.Remove(Block);
        }
Exemplo n.º 17
0
        protected void Update(GoBlockBase goBlock, SafetyFlag safetyFlag)
        {
            SafetyStatus lSafetyStatus = new SafetyStatus(safetyFlag);

            foreach (int lIndex in goBlock.MemberList)
                Safety[lIndex] = lSafetyStatus;
        }