示例#1
0
        protected static void SetAlphaBeta(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            searchEngine.SearchOptions.AlphaValue = Convert.ToInt32(parameters[0]);
            searchEngine.SearchOptions.BetaValue = Convert.ToInt32(parameters[1]);

            Respond(proxy, id);
        }
示例#2
0
        protected static void SetBoardSize(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            goBoard.SetBoardSize(Convert.ToInt32(parameters[0]));

            Respond(proxy, id);
        }
示例#3
0
 protected static void Respond(Worker.SendResponse proxy, string id, bool success, string message, bool async)
 {
     proxy((async ? "!" : "") + (success ? "=" : "?") + "\t" + id + "\t" + message);
 }
示例#4
0
        protected static void Search(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            Color color = Color.ToColor(parameters[0]);

            AsyncResponseHelper lAsyncResponseHelper = new AsyncResponseHelper(proxy, id);

            Respond(proxy, id);

            searchEngine.SimpleAsyncSearch(color, lAsyncResponseHelper.OnCompletion);
        }
示例#5
0
 public AsyncResponseHelper(Worker.SendResponse proxy, string id)
 {
     Proxy = proxy;
     ID = id;
 }
示例#6
0
        protected static void Abort(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            searchEngine.StopSearch();

            Respond(proxy, id);
        }
示例#7
0
 protected static void Respond(Worker.SendResponse proxy, string id)
 {
     Respond(proxy, id, true, string.Empty, false);
 }
示例#8
0
 protected static void Version(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
 {
     Respond(proxy, id, Worker.Version);
 }
示例#9
0
        protected static void DumpBoard(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            Console.Error.WriteLine(goBoard.ToString());

            Respond(proxy, id);
        }
示例#10
0
        protected static void PlaySequence(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            if (parameters.Count > 0)
            {
                string[] lMoves = parameters[0].Split(' ');

                for (int i = 0; i < lMoves.Length / 2; i++)
                    goBoard.PlayStone(lMoves[i * 2 + 1], Color.ToColor(lMoves[(i * 2)]), false);
            }

            Respond(proxy, id);
        }
示例#11
0
        protected static void ClearPatterns(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            searchEngine.SearchOptions.PatternDetector = new PatternDetector();

            Respond(proxy, id);
        }
示例#12
0
        protected static void ClearBoard(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            goBoard.ClearBoard();

            Respond(proxy, id);
        }
示例#13
0
        protected static void AddPatterns(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            PatternCollection lPatternCollection = new PatternCollection();

            foreach (string lString in parameters)
            {
                string lPattern = lString.Replace("~", "\n");
                lPatternCollection.Add(new Pattern(lPattern));
            }

            if (lPatternCollection.Count != 0)
            {
                if (searchEngine.SearchOptions.PatternDetector == null)
                    searchEngine.SearchOptions.PatternDetector = new PatternDetector();

                searchEngine.SearchOptions.PatternDetector.Add(lPatternCollection);
            }

            Respond(proxy, id);
        }
示例#14
0
        protected static void SetPermutation(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            searchEngine.SearchOptions.Permutations = Convert.ToInt32(parameters[0]);

            Respond(proxy, id);
        }
示例#15
0
 protected static void Respond(Worker.SendResponse proxy, string id, string message)
 {
     Respond(proxy, id, true, message, false);
 }
示例#16
0
        protected static void SetSearchMethod(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            searchEngine.SetSearchMethod(SearchMethodFactory.ToType(parameters[0]));

            Respond(proxy, id);
        }
示例#17
0
 protected static void Respond(Worker.SendResponse proxy, string id, bool success)
 {
     Respond(proxy, id, success, string.Empty, false);
 }
示例#18
0
        protected static void WriteLine(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            foreach (string lString in parameters)
                Console.Error.WriteLine("DEBUG: " + lString);

            Respond(proxy, id);
        }
示例#19
0
 protected static void Respond(Worker.SendResponse proxy, string id, bool success, string message)
 {
     Respond(proxy, id, success, message, false);
 }
示例#20
0
        public static bool Execute(string command, string id, List<string> parameters, GoBoard goBoard, SearchEngine searchEngine, Worker.SendResponse proxy)
        {
            WorkerFunction lFunction = GetFunction(command, parameters.Count);

            if (lFunction == null)
                return false;

            try
            {
                lFunction(goBoard, searchEngine, parameters, id, proxy);
                return true;
            }
            catch (Exception e)
            {
                Console.Error.Write("ERROR: " + e.ToString());
                Respond(proxy, id, false, command, true); // async response
                return false;
            }
        }
示例#21
0
 public static int LaunchWorker(string address, int port)
 {
     Worker lWorker = new Worker(address, port, string.Empty, string.Empty, 5, true);
     lWorker.Run();
     return 0;
 }