private static async Task FindNonEmptyView(WordSearcherGameClient wsGameClient) { if (wsGameClient.State.SeesAnything) { Logger.Log.Info("Already have a non-empty view, no search is required."); return; } Logger.Log.Info("Looking for a non-empty view for width and height estimation..."); var linesChecked = 0; while (true) { var searchRange = 50 + linesChecked / 5 * 20; var foundSomething = await MoveUntilSeeAnything(wsGameClient, linesChecked % 2 == 0?Direction.Right : Direction.Left, searchRange); if (foundSomething) { break; } Logger.Log.Info( $"Found nothing in range {searchRange} on line, going {Constants.VisibleFieldHeight} lower... (current Y:{wsGameClient.State.Y})"); linesChecked++; await wsGameClient.MoveAsync(Direction.Down, Constants.VisibleFieldHeight); } Logger.Log.Info("Non-empty view found."); }
private static async Task Main(string[] args) { var(server, token) = ParseArgs(args); Logger.Log.Info($"Playing on server \"{server}\" with token \"{token}\""); var wsClient = new WordSearcherGameClient(server, token); var ws = new WordSearcher(wsClient); await ws.PlaySessionAsync(); }
private static async Task <bool> MoveUntilSeeAnything(WordSearcherGameClient wsGameClient, Direction direction, int maxMoves = -1) { while (!wsGameClient.State.SeesAnything && maxMoves != 0) { await wsGameClient.MoveAsync(direction); if (maxMoves > 0) { maxMoves--; } } return(wsGameClient.State.SeesAnything); }
public LetterSearcher(WordSearcherGameClient wsClient) { this.wsClient = wsClient; }
public MapDimensionsEstimator(WordSearcherGameClient wsGameClient) { this.wsGameClient = wsGameClient; letterSearcher = new LetterSearcher(wsGameClient); }
public SimpleMapScanner(WordSearcherGameClient wsGameClient, int mapWidth, int mapHeight) { this.wsGameClient = wsGameClient; this.mapWidth = mapWidth; this.mapHeight = mapHeight; }