Exemplo n.º 1
0
        public SimulationResult RunOptimization(Deck playerDeck, Deck enemyDeck, bool surgeMode, int iterations)
        {
            Board board = new Board(playerDeck, enemyDeck, surgeMode);

            SimulationResult result = new SimulationResult();
            result.NumberOfIterations = iterations;

            for (int currentIteration = 0; currentIteration < iterations; currentIteration++)
            {
                board.ResetToDefault();

                RunSimulation(board, result);
            }

            return result;
        }
Exemplo n.º 2
0
        private SimulationResult RunSimulation(Board board, SimulationResult intermediateResult)
        {
            for (int round = 1; round <= Board.MaxRound; round++)
            {
                Logger.Log("Round {0}", round);

                // Draw new card
                Deck currentPlayerDeck = board.GetCurrentPlayerDeck();
                Deck currentEnemyDeck = board.GetCurrentEnemyDeck();

                // Player turn
                Logger.Log($"{currentPlayerDeck.GetDeckName()} turn:");
                var winningDeck = PlayerTurn(currentPlayerDeck, currentEnemyDeck);
                if (winningDeck != null)
                {
                    return UpdateResult(intermediateResult, winningDeck);
                }

                // Enemy turn
                Logger.Log($"{currentEnemyDeck.GetDeckName()} turn:");
                winningDeck = PlayerTurn(currentEnemyDeck, currentPlayerDeck);
                if (winningDeck != null)
                {
                    return UpdateResult(intermediateResult, winningDeck);
                }

                // Decrease delay
                currentPlayerDeck.PlayedCards.ForEach(c => c.Delay--);
                currentEnemyDeck.PlayedCards.ForEach(c => c.Delay--);
            }

            // If no player win in 50 turns, its draw
            intermediateResult.NumberOfPlayerDraws++;

            return intermediateResult;
        }
Exemplo n.º 3
0
        private SimulationResult UpdateResult(SimulationResult intermediateResult, Deck winningDeck)
        {
            if (winningDeck.IsPlayer)
            {
                intermediateResult.NumberOfPlayerWins ++;
            }
            else
            {
                intermediateResult.NumberOfPlayerLosses++;
            }

            return intermediateResult;
        }