Skip to content
Snippets Groups Projects
Commit 4ac3a0fd authored by bionic85's avatar bionic85
Browse files

Plaatjes gefixt en groote is variabel

parent b7a6477c
No related branches found
No related tags found
No related merge requests found
......@@ -20,8 +20,8 @@ namespace PuzzlePlayer_Namespace
// constructor with boardSize parameter (default is set to 8 but can be changed)
public Binary(int boardSize = 6) // should be even
{
boardState = GetClearBoard(boardSize);
lastGeneratedBoard = GetClearBoard(boardSize);
boardState = GetClearBoard(boardSize,boardSize);
lastGeneratedBoard = GetClearBoard(boardSize, boardSize);
description = "Binary puzzle is played on any even-numbered square grid, with some cells initially containing black or white circles. The goal of the puzzle is to fill all cells such that:\r\n● More than two circles of the same color cannot be adjacent\r\n● Each row and column must contain an equal number of black and white circles";
......@@ -89,7 +89,7 @@ namespace PuzzlePlayer_Namespace
int[,] generatedBoard;
//generates a board starting with an empty board and a empty HashSet
while ((generatedBoard = BackTrackAlgorithm(GetClearBoard(boardState.GetLength(0)), new HashSet<string>())) == null)
while ((generatedBoard = BackTrackAlgorithm(GetClearBoard(boardState.GetLength(0), boardState.GetLength(1)), new HashSet<string>())) == null)
{
counter++;
Debug.WriteLine($"board is null....trying for the {counter} time");
......
......@@ -46,13 +46,13 @@ namespace PuzzlePlayer_Namespace
public int[,] lastGeneratedBoard;
// static meathode for filling a int[,] with -1
public static int[,] GetClearBoard(int boardSize)
public static int[,] GetClearBoard(int boardSizeX, int boardSizeY)
{
int[,] result = new int[boardSize, boardSize];
int[,] result = new int[boardSizeX, boardSizeY];
// fill the board with empty spaces (-1)
for (int i = 0; i < boardSize; i++)
for (int i = 0; i < boardSizeX; i++)
{
for (int j = 0; j < boardSize; j++)
for (int j = 0; j < boardSizeY; j++)
result[i, j] = emptySpace;
}
......
......@@ -40,21 +40,21 @@ namespace PuzzlePlayer_Namespace
Point playerPos;
List<Point> shortestPath;
public Maze(int size = 20)
public Maze(int sizeX = 30, int sizeY = 20)
{
drawFactor = 1;
// init all 2D array's
Reset(size);
lastGeneratedBoard = GetClearBoard(size);
Reset(sizeX, sizeY);
lastGeneratedBoard = GetClearBoard(sizeX, sizeY);
description = "The maze is played on a square grid where each cells has walls. You need to navigate through the maze until you reach the end. Use the arrow keys or WASD to move the blue square to the end goal";
}
private void Reset(int size)
private void Reset(int sizeX, int sizeY)
{
boardState = GetClearBoard(size);
mazeState = GetClearBoard(size);
visitedCells = GetClearBoard(size);
boardState = GetClearBoard(sizeX, sizeY);
mazeState = GetClearBoard(sizeX, sizeY);
visitedCells = GetClearBoard(sizeX, sizeY);
playerPos = new Point(0,0);
}
......@@ -96,7 +96,7 @@ namespace PuzzlePlayer_Namespace
public override void Draw(Graphics gr, Rectangle r)
{
// clear screen
gr.FillRectangle(Brushes.Wheat, r);
gr.FillRectangle(Brushes.GhostWhite, r);
Size tilesize = new Size(r.Width / boardState.GetLength(0), r.Height / boardState.GetLength(1));
Pen wall = new Pen(Color.Black, tilesize.Width / 5);
......@@ -119,9 +119,6 @@ namespace PuzzlePlayer_Namespace
if(i == playerPos.X && j == playerPos.Y)
gr.FillRectangle(Brushes.DarkBlue, currentRect);
// draw board outline
gr.DrawRectangle(Pens.LightGray,currentRect);
// drawing walls
(bool top,bool right,bool bottom,bool left) = getWallsFromNumber(mazeState[i,j]);
......@@ -146,11 +143,11 @@ namespace PuzzlePlayer_Namespace
public override void Generate()
{
//clear the board and all 2D array's
Reset(mazeState.GetLength(0));
Reset(mazeState.GetLength(0), mazeState.GetLength(1));
Random rnd = new Random();
int x = rnd.Next(mazeState.GetLength(0));
int y = rnd.Next(mazeState.GetLength(0));
int y = rnd.Next(mazeState.GetLength(1));
if (Recursive_DepthFirstSearchMazeGenerator(x, y))
Debug.WriteLine("Maze succesfully generated");
......@@ -270,8 +267,8 @@ namespace PuzzlePlayer_Namespace
// don't have much in common in regards to solving. So most of the code in the abstract Board class is to no use for us here
public override SOLUTIONS Solve(bool CheckOnly)
{
visitedCells = GetClearBoard(mazeState.GetLength(0));
boardState = GetClearBoard(mazeState.GetLength(0));
visitedCells = GetClearBoard(mazeState.GetLength(0), mazeState.GetLength(1));
boardState = GetClearBoard(mazeState.GetLength(0), mazeState.GetLength(1));
shortestPath = new List<Point>();
shortestPath.Add(new Point(0,0)); // starting point
......@@ -360,13 +357,6 @@ namespace PuzzlePlayer_Namespace
return false;
}
// this methode is not needed because we write our own Solve methode
protected override List<Move> GetSolveList(int[,] boardToSolve)
{
return null;
}
public override void TileInput(Point? p, Keys key)
{
boardState[playerPos.X, playerPos.Y] = 1; //dw
......@@ -400,9 +390,16 @@ namespace PuzzlePlayer_Namespace
boardState[playerPos.X, playerPos.Y] = 1;
}
public override void TileClick(Point p, int x)
public override void Restart()
{
//MessageBox.Show($"{mazeState[p.X, p.Y]}");
base.Restart();
playerPos = new Point(0, 0);
}
// this methode is not needed because we write our own Solve methode
protected override List<Move> GetSolveList(int[,] boardToSolve)
{
return null;
}
}
}
PuzzlePlayer/Resources/Maze.jpg

36.4 KiB | W: | H:

PuzzlePlayer/Resources/Maze.jpg

42.3 KiB | W: | H:

PuzzlePlayer/Resources/Maze.jpg
PuzzlePlayer/Resources/Maze.jpg
PuzzlePlayer/Resources/Maze.jpg
PuzzlePlayer/Resources/Maze.jpg
  • 2-up
  • Swipe
  • Onion skin
PuzzlePlayer/Resources/MazeGray.jpg

36.4 KiB | W: | H:

PuzzlePlayer/Resources/MazeGray.jpg

37.4 KiB | W: | H:

PuzzlePlayer/Resources/MazeGray.jpg
PuzzlePlayer/Resources/MazeGray.jpg
PuzzlePlayer/Resources/MazeGray.jpg
PuzzlePlayer/Resources/MazeGray.jpg
  • 2-up
  • Swipe
  • Onion skin
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