Beispiel #1
0
        static void Main(string[] args)
        {
            Player      p2 = new RandomPlayer();//to call the diffrent players add there name after new
            HangmanGame hg = new HangmanGame(p2);

            Console.WriteLine();
        }
Beispiel #2
0
 static void Main(string[] args)
 {
     Player      p  = new ABCplayer();
     HumanPlayer p2 = new HumanPlayer();
     //Need to add in how to handle multi letter words like apple
     HangmanGame hg = new HangmanGame(p2);
 }
Beispiel #3
0
        private static void GetAverageGuessesOfPlayers()
        {
            Player[] p = { new BrutePlayer(),     new RandoPlayer(),
                           new VowelSmrtPlayer(), new WheelFortunePlayer() };

            int[] average = new int[p.Length];
            for (int i = 0; i < p.Length; i++)
            {
                int   index = 0;
                int[] tries = new int[10];
                for (int j = 0; j < 9; j++)
                {
                    HangmanGame hg = new HangmanGame(p[i]);
                    tries[index] = hg.tries;
                    index++;
                    if (i != 1)
                    {
                        p[i].guessCount = 0;
                    }
                }
                average[i] = tries.Sum();
            }
            Console.WriteLine($"The Bruteforce Player average is {(average[0]/average.Length)}.");
            Console.WriteLine($"The Random Player average is {(average[1] / average.Length)}.");
            Console.WriteLine($"The Efficent Bruteforce Player average is {(average[2] / average.Length)}.");
            Console.WriteLine($"The Wheel of Fortune Player average is {(average[3] / average.Length)}.");
            Console.WriteLine($"The Educated average is not working.");
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Player p  = new ABCplayer();
            Player p2 = new HumanPlayer();
            Player p3 = new BruteMan();
            Player p4 = new RandoMan();
            Player p5 = new _400IQMan();

            HangmanGame hg = new HangmanGame(p5);
        }
Beispiel #5
0
 static void Main(string[] args)
 {
     Player      p  = new ABCplayer();
     HumanPlayer p2 = new HumanPlayer();
     Player      p3 = new Zplayer();
     Player      p4 = new BruteForcePlayer();
     Player      p5 = new RandomPlayer();
     Player      p6 = new SmartPlayer();
     //Need to add in how to handle multi letter words like apple
     HangmanGame hg = new HangmanGame(p2);
 }
Beispiel #6
0
        static void Main(string[] args)


        {
            Player           p   = new ABCplayer();
            HumanPlayer      p2  = new HumanPlayer();
            RandomPlayer     r   = new RandomPlayer();      //not working
            BruteForcePlayer bfp = new BruteForcePlayer();
            //Need to add in how to handle multi letter words like apple
            HangmanGame hg = new HangmanGame(p2);  //apple
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            //////******UNCOMMENT OUT THE PLAYER YOU WOULD LIKE TO PLAY******//////


            //Player p1 = new ABCplayer();
            //HangmanGame hg1 = new HangmanGame(p1);

            //Player p2 = new HumanPlayer();
            //HangmanGame hg2 = new HangmanGame(p2);

            //Player p3 = new BruteForcePlayer();
            //HangmanGame hg3 = new HangmanGame(p3);

            Player      p4  = new SmartyPlayer();
            HangmanGame hg4 = new HangmanGame(p4);

            //Player p5 = new RandomPlayer();
            //HangmanGame hg5 = new HangmanGame(p5);
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Hangman Game");
            Console.WriteLine("Select an option: ");
            do
            {
                int input = UserActions();
                if (input != 9)
                {
                    Player[]    p = { new HumanPlayer(),     new BrutePlayer(),
                                      new RandoPlayer(),        new VowelSmrtPlayer(),
                                      new WheelFortunePlayer(), new EducatedPlayer() };
                    HangmanGame hg = new HangmanGame(p[input]);
                }
                else
                {
                    GetAverageGuessesOfPlayers();
                }

                Console.Write("Play again ");
            } while (YesOrNo());
            Console.WriteLine("Good Bye.");
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            // POLYMORPHISM!!!
            Player p1 = new ABCplayer();
            Player p2 = new RandomPlayer();
            Player p3 = new SmartyPants();
            Player p4 = new HumanPlayer();

            List <Player> x = new List <Player>();

            x.Add(p1);
            x.Add(p2);
            x.Add(p3);
            //x.Add(p4);

            int        wins          = 0;
            double     sumABC        = 0;
            double     sumRandom     = 0;
            double     sumSmarty     = 0;
            double     averageABC    = 0;
            double     averageRandom = 0;
            double     averageSmarty = 0;
            double     sumHuman      = 0;
            double     averageHuman  = 0;
            List <int> tries         = new List <int>();

            // BRUTEFORCE PLAYER
            wins = 1;
            do
            {
                p1.Reset();
                HangmanGame hg = new HangmanGame(p1);
                tries.Add(hg.tries);
                sumABC += hg.tries;
                wins++;
            } while (wins <= 1000);
            averageABC = sumABC / wins;

            // RANDOM GUESS PLAYER
            wins = 1;
            do
            {
                p2.Reset();
                HangmanGame hg = new HangmanGame(p2);
                sumRandom += hg.tries;
                wins++;
            } while (wins <= 1000);
            averageRandom = sumRandom / wins;

            // SMART PLAYER
            wins = 1;
            do
            {
                p3.Reset();
                HangmanGame hg = new HangmanGame(p3);
                sumSmarty += hg.tries;
                wins++;
            } while (wins <= 1000);
            averageSmarty = sumSmarty / wins;

            //// HUMAN PLAYER
            //wins = 1;
            //do
            //{
            //    p4.Reset();
            //    HangmanGame hg = new HangmanGame(p4);
            //    sumHuman += hg.tries;
            //    wins++;
            //} while (wins <= 10);
            //averageHuman = sumHuman / 10;

            Console.WriteLine("ABC tries: " + averageABC);
            Console.WriteLine("Random tries: " + averageRandom);
            Console.WriteLine("Smarty tries: " + averageSmarty);
            Console.WriteLine("Human tries: " + averageHuman);

            if (averageSmarty < averageABC && averageSmarty < averageRandom && averageSmarty < averageHuman)
            {
                Console.WriteLine($"SmartyPants is the smartest person around!");
            }
            else if (averageABC < averageRandom && averageABC < averageSmarty && averageABC < averageHuman)
            {
                Console.WriteLine($"BruteForce Wins!");
            }
            else if (averageRandom < averageSmarty && averageRandom < averageABC && averageRandom < averageHuman)
            {
                Console.WriteLine("Random Wins!");
            }
            else
            {
                Console.WriteLine("YOU ARE THE SMARTEST AROUND!!");
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            //List<Player> players = new List<Player>();
            //Player p = new EmptyClass();

            //for (int i = 0; i < 10; i++)
            //{

            //    HangmanGame hg = new HangmanGame(new EmptyClass());
            //}

            //players.Add(new BruteForcePlayer());
            //players.Add(new HumanPlayer());
            //players.Add(new SmartyPlayer());

            // foreach loop to itterate through the four players
            // each player will play 10 games, adding their tries together as they go
            // create List<int> to hold the average of all 10 of their games
            // display results in pretty format

            List <int> playerAveragedResults = new List <int>();

            int accumulatedTotal = 0;

            for (int i = 0; i < 10; i++)
            {
                Player      p      = new ABCplayer();
                HangmanGame hg     = new HangmanGame(p);
                int         result = hg.ReturnResult();
                accumulatedTotal += result;
            }

            playerAveragedResults.Add(accumulatedTotal / 10);

            accumulatedTotal = 0;



            for (int i = 0; i < 10; i++)
            {
                Player      p      = new BruteForcePlayer();
                HangmanGame hg     = new HangmanGame(p);
                int         result = hg.ReturnResult();
                accumulatedTotal += result;
            }

            playerAveragedResults.Add(accumulatedTotal / 10);

            accumulatedTotal = 0;


            // play human player twice since who has time for ten hole games?
            for (int i = 0; i < 2; i++)
            {
                Player      p      = new HumanPlayer();
                HangmanGame hg     = new HangmanGame(p);
                int         result = hg.ReturnResult();
                accumulatedTotal += result;
            }

            playerAveragedResults.Add(accumulatedTotal / 2);

            accumulatedTotal = 0;



            for (int i = 0; i < 10; i++)
            {
                Player      p      = new SmartyPlayer();
                HangmanGame hg     = new HangmanGame(p);
                int         result = hg.ReturnResult();
                accumulatedTotal += result;
            }

            playerAveragedResults.Add(accumulatedTotal / 10);



            List <string> playerNames = new List <string>()
            {
                "ABC Player", "Brute Force Player", "Human Player", "Smarty Player"
            };

            Console.WriteLine();
            Console.WriteLine("Average number of attempts per game by player type:");
            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine($"{playerNames[i], 20} : {playerAveragedResults[i]}");
            }
        }