Ejemplo n.º 1
0
        public BitPlane Xor(BitPlane bitPlane)
        {
            var result = new BitPlane(Width, Height);

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

            bitPlaneCopy.bitArray = bitArray.Clone() as BitArray;
            return(bitPlaneCopy);
        }
Ejemplo n.º 3
0
 public void EnsureDeadStones()
 {
     if (DeadStones == null)
     {
         DeadStones = new BitPlane(boardSize);
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
 public Board(byte boardSize)
 {
     Black = new BitPlane(boardSize);
     White = new BitPlane(boardSize);
 }