Пример #1
0
        public static String MakeMove()
        {
            HiPerfTimer timer = new HiPerfTimer();
            timer.Start();
            int x = Map.MyLocation.X;
            int y = Map.MyLocation.Y;

            GameState g = new GameState(readMap(), Map.MyLocation, Map.OpponentLocation);
            MapAnalyzer ma = new MapAnalyzer(g);

            if (g.getSuccessorStates(Player).Count == 0)
            {
                return randomMove();
            }

            bool separated = !ma.sameField(g.Player, g.Opponent);

            EvaluatorCollection ec = new EvaluatorCollection();
            Search s;
            if (!separated)
            {
                ec.add(new CutOffEvaluator());
                ec.add(new VoronoiEvaluator());
                s = new MiniMaxSearch();
            }
            else
            {
                ec.add(new FloodFillEvaluator());
                s = new MiniMaxSearch();
            }
            MultiplyEvaluators finalEval = new MultiplyEvaluators(new GameWinEvaluator(), ec);

            timer.Stop();
            int depth = 4;
            double time = timer.Duration * 1000;
            GameState best = new GameState();
            while (time < 500)
            {
                depth++;
                timer.Start();
                best = new GameState(s.doSearch(g, finalEval, depth, time));
                timer.Stop();
                time += timer.Duration * 1000;
            }
            //Console.Error.WriteLine(separated + " " + time + " " + depth);
            //ma.printMap();

            if (best.previousPlayerMove == null)
                return "N";
            else
                return intDirectionToString(best.previousPlayerMove.Direction);
        }
Пример #2
0
        public override string ToString()
        {
            EvaluatorCollection ec = new EvaluatorCollection();
            ec.add(new VoronoiEvaluator());
            Evaluator e = new MultiplyEvaluators(new GameWinEvaluator(), ec);
            //return String.Format("Dir: {6}, PlayerPos: {0}|{1} - Score: {4}, OpponentPos: {2}|{3}, Score: {5}", Player.X, Player.Y, Opponent.X, Opponent.Y
            //                                                                                                    , e.evaluation(this, 0)
            //                                                                                                    , e.evaluation(this, 1)
            //                                                                                                    , MyTronBot.intDirectionToString(previousPlayerMove.Direction)
            //                                                                                                    );
            return String.Format("Dir: {4}, PlayerPos: {0}|{1}, OpponentPos: {2}|{3}", Player.X, Player.Y, Opponent.X, Opponent.Y

                                                                                                                , MyTronBot.intDirectionToString(previousPlayerMove.Direction)

                                                                                                                );
        }