public static void SupplementalDemo_SingleGame(this GameBoard board)
        {
            var greedyStrategy = new ChutesAndLadders.Strategy.Greedy.Engine();
            var linearStrategy = new ChutesAndLadders.Strategy.Linear.Engine();

            var geneticStrategy = new ChutesAndLadders.Strategy.Rules.Engine("Best Found");

            geneticStrategy.AddBestStrategyRules();

            var shortestPathStrategy = new ChutesAndLadders.Strategy.ShortestPath.Engine();

            // Remember that player 1 has a big advantage
            var player1 = new Player("Player 1", greedyStrategy);
            var player2 = new Player("Player 2", linearStrategy);
            var player3 = new Player("Player 3", geneticStrategy);
            var player4 = new Player("Player 4", shortestPathStrategy);
            var players = new Player[] { player1, player2, player3, player4 };

            var gameEngine = new Game(board);

            // Set the last parameter to a value 1-6 to have all rolls be that value
            // This allow us to compare the strategies when all use the same roll
            // It would be better if the roll varied by round but all players
            // got the same roll in a given round
            var results = gameEngine.Play(players, 1, 16, true, 0);

            Console.WriteLine(results.ToString());
            Console.WriteLine();
            Console.WriteLine(player4.Strategy.ToString());
        }
Beispiel #2
0
        public static void Demo2b_ImprovedLinear(this GameBoard board)
        {
            var linearStrategy = new ChutesAndLadders.Strategy.Linear.Engine();

            var improvedLinearStrategy1 = new ChutesAndLadders.Strategy.Rules.Engine("Improved Linear 1");

            improvedLinearStrategy1.AddTakeLadderRules(28, 84);
            improvedLinearStrategy1.AddTakeLadderRules(80, 100);

            var improvedLinearStrategy2 = new ChutesAndLadders.Strategy.Rules.Engine("Improved Linear 2");

            improvedLinearStrategy2.AddTakeLadderRules(28, 84);
            improvedLinearStrategy2.AddTakeLadderRules(80, 100);
            improvedLinearStrategy2.AddTakeChuteRules(98, 78);

            // This is the shortest path, which should give the same results
            // as "Take All Ladders" if all games started from 0
            var improvedLinearStrategy3 = new ChutesAndLadders.Strategy.Rules.Engine("Improved Linear 3");

            improvedLinearStrategy3.AddTakeLadderRules(1, 38);
            improvedLinearStrategy3.AddTakeLadderRules(51, 67);
            improvedLinearStrategy3.AddTakeLadderRules(71, 91);


            var player1 = new Player("Player 1", linearStrategy);
            var player2 = new Player("Player 2", improvedLinearStrategy1);
            var player3 = new Player("Player 3", improvedLinearStrategy2);
            var player4 = new Player("Player 4", improvedLinearStrategy3);
            var players = new Player[] { player1, player2, player3, player4 };

            var engine = new SimulationCollection();

            engine.RunSimulations(players, 30000, true);
        }
Beispiel #3
0
        public static void Demo1a_GreedyAlgorithm(this GameBoard board)
        {
            var greedyStrategy = new ChutesAndLadders.Strategy.Greedy.Engine();
            var badStrategy    = new ChutesAndLadders.Strategy.AgressivelyBad.Engine();
            var linearStrategy = new ChutesAndLadders.Strategy.Linear.Engine();

            var player1 = new Player("Player 1", greedyStrategy);
            var player2 = new Player("Player 2", badStrategy);
            var player3 = new Player("Player 3", linearStrategy);
            var players = new Player[] { player1, player2, player3 };

            var engine = new SimulationCollection();

            engine.RunSimulations(players, 30000, true);
        }
Beispiel #4
0
        public static void Demo3c_GeneticSuperiority(this GameBoard board)
        {
            var greedyStrategy = new ChutesAndLadders.Strategy.Greedy.Engine();
            var linearStrategy = new ChutesAndLadders.Strategy.Linear.Engine();

            var geneticStrategy = new ChutesAndLadders.Strategy.Rules.Engine("Best Found");

            geneticStrategy.AddBestStrategyRules();

            var player1 = new Player("Player 1", greedyStrategy);
            var player2 = new Player("Player 2", linearStrategy);
            var player3 = new Player("Player 3", geneticStrategy);
            var players = new Player[] { player1, player2, player3 };

            var engine = new SimulationCollection();

            engine.RunSimulations(players, 100000, true);
        }