Skip to content
Snippets Groups Projects
Commit cfda09f3 authored by DamianKomdeur's avatar DamianKomdeur
Browse files

Hint fixed

Hint now doesn't get stuck with sudoku and binary
parent 7c12d04f
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,8 @@ using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
namespace PuzzlePlayer_Namespace
{
......@@ -102,7 +104,8 @@ namespace PuzzlePlayer_Namespace
}
// virtual method for solving one step
public virtual void Hint()
/*public virtual void Hint()
{
int row;
int col;
......@@ -131,6 +134,35 @@ namespace PuzzlePlayer_Namespace
}
}
}
*/
public virtual void Hint()
{
List<Tuple<int, int>> emptySpaces = new List<Tuple<int, int>>();
for (int x = 0; x < boardState.GetLength(0); x++)
{
for (int y = 0; y < boardState.GetLength(1); y++)
{
if (boardState[x, y] == emptySpace)
{
emptySpaces.Add(new Tuple<int, int>(x, y));
}
}
}
if (emptySpaces.Count > 0)
{
int index = random.Next(emptySpaces.Count);
Tuple<int, int> randomEmptySpace = emptySpaces[index];
int row = randomEmptySpace.Item1;
int col = randomEmptySpace.Item2;
boardState[row, col] = solution[row, col];
}
}
public virtual int RandomNumber(int number)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment