This commit is contained in:
AUnicornWithNoLife 2023-05-25 13:07:02 +01:00
parent 9fed104d24
commit 60ce786b37
2 changed files with 66 additions and 2 deletions

64
Master Mind/AI.cs Normal file
View File

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Master_Mind
{
internal class AI
{
public static int[] Guess(Game.GameData game)
{
int[] guess = new int[4];
for (int i = 0; i < 4; i++)
guess[i] = -1;
for (int x = 0; x < game.go; x++)
{
int[] stat = game.ContainsCalcIHateThis(x);
for (int y = 0; y < 4; y++)
{
if (stat[y] == 1)
{
guess[y] = game.board[x, y];
}
}
}
return guess;
}
public static int[] ShittyGuess(Game.GameData game)
{
if (game.go == 0)
{
// RANDOM
}
// LOOP thru
}
public static bool IsThisValidGivenWhatIKnow(Game.GameData game, int[] guess)
{
for (int x = 0; x < game.go; x++)
{
int[] gDat = game.ContainsCalcIHateThis(x);
for (int y = 0; y < 4; y++)
{
if
(
((gDat[y] == 1) && (guess[y] != game.board[x, y])) ||
((gDat[y] == 2) && (guess[y] == game.board[x, y]))
)
return false;
}
}
return true;
}
}
}

View File

@ -24,7 +24,7 @@ namespace Master_Mind
int[] checks = board.ContainsCalcIHateThis(x);
Console.BackgroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Gray;
Console.Write(" ");
for (int y = 0; y < 4; y++)
@ -47,7 +47,7 @@ namespace Master_Mind
Console.Write(" ");
}
Console.BackgroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Gray;
Console.Write(" ");
Console.BackgroundColor = ConsoleColor.Black;