pretty mucg done

This commit is contained in:
AUnicornWithNoLife 2023-05-26 08:42:05 +01:00
parent 143756afbd
commit 0337c8c899
3 changed files with 41 additions and 49 deletions

View File

@ -35,12 +35,12 @@ namespace Master_Mind
{ {
int[] guess = new int[4]; int[] guess = new int[4];
Random r = new Random();
if (game.go == 0) if (game.go == 0)
{ {
// RANDOM // RANDOM
Random r = new Random();
guess[0] = r.Next(6); guess[0] = r.Next(6);
guess[1] = r.Next(6); guess[1] = r.Next(6);
guess[2] = r.Next(6); guess[2] = r.Next(6);
@ -51,7 +51,7 @@ namespace Master_Mind
while (!IsThisValidGivenWhatIKnow(game, guess)) while (!IsThisValidGivenWhatIKnow(game, guess))
{ {
if (++guess[0] >= 6) /*if (++guess[0] >= 6)
{ {
guess[0] = 0; 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; 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; return true;
} }
} }

View File

@ -100,10 +100,6 @@ namespace Master_Mind
Console.WriteLine("Loading..."); Console.WriteLine("Loading...");
int g = 0;
for (int x = 0; x < 100; x++)
{
GameData game = new GameData(); GameData game = new GameData();
if (opt == 1) if (opt == 1)
@ -119,27 +115,26 @@ namespace Master_Mind
} }
else else
{ {
Console.WriteLine("Please select your colors"); game.sequence = Render.GetColorInput();
return;
} }
do do
{ {
//game.AddRow(Render.GetColorInput()); if (opt == 1)
{
game.AddRow(Render.GetColorInput());
}
else
{
game.AddRow(AI.ShittyGuess(game)); game.AddRow(AI.ShittyGuess(game));
}
Console.Clear(); Console.Clear();
Render.RenderBoard(game); Render.RenderBoard(game, (opt == 2));
//Console.ReadLine(); Console.ReadLine();
g++;
} while (game.won == 0); } while (game.won == 0);
} }
Console.WriteLine(((float)g / 100f).ToString());
}
} }
} }

View File

@ -8,7 +8,7 @@ namespace Master_Mind
{ {
public class Render 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++) for (int x = 0; x < (board.go); x++)
{ {
@ -56,6 +56,8 @@ namespace Master_Mind
Console.WriteLine("\n"); Console.WriteLine("\n");
if (showAns)
{
for (int y = 0; y < 4; y++) for (int y = 0; y < 4; y++)
{ {
Console.BackgroundColor = Values.colors[board.sequence[y]]; Console.BackgroundColor = Values.colors[board.sequence[y]];
@ -64,6 +66,7 @@ namespace Master_Mind
Console.Write(" "); Console.Write(" ");
} }
} }
}
public static int[] GetColorInput() public static int[] GetColorInput()
{ {