示例#1
0
        public static int protocol_version(GTPBasics.SendAndRecieve sndRec)
        {
            string response = sndRec("protocol_version");

            return Convert.ToInt32(response);
        }
示例#2
0
        //Same as gen_move, but does not play the move
        public static Ent_vertex reg_genmove(string color, GTPBasics.SendAndRecieve sndRec)
        {
            List<Entity> entities = new List<Entity>();
            entities.Add(new Ent_color(color));
            string response = sndRec("genmove " + string.Join(" ", entities));

            if (response.ToLower() == "resign")
                return null;
            else
                return new Ent_vertex(response);
        }
示例#3
0
        public static List<Ent_vertex> place_free_handicap(int number_of_stones, GTPBasics.SendAndRecieve sndRec)
        {
            List<Entity> entities = new List<Entity>();
            entities.Add(new Ent_int(number_of_stones)); //Super OO just because might as well
            string response = sndRec("place_free_handicap " + string.Join(" ", entities));

            string[] delimitter = { " " };
            string[] parts = response.Split(delimitter, StringSplitOptions.RemoveEmptyEntries);

            List<Ent_vertex> vertices = new List<Ent_vertex>();
            for (int x = 0; x < parts.Length; x++)
                vertices.Add(new Ent_vertex(parts[x]));

            return vertices;
        }
示例#4
0
 //Unhandled error: "unacceptable size"!
 //coordinates are 0 based from bottom left of board
 public static void play(string color, int xPos, int yPos, GTPBasics.SendAndRecieve sndRec)
 {
     List<Entity> entities = new List<Entity>();
     entities.Add(new Ent_move(new Ent_color(color), new Ent_vertex(xPos, yPos)));
     sndRec("play " + string.Join(" ", entities));
 }
示例#5
0
 //Unhandled error message: "cannot undo"!
 public static void undo(GTPBasics.SendAndRecieve sndRec)
 {
     sndRec("undo");
 }
示例#6
0
        public static string SendAndReceiveReponse(string command_name, List<Entity> entities, GTPBasics.SendAndRecieve sndRec)
        {
            foreach (Entity entity in entities)
                command_name += " " + entity.ToString();

            return sndRec(command_name);
        }
示例#7
0
 public static void komi(float new_komi, GTPBasics.SendAndRecieve sndRec)
 {
     List<Entity> entities = new List<Entity>();
     entities.Add(new Ent_float(new_komi)); //Super OO just because might as well
     sndRec("komi " + string.Join(" ", entities));
 }
示例#8
0
 public static void time_left(
     string color, int time, int stones, GTPBasics.SendAndRecieve sndRec)
 {
     List<Entity> entities = new List<Entity>();
     entities.Add(new Ent_color(color));
     entities.Add(new Ent_int(time));
     entities.Add(new Ent_int(stones));
     sndRec("time_left " + string.Join(" ", entities));
 }
示例#9
0
        public static List<Ent_vertex> final_status_list(string status, GTPBasics.SendAndRecieve sndRec)
        {
            List<Entity> entities = new List<Entity>();
            entities.Add(new Ent_string(status)); //Super OO just because might as well
            string response = sndRec("final_score " + string.Join(" ", entities));

            string[] delimitter = { " " };
            string[] parts = response.Split(delimitter, StringSplitOptions.RemoveEmptyEntries);

            List<Ent_vertex> vertices = new List<Ent_vertex>();
            for (int x = 0; x < parts.Length; x++)
                vertices.Add(new Ent_vertex(parts[x]));

            return vertices;
        }
示例#10
0
 public static bool known_command(string command_name, GTPBasics.SendAndRecieve sndRec)
 {
     List<Entity> entities = new List<Entity>();
     entities.Add(new Ent_string(command_name)); //Super OO just because might as well
     return (new Ent_boolean(sndRec("known_command " + string.Join(" ", entities)))).data;
 }
示例#11
0
 //Unhandled error message: "cannot score"!
 public static string final_score(GTPBasics.SendAndRecieve sndRec)
 {
     return sndRec("final_score");
 }
示例#12
0
 public static void clear_board(GTPBasics.SendAndRecieve sndRec)
 {
     sndRec("clear_board");
 }
示例#13
0
 //Unhandled error: "unacceptable size"!
 public static void boardsize(int size, GTPBasics.SendAndRecieve sndRec)
 {
     List<Entity> entities = new List<Entity>();
     entities.Add(new Ent_int(size)); //Super OO just because might as well
     sndRec("boardsize " + string.Join(" ", entities));
 }
示例#14
0
 public static void set_free_handicap(List<Ent_vertex> vertices, GTPBasics.SendAndRecieve sndRec)
 {
     List<Entity> entities = new List<Entity>(vertices);
     sndRec("set_free_handicap " + string.Join(" ", entities));
 }
示例#15
0
        public static string[] list_commands(GTPBasics.SendAndRecieve sndRec)
        {
            string response = sndRec("list_commands");

            char[] delimitters = { GTPBasics.LF, GTPBasics.HT, GTPBasics.SPACE }; //I am not entirely sure, but I think just tabs (HT) will be enough
            return response.Split(delimitters, StringSplitOptions.RemoveEmptyEntries);
        }
示例#16
0
 public static string showboard(GTPBasics.SendAndRecieve sndRec)
 {
     return sndRec("showboard");
 }
示例#17
0
 public static void loadsgf(string filename, int move_number, GTPBasics.SendAndRecieve sndRec)
 {
     List<Entity> entities = new List<Entity>();
     entities.Add(new Ent_string(filename));
     entities.Add(new Ent_int(move_number));
     sndRec("loadsgf " + string.Join(" ", entities));
 }
示例#18
0
 //Unhandled syntax errors!
 public static void time_settings(
     int main_time, int byo_yomi_time, int byo_yomi_stones, GTPBasics.SendAndRecieve sndRec)
 {
     List<Entity> entities = new List<Entity>();
     entities.Add(new Ent_int(main_time));
     entities.Add(new Ent_int(byo_yomi_time));
     entities.Add(new Ent_int(byo_yomi_stones));
     sndRec("time_settings " + string.Join(" ", entities));
 }
示例#19
0
 public static string name(GTPBasics.SendAndRecieve sndRec)
 {
     return sndRec("name");
 }
示例#20
0
 public static string version(GTPBasics.SendAndRecieve sndRec)
 {
     return sndRec("version");
 }
示例#21
0
 public static string SendAndReceiveReponse(string command_name, GTPBasics.SendAndRecieve sndRec)
 {
     return SendAndReceiveReponse(command_name, new List<Entity>(), sndRec);
 }