diff --git a/Master Mind/AI.cs b/Master Mind/AI.cs index a6fcd65..c6d724b 100644 --- a/Master Mind/AI.cs +++ b/Master Mind/AI.cs @@ -35,12 +35,12 @@ namespace Master_Mind { int[] guess = new int[4]; + Random r = new Random(); + if (game.go == 0) { // RANDOM - Random r = new Random(); - guess[0] = r.Next(6); guess[1] = r.Next(6); guess[2] = r.Next(6); @@ -51,7 +51,7 @@ namespace Master_Mind while (!IsThisValidGivenWhatIKnow(game, guess)) { - if (++guess[0] >= 6) + /*if (++guess[0] >= 6) { guess[0] = 0; @@ -69,7 +69,12 @@ namespace Master_Mind } } } - } + }*/ + + guess[0] = r.Next(6); + guess[1] = r.Next(6); + guess[2] = r.Next(6); + guess[3] = r.Next(6); } return guess; @@ -104,17 +109,6 @@ namespace Master_Mind } } - /*for (int x = 0; x < game.go; x++) - { - int[] gDat = game.ContainsCalcIHateThis(x); - - for (int y = 0; y < 4; y++) - { - if (gDat[y] == 0 && (guess.Contains(game.board[x, y]))) - return false; - } - }*/ - return true; } } diff --git a/Master Mind/Game.cs b/Master Mind/Game.cs index a8b391c..747bbf9 100644 --- a/Master Mind/Game.cs +++ b/Master Mind/Game.cs @@ -100,46 +100,41 @@ namespace Master_Mind Console.WriteLine("Loading..."); - int g = 0; + GameData game = new GameData(); - for (int x = 0; x < 100; x++) + if (opt == 1) { - GameData game = new GameData(); + Random rand = new Random(); + for (int i = 0; i < 4; i++) + { + int col = rand.Next(6); + + game.sequence[i] = col; + } + } + else + { + game.sequence = Render.GetColorInput(); + } + + do + { if (opt == 1) { - Random rand = new Random(); - - for (int i = 0; i < 4; i++) - { - int col = rand.Next(6); - - game.sequence[i] = col; - } + game.AddRow(Render.GetColorInput()); } else { - Console.WriteLine("Please select your colors"); - - return; + game.AddRow(AI.ShittyGuess(game)); } - do - { - //game.AddRow(Render.GetColorInput()); - game.AddRow(AI.ShittyGuess(game)); + Console.Clear(); - Console.Clear(); + Render.RenderBoard(game, (opt == 2)); - Render.RenderBoard(game); - - //Console.ReadLine(); - - g++; - } while (game.won == 0); - } - - Console.WriteLine(((float)g / 100f).ToString()); + Console.ReadLine(); + } while (game.won == 0); } } } diff --git a/Master Mind/Render.cs b/Master Mind/Render.cs index 063e62c..2460ec0 100644 --- a/Master Mind/Render.cs +++ b/Master Mind/Render.cs @@ -8,7 +8,7 @@ namespace Master_Mind { public class Render { - public static void RenderBoard(Game.GameData board) + public static void RenderBoard(Game.GameData board, bool showAns = false) { for (int x = 0; x < (board.go); x++) { @@ -56,12 +56,15 @@ namespace Master_Mind Console.WriteLine("\n"); - for (int y = 0; y < 4; y++) + if (showAns) { - Console.BackgroundColor = Values.colors[board.sequence[y]]; - Console.Write(" "); - Console.BackgroundColor = ConsoleColor.Black; - Console.Write(" "); + for (int y = 0; y < 4; y++) + { + Console.BackgroundColor = Values.colors[board.sequence[y]]; + Console.Write(" "); + Console.BackgroundColor = ConsoleColor.Black; + Console.Write(" "); + } } }