public static GTPInternalResponse GTPUnconditionalStatus(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() < 1) return MissingParametersResponse(); string lPoint = gtpCommand.GetParameter(0); return new GTPInternalResponse(true, gtpGoBoard.Board.GetSafetyStatus((gtpGoBoard.At(lPoint))).GTPString); }
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 GTPSetFreeHandicap(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { gtpGoBoard.Board.ClearBoard(); gtpGoBoard.SearchEngine.GoalBase = null; foreach (string lPoint in gtpCommand.ParameterParts) if (!gtpGoBoard.Board.PlayStone(gtpGoBoard.At(lPoint), Color.Black, false)) return new GTPInternalResponse(false, "unknown error"); return new GTPInternalResponse(); }
public static GTPInternalResponse GTPPlay(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() < 2) return MissingParametersResponse(); Color lColor = new Color(); if (!gtpCommand.GetParameter(0, ref lColor)) return InvalidParameterResponse(); string lPoint = gtpCommand.GetParameter(1); if (gtpGoBoard.Board.PlayStone((gtpGoBoard.At(lPoint)), lColor, true)) return new GTPInternalResponse(); else return new GTPInternalResponse(false, "invalid move"); }
public static GTPInternalResponse GTPPlaySequence(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() % 2 != 0) return MissingParametersResponse(); for (int i = 0; i < gtpCommand.GetParameterCount() / 2; i++) { Color lColor = new Color(); if (!gtpCommand.GetParameter(i * 2, ref lColor)) return InvalidParameterResponse(); string lPoint = gtpCommand.GetParameter((i * 2) + 1); if (!gtpGoBoard.Board.PlayStone((gtpGoBoard.At(lPoint)), lColor, true)) return new GTPInternalResponse(false, "invalid move - " + lPoint); } return new GTPInternalResponse(); }
public static GTPInternalResponse GTPGoalSave(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() < 1) return MissingParametersResponse(); string lPoint = gtpCommand.GetParameter(0); gtpGoBoard.SearchEngine.GoalBase = new GoalSave(gtpGoBoard.Board, gtpGoBoard.At(lPoint)); return new GTPInternalResponse(true); }
public static GTPInternalResponse GTPIsLegal(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() < 2) return MissingParametersResponse(); Color lColor = new Color(); if (!gtpCommand.GetParameter(0, ref lColor)) return InvalidParameterResponse(); string lPoint = gtpCommand.GetParameter(1); return new GTPInternalResponse(true, gtpGoBoard.Board.IsLegal(gtpGoBoard.At(lPoint), lColor) ? "1" : "0"); }
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()); }
public static GTPInternalResponse GTPDumcolorEnclosedRegion(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() < 1) return MissingParametersResponse(); string lPoint = gtpCommand.GetParameter(0); string lResponse = gtpGoBoard.Board.ToStringEnclosedBlockDump(gtpGoBoard.At(lPoint)); return new GTPInternalResponse(true, lResponse); }
public static GTPInternalResponse GTPCountLib(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() < 1) return MissingParametersResponse(); string lPoint = gtpCommand.GetParameter(0); int lLiberties = gtpGoBoard.Board.GetBlockLibertyCount((gtpGoBoard.At(lPoint))); return new GTPInternalResponse(true, lLiberties.ToString()); }
public GTPInternalResponse GTPWhatColor(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() < 1) return MissingParameterResponse(); string lPoint = gtpCommand.GetParameter(0); Color lColor = gtpGoBoard.Board.Cells[gtpGoBoard.At(lPoint)].Color; if (lColor.IsEmpty) return new GTPInternalResponse(true, "empty"); else if (lColor.IsBlack) return new GTPInternalResponse(true, "black"); else if (lColor.IsWhite) return new GTPInternalResponse(true, "white"); return new GTPInternalResponse(false, "unknown error"); }
public static GTPInternalResponse GTPBlack(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand) { if (gtpCommand.GetParameterCount() < 1) return MissingParametersResponse(); string lPoint = gtpCommand.GetParameter(0); if (gtpGoBoard.Board.PlayStone((gtpGoBoard.At(lPoint)), Color.Black, true)) return new GTPInternalResponse(); else return new GTPInternalResponse(false, "invalid move"); }