/// <summary> /// This will be run on each turns. It must return a direction fot the bot to follow /// </summary> /// <param name="state">The game state</param> /// <returns></returns> public string Move(GameState state) { myFinder = new Pathfinder(state); string direction; switch (random.Next(0, 5)) { case 0: direction = Direction.East; break; case 1: direction = Direction.West; break; case 2: direction = Direction.North; break; case 3: direction = Direction.South; break; default: direction = Direction.Stay; break; } direction = myFinder.GetNextMoveToGetToDestination(2, 2); Console.WriteLine("Completed turn {0}, going {1}", state.currentTurn, direction); Console.WriteLine(DateTime.Now - delta); return direction; }
public string WhatShouldIDo(GameState state) { gState = state; Dictionary<Pos, Tile> POI = new Dictionary<Pos, Tile>(); numberOfMinePlayer1 = 0; numberOfMinePlayer2 = 0; numberOfMinePlayer3 = 0; numberOfMinePlayer4 = 0; for (int i = 0; i < state.board.Length; i++) { for (int j = 0; j < state.board[i].Length; j++) { if (state.board[i][j] != Tile.FREE && state.board[i][j] != Tile.IMPASSABLE_WOOD) { POI.Add(new Pos() { x = i, y = j }, state.board[i][j]); } if (state.board[i][j] == Tile.GOLD_MINE_1) numberOfMinePlayer1++; else if (state.board[i][j] == Tile.GOLD_MINE_2) numberOfMinePlayer2++; else if (state.board[i][j] == Tile.GOLD_MINE_3) numberOfMinePlayer3++; else if (state.board[i][j] == Tile.GOLD_MINE_4) numberOfMinePlayer4++; } } Pos bestPoiPos = new Pos(); int bestScore = Int32.MaxValue; Pathfinder pathfinder = new Pathfinder(state); foreach (var poi in POI) { int cost = WhatsMyScore(pathfinder.GetDestinationCost(poi.Key), poi.Value); if (cost < bestScore) { bestPoiPos = poi.Key; bestScore = cost; } } return pathfinder.GetNextMoveToGetToDestination(bestPoiPos.x, bestPoiPos.y); }