Exemple #1
0
        public BitPlane Xor(BitPlane bitPlane)
        {
            var result = new BitPlane(Width, Height);

            result.bitArray = bitArray.Xor(bitPlane.bitArray);
            return(result);
        }
Exemple #2
0
        public BitPlane Copy()
        {
            var bitPlaneCopy = new BitPlane(Width, Height);

            bitPlaneCopy.bitArray = bitArray.Clone() as BitArray;
            return(bitPlaneCopy);
        }
Exemple #3
0
 public void EnsureDeadStones()
 {
     if (DeadStones == null)
     {
         DeadStones = new BitPlane(boardSize);
     }
 }
Exemple #4
0
        public static BitPlane operator -(BitPlane leftPlane, BitPlane rightPlane)
        {
            var result = new BitPlane(leftPlane.Width, leftPlane.Height);

            for (var i = 0; i < leftPlane.bitArray.Count; i++)
            {
                if (leftPlane.bitArray[i] && !rightPlane.bitArray[i])
                {
                    result.bitArray[i] = true;
                }
                else
                {
                    result.bitArray[i] = false;
                }
            }
            return(result);
        }
Exemple #5
0
        public bool GroupIsDead(Stone stone)
        {
            if (HasStone(stone))
            {
                var bitPlane = new BitPlane(Black.Width,
                                            Black.Height);

                var stonesToCheck = new List <Stone>();
                stonesToCheck.Add(stone);

                while (stonesToCheck.Count > 0)
                {
                    var thisStone = stonesToCheck[0];
                    if (!bitPlane[thisStone.X, thisStone.Y])
                    {
                        bitPlane[thisStone.X, thisStone.Y] = true;

                        var nextStone = thisStone.TopStone();
                        if (HasStone(nextStone))
                        {
                            stonesToCheck.Add(nextStone);
                        }
                        else
                        {
                            if (StoneInBounds(nextStone.OtherColorStone()) &&
                                !HasStone(nextStone.OtherColorStone()))
                            {
                                return(false);
                            }
                        }

                        nextStone = thisStone.LeftStone();
                        if (HasStone(nextStone))
                        {
                            stonesToCheck.Add(nextStone);
                        }
                        else
                        {
                            if (StoneInBounds(nextStone.OtherColorStone()) &&
                                !HasStone(nextStone.OtherColorStone()))
                            {
                                return(false);
                            }
                        }

                        nextStone = thisStone.BottomStone();
                        if (HasStone(nextStone))
                        {
                            stonesToCheck.Add(nextStone);
                        }
                        else
                        {
                            if (StoneInBounds(nextStone.OtherColorStone()) &&
                                !HasStone(nextStone.OtherColorStone()))
                            {
                                return(false);
                            }
                        }

                        nextStone = thisStone.RightStone();
                        if (HasStone(nextStone))
                        {
                            stonesToCheck.Add(nextStone);
                        }
                        else
                        {
                            if (StoneInBounds(nextStone.OtherColorStone()) &&
                                !HasStone(nextStone.OtherColorStone()))
                            {
                                return(false);
                            }
                        }

                        stonesToCheck.Remove(thisStone);
                    }
                    else
                    {
                        stonesToCheck.Remove(thisStone);
                    }
                }

                return(true);
            }
            return(false);
        }
Exemple #6
0
 public Board(byte boardSize)
 {
     Black = new BitPlane(boardSize);
     White = new BitPlane(boardSize);
 }