Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 protected static void Respond(Worker.SendResponse proxy, string id, bool success, string message, bool async)
 {
     proxy((async ? "!" : "") + (success ? "=" : "?") + "\t" + id + "\t" + message);
 }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 public AsyncResponseHelper(Worker.SendResponse proxy, string id)
 {
     Proxy = proxy;
     ID = id;
 }
Exemplo n.º 6
0
        protected static void Abort(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            searchEngine.StopSearch();

            Respond(proxy, id);
        }
Exemplo n.º 7
0
 protected static void Respond(Worker.SendResponse proxy, string id)
 {
     Respond(proxy, id, true, string.Empty, false);
 }
Exemplo n.º 8
0
 protected static void Version(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
 {
     Respond(proxy, id, Worker.Version);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 12
0
        protected static void ClearBoard(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy)
        {
            goBoard.ClearBoard();

            Respond(proxy, id);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 15
0
 protected static void Respond(Worker.SendResponse proxy, string id, string message)
 {
     Respond(proxy, id, true, message, false);
 }
Exemplo n.º 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);
        }
Exemplo n.º 17
0
 protected static void Respond(Worker.SendResponse proxy, string id, bool success)
 {
     Respond(proxy, id, success, string.Empty, false);
 }
Exemplo n.º 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);
        }
Exemplo n.º 19
0
 protected static void Respond(Worker.SendResponse proxy, string id, bool success, string message)
 {
     Respond(proxy, id, success, message, false);
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
 }