public static GTPInternalResponse GTPProtectedLiberties(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() < 1) return MissingParametersResponse(); Color lColor = new Color(); if (!gtpCommand.GetParameter(0, ref lColor)) return InvalidParameterResponse(); StringBuilder s = new StringBuilder(512); for (int x = 0; x < gtpGoBoard.Board.BoardSize; x++) for (int y = 0; y < gtpGoBoard.Board.BoardSize; y++) if (gtpGoBoard.Board.IsProtectedLiberty((gtpGoBoard.At(x, y)), lColor)) { if (s.Length != 0) s.Append(' '); s.Append(gtpGoBoard.ToString(x, y)); } return new GTPInternalResponse(true, s.ToString()); }
public static GTPInternalResponse GTPFinalStatusList(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() < 1) return MissingParametersResponse(); string lString = gtpCommand.GetParameter(0).ToLower().Trim(); SafetyFlag lSafetyFlag; switch (lString) { case "dead": lSafetyFlag = SafetyFlag.Dead; break; case "alive": lSafetyFlag = SafetyFlag.Alive; break; case "white_territory": lSafetyFlag = SafetyFlag.White | SafetyFlag.Territory; break; case "black_territory": lSafetyFlag = SafetyFlag.Black | SafetyFlag.Territory; break; case "w_territory": lSafetyFlag = SafetyFlag.White | SafetyFlag.Territory; break; case "b_territory": lSafetyFlag = SafetyFlag.Black | SafetyFlag.Territory; break; case "dame": lSafetyFlag = SafetyFlag.Dame; break; case "seki": lSafetyFlag = SafetyFlag.Seki; break; case "undecided": lSafetyFlag = SafetyFlag.Undecided; break; case "unsurroundable": lSafetyFlag = SafetyFlag.Unsurroundable; break; default: return new GTPInternalResponse(false, "error"); } StringBuilder s = new StringBuilder(512); for (int x = 0; x < gtpGoBoard.Board.BoardSize; x++) for (int y = 0; y < gtpGoBoard.Board.BoardSize; y++) if (gtpGoBoard.Board.GetSafetyStatus((gtpGoBoard.At(x, y))).CompareTo(lSafetyFlag)) { if (s.Length != 0) s.Append(' '); s.Append(gtpGoBoard.ToString(x, y)); } return new GTPInternalResponse(true, s.ToString()); }