Ejemplo n.º 1
0
        public string StartSimulations(Board board, int numberOfSimulations)
        {
            Random random = new Random();
            List <MonteCarloUpgradeMove> moves = new List <MonteCarloUpgradeMove>();
            MonteCarloUpgradeMove        move  = new MonteCarloUpgradeMove();

            AddMoves(moves, board);
            int amountOfTestedMoves = moves.Count;

            TestMoves(numberOfSimulations, board, moves, amountOfTestedMoves);
            setResult(moves);
            moves.Sort((s2, s1) => s1.result.CompareTo(s2.result));

            int bestOf = 3;

            if (moves.Count < 3)
            {
                bestOf = moves.Count;
            }
            TestMoves(numberOfSimulations, board, moves, bestOf);
            setResult(moves);

            for (int i = bestOf; i < moves.Count; i++)
            {
                moves[i].result = 0;
            }

            moves.Sort((s2, s1) => s1.result.CompareTo(s2.result));
            Console.WriteLine("Ruch: " + moves[0].MoveCode + " Liczba prob: " + moves[0].trys + " łączna liczba punktów: " + moves[0].rate + " Ocena " + moves[0].result);
            //  writeToFile(bestOf, moves);
            return(moves[0].MoveCode);
        }
Ejemplo n.º 2
0
 public void AddMoves(List <MonteCarloUpgradeMove> moves, Board board)
 {
     foreach (MonteCarloUpgradeMove.PossibleMoves code in Enum.GetValues(typeof(MonteCarloUpgradeMove.PossibleMoves)))
     {
         MonteCarloUpgradeMove move = new MonteCarloUpgradeMove();
         string moveCode            = code.ToString();
         move = new MonteCarloUpgradeMove(moveCode);
         if (Move.IsMovePossible(move, this, board.CoinsOnBoard, board.MinesOnBoard))
         {
             moves.Add(new MonteCarloUpgradeMove(moveCode));
         }
     }
     DeleteNone(moves);
 }