Example #1
0
        public override PlayerTask GetMove(POGame.POGame poGame)
        {
            if (poGame.CurrentPlayer.Options().Count == 1)
            {
                return(poGame.CurrentPlayer.Options()[0]);
            }

            Console.WriteLine("Turn #" + poGame.Turn + ": AlvaroAgent needs to take a decision...");
            Console.WriteLine(poGame.FullPrint());
            POGame.POGame initialState = poGame.getCopy();

            Node root = new Node();

            Node  selectedNode;
            Node  nodeToSimulate;
            float scoreOfSimulation;
            int   iterations = 0;

            InitializeRoot(root, initialState);

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            while (stopwatch.ElapsedMilliseconds <= MAX_TIME)
            {
                poGame         = initialState;
                selectedNode   = Selection(root, iterations, ref poGame);
                nodeToSimulate = Expansion(selectedNode, ref poGame);

                Console.WriteLine("Iteration #" + iterations + ": node to be simulated:" + selectedNode);

                for (int i = 0; i < NUM_SIMULATIONS; i++)
                {
                    scoreOfSimulation = Simulation(nodeToSimulate, poGame);
                    Backpropagation(nodeToSimulate, scoreOfSimulation);
                    iterations++;
                }
            }
            stopwatch.Stop();

            PlayerTask selectedTask = SelectAction.selectTask(SELECTION_ACTION_METHOD, root, iterations, EXPLORE_CONSTANT);

            Console.WriteLine("Turn #" + poGame.Turn + ", selected task:" + selectedTask);
            return(selectedTask);
        }
Example #2
0
 public string FullPrint()
 {
     return(currentPOGame.FullPrint());
 }