static void Main(string[] args)
        {
            MasterMindGame game = new MasterMindGame(20, 4);

            while (!game.GameFinished)
            {
                game.SetColor(0, (Color)int.Parse(Console.ReadLine()));
                game.SetColor(1, (Color)int.Parse(Console.ReadLine()));
                game.SetColor(2, (Color)int.Parse(Console.ReadLine()));
                game.SetColor(3, (Color)int.Parse(Console.ReadLine()));
                MasterMindResult result = game.EndTry();
                Console.WriteLine("Posmatch: " + result.PosMatch);
                Console.WriteLine("colormatch: " + result.ColorMatch);
                Console.WriteLine(game.GetDebugInfo());
            }
            if (game.GameWon)
            {
                Console.WriteLine("You have Won");
            }
            else
            {
                Console.WriteLine("You have lost");
            }

            Console.ReadKey(true);
        }
Example #2
0
        public MasterMindResult EndTry()
        {
            MasterMindResult result = GetCurrentRow().CompareWithSecretRow(HiddenRow);

            if (result.PosMatch == RowLength)
            {
                GameWon      = true;
                GameFinished = true;
            }
            if (MaxTurns < CurrentRow)
            {
                GameFinished = true;
            }
            return(result);
        }