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

Maze hint in main

parent e47030f0
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
...@@ -158,6 +159,36 @@ namespace PuzzlePlayer_Namespace ...@@ -158,6 +159,36 @@ namespace PuzzlePlayer_Namespace
} }
public override void Hint()
{
shortestPath = new List<Point>();
visitedCells = GetClearBoard(mazeState.GetLength(0), mazeState.GetLength(1));
shortestPath.Add(new Point(0, 0));
bool foundSolution = Recursive_DepthFirstSearchMazeSolve(0, 0);
int hintCounter = 0;
if (foundSolution)
{
boardState[playerPos.X, playerPos.Y] = 1;
foreach (Point step in shortestPath.Skip(1))
{
if (boardState[step.X, step.Y] == emptySpace)
{
if (hintCounter == 5)
{
break;
}
boardState[step.X, step.Y] = 1;
playerPos.X = step.X;
playerPos.Y = step.Y;
hintCounter++;
}
}
}
}
private bool Recursive_DepthFirstSearchMazeGenerator(int x, int y) private bool Recursive_DepthFirstSearchMazeGenerator(int x, int y)
{ {
visitedCells[x, y] = 1; // mark current cell as visited (this is needed for the first cell) visitedCells[x, y] = 1; // mark current cell as visited (this is needed for the first cell)
......
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