public BitPlane Xor(BitPlane bitPlane) { var result = new BitPlane(Width, Height); result.bitArray = bitArray.Xor(bitPlane.bitArray); return(result); }
public BitPlane Copy() { var bitPlaneCopy = new BitPlane(Width, Height); bitPlaneCopy.bitArray = bitArray.Clone() as BitArray; return(bitPlaneCopy); }
public void EnsureDeadStones() { if (DeadStones == null) { DeadStones = new BitPlane(boardSize); } }
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); }
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); }
public Board(byte boardSize) { Black = new BitPlane(boardSize); White = new BitPlane(boardSize); }