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); }
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); }
protected static void Respond(Worker.SendResponse proxy, string id, bool success, string message, bool async) { proxy((async ? "!" : "") + (success ? "=" : "?") + "\t" + id + "\t" + message); }
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); }
public AsyncResponseHelper(Worker.SendResponse proxy, string id) { Proxy = proxy; ID = id; }
protected static void Abort(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy) { searchEngine.StopSearch(); Respond(proxy, id); }
protected static void Respond(Worker.SendResponse proxy, string id) { Respond(proxy, id, true, string.Empty, false); }
protected static void Version(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy) { Respond(proxy, id, Worker.Version); }
protected static void DumpBoard(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy) { Console.Error.WriteLine(goBoard.ToString()); Respond(proxy, id); }
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); }
protected static void ClearPatterns(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy) { searchEngine.SearchOptions.PatternDetector = new PatternDetector(); Respond(proxy, id); }
protected static void ClearBoard(GoBoard goBoard, SearchEngine searchEngine, List<string> parameters, string id, Worker.SendResponse proxy) { goBoard.ClearBoard(); Respond(proxy, id); }
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); }
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); }
protected static void Respond(Worker.SendResponse proxy, string id, string message) { Respond(proxy, id, true, message, false); }
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); }
protected static void Respond(Worker.SendResponse proxy, string id, bool success) { Respond(proxy, id, success, string.Empty, false); }
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); }
protected static void Respond(Worker.SendResponse proxy, string id, bool success, string message) { Respond(proxy, id, success, message, false); }
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; } }
public static int LaunchWorker(string address, int port) { Worker lWorker = new Worker(address, port, string.Empty, string.Empty, 5, true); lWorker.Run(); return 0; }