public int evaluation(GameState g, int player) { MapAnalyzer m = new MapAnalyzer(g.Map); int playerFieldSize = m.fieldSize(player == 1 ? g.Opponent : g.Player); int opponentFieldSize = m.fieldSize(player == 0 ? g.Opponent : g.Player); return playerFieldSize - opponentFieldSize; }
public int getCurrentResult() { MapAnalyzer ma = new MapAnalyzer(Map); int playerFields = ma.fieldSize(Player); int opponentFields = ma.fieldSize(Opponent); if (Player.X+1 == Opponent.X && Player.Y == Opponent.Y) return -10; if (Player.X-1 == Opponent.X && Player.Y == Opponent.Y) return -10; if (Player.X == Opponent.X && Player.Y+1 == Opponent.Y) return -10; if (Player.X == Opponent.X && Player.Y-1 == Opponent.Y) return -10; if (playerFields <= 1) return -100; if (opponentFields <= 1) return 100; return 0; }
public int evaluation(GameState g, int player) { MapAnalyzer m = new MapAnalyzer(g); int playerFieldSize = m.fieldSize(player == 1 ? g.Opponent : g.Player); //Console.Error.WriteLine("Evaluate {0}|{1}: {2} {3}", (player == 1 ? g.Opponent.X : g.Player.X), (player == 1 ? g.Opponent.Y : g.Player.Y), playerFieldSize , opponentFieldSize); return playerFieldSize; }
public int evaluation(GameState g, int player) { int direction = g.previousPlayerMove.Direction; int[,] map = g.Map; //int[,] newMap = MapManipulator.straightLineFromPosition(map, player == 1 ? g.Opponent : g.Player, direction); //int distance = MapManipulator.distanceStraightLine(map, player == 1 ? g.Opponent : g.Player, direction); MapAnalyzer m = new MapAnalyzer(map); //m.printMap(); //since MapAnalyzer actually clones the arrays and so player reports the wrong size if being part of the wall, manipulate the array directly //and fill opponent first, then check the player field size. this will report correct size int opponentFieldSize = m.fieldSize(player == 0 ? g.Opponent : g.Player); int playerFieldSize = m.fieldSize(player == 1 ? g.Opponent : g.Player); bool seperated = m.sameField(g.Player, g.Opponent); int score = 0; if (seperated && playerFieldSize > opponentFieldSize) return 100; if (seperated && opponentFieldSize > playerFieldSize) return -100; if (seperated && opponentFieldSize == playerFieldSize) return 5; if (g.Player.X + 1 == g.Opponent.X && g.Player.Y == g.Opponent.Y) score -= -50; if (g.Player.X - 1 == g.Opponent.X && g.Player.Y == g.Opponent.Y) score -= -50; if (g.Player.X == g.Opponent.X && g.Player.Y + 1 == g.Opponent.Y) score -= -50; if (g.Player.X == g.Opponent.X && g.Player.Y - 1 == g.Opponent.Y) score -= -50; if (g.Player.X +1== g.Opponent.X && g.Player.Y - 1 == g.Opponent.Y) score -= -50; if (g.Player.X-1 == g.Opponent.X && g.Player.Y - 1 == g.Opponent.Y) score -= -50; if (g.Player.X+1 == g.Opponent.X && g.Player.Y + 1 == g.Opponent.Y) score -= -50; if (g.Player.X-1 == g.Opponent.X && g.Player.Y + 1 == g.Opponent.Y) score -= -50; //Console.Error.WriteLine(MyTronBot.intDirectionToString(direction)); //Console.Error.WriteLine("OpponentFieldSize: " + opponentFieldSize + " PlayerFieldSize: " + playerFieldSize); //Console.Error.WriteLine("Utility cutoff: " + (playerFieldSize - opponentFieldSize) + "\n"); //Console.Error.WriteLine("Distance Eval: " + distanceEvaluation + "\nEval: " + evaluation); //if (opponentFieldSize < playerFieldSize) finalEval = playerFieldSize + distanceEvaluation; //Console.Error.WriteLine("FinalEval: " + finalEval); return score; }
public bool sameField(Point pos1, Point pos2) { MapAnalyzer ma = new MapAnalyzer(Map); int pos1size = ma.fieldSize(pos1); int pos2size = ma.fieldSize(pos2); //Console.Error.WriteLine("Pos1: " + pos1size + " Pos2: " + pos2size); return (pos1size == pos2size); }