BotResponse IBot.GetResponse(TimeSpan time) { var boards = State.Boards; int playableBoard = State.PlayableBoard; var evaluator = new Evaluator(); int x0 = 3 * (playableBoard % 3); int y0 = 3 * (playableBoard / 3); int bestScore = int.MinValue; int bestX = -1; int bestY = -1; for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { if (State.Field.Board[x0 + x, y0 + y] == 0) { var newState = State.CopyAndPlay(x0 + x, y0 + y, Settings.YourBot); int score = evaluator.Evaluate(newState.Boards, newState.PlayableBoards, Settings.YourBot); if (score > bestScore) { bestScore = score; bestX = x0 + x; bestY = y0 + y; } } } } var move = new MoveInstruction(bestX, bestY); var response = new BotResponse() { Move = move, Log = move.ToString(), }; return response; }
private void AssertMoveNot(int x, int y, BotResponse response) { string expected = string.Format("({0},{1})", x, y); string actual = string.Format("({0},{1})", response.Move.X, response.Move.Y); Assert.AreNotEqual(expected, actual); }