Ejemplo n.º 1
0
        internal StrategyComparisonResults GetResultsFor(ComparisonDescription descr)
        {
            StrategyComparisonResults result = null;

            if (!this.resultsCache.TryGetValue(descr, out result))
            {
                GameConfigBuilder builder       = new GameConfigBuilder();
                PlayerAction      playerAction1 = descr.Player1Action;
                PlayerAction      playerAction2 = descr.Player2Action;

                if (playerAction1 != null && playerAction2 != null)
                {
                    System.Console.WriteLine("Playing {0} vs {1}", playerAction1.PlayerName, playerAction2.PlayerName);
                    PlayerAction.SetKingdomCards(builder, new PlayerAction[] { playerAction1, playerAction2 });

                    var gameConfig = builder.ToGameConfig();

                    var strategyComparison = new StrategyComparison(playerAction1, playerAction2, gameConfig, rotateWhoStartsFirst: true, numberOfGames: 1000);
                    result = strategyComparison.ComparePlayers(
                        gameIndex => null,
                        gameIndex => null,
                        shouldParallel: true,
                        gatherStats: true);

                    this.resultsCache.Add(descr, result);
                }
                else
                {
                    this.resultsCache.Add(descr, null);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        internal StrategyComparisonResults GetResultsFor(ComparisonDescription descr)
        {
            StrategyComparisonResults result = null;
            if (!this.resultsCache.TryGetValue(descr, out result))
            {
                GameConfigBuilder builder = new GameConfigBuilder();
                PlayerAction playerAction1 = descr.Player1Action;
                PlayerAction playerAction2 = descr.Player2Action;

                if (playerAction1 != null && playerAction2 != null)
                {
                    System.Console.WriteLine("Playing {0} vs {1}", playerAction1.PlayerName, playerAction2.PlayerName);
                    builder.SetKingdomCards(new PlayerAction[] { playerAction1, playerAction2 });

                    var gameConfig = builder.ToGameConfig();

                    var strategyComparison = new StrategyComparison(playerAction1, playerAction2, gameConfig, rotateWhoStartsFirst: true, numberOfGames: 1000);
                    result = strategyComparison.ComparePlayers(
                        gameIndex => null,
                        gameIndex => null,
                        shouldParallel: true,
                        gatherStats: true);

                    this.resultsCache.Add(descr, result);
                }
                else
                {
                    this.resultsCache.Add(descr, null);
                }
            }

            return result;
        }
Ejemplo n.º 3
0
 public bool Equals(ComparisonDescription other)
 {
     return(this.player1 == other.player1 &&
            this.player2 == other.player2);
 }
 public bool Equals(ComparisonDescription other)
 {
     return this.player1 == other.player1 &&
             this.player2 == other.player2;
 }