Exemple #1
0
        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);
        }
Exemple #2
0
        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());
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        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");
        }
Exemple #5
0
        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();
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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");
        }
Exemple #8
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());
        }
Exemple #9
0
        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);
        }
Exemple #10
0
        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());
        }
Exemple #11
0
        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");
        }
Exemple #12
0
        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");
        }