Skip to content
Snippets Groups Projects
Commit 59e7a713 authored by Floris's avatar Floris
Browse files

update

parent 9b5db69c
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ namespace PuzzlePlayer_Namespace
{
internal static void Main(string[] args)
{
Application.Run(new PuzzleForm(new Skyscrapers()));
Application.Run(new PuzzleForm(new Skyscrapers(6)));
}
}
......
......@@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Linq;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace PuzzlePlayer_Namespace
{
......@@ -16,14 +18,18 @@ namespace PuzzlePlayer_Namespace
public string[,] candidateState;
public Skyscrapers(int boardSize = 6)
{
boardState = GetClearBoard(boardSize);
lastGeneratedBoard = GetClearBoard(boardSize);
candidateState = new string[boardSize, boardSize];
boardState = GetClearBoard(boardSize + 2);
lastGeneratedBoard = GetClearBoard(boardSize + 2);
candidateState = new string[boardSize + 2, boardSize + 2];
description = "lol";
drawFactor = 1;
candidateState[1, 1] = "123";
candidateState[2, 3] = "1734";
candidateState[4, 4] = "123456789";
boardState[1, 1] = 1;
boardState[2, 2] = 2;
boardState[3, 3] = 3;
boardState[4, 4] = 4;
}
public override void Draw(Graphics gr, Rectangle r)
{
......@@ -90,13 +96,29 @@ namespace PuzzlePlayer_Namespace
public override void Generate()
{
int[] remaining = new int[boardState.GetLength(0)];
for (int i = 0; i < remaining.Length; i++)
remaining[i] = i + 1;
for (int i = 0; i < boardState.GetLength(0); i++)
boardState = GetClearBoard(boardState.GetLength(0));
candidateState = new string[boardState.GetLength(0), boardState.GetLength(1)];
Random random = new Random();
void RandomFillLine(int direction)
{
List<int> options = new List<int>();
for (int i = 0; i < boardState.GetLength(0) - 2; i++)
options.Add(i + 1);
int deficit = 0;
if (boardState[1, 1] != emptySpace)
{
options.Remove(boardState[1, 1]);
deficit++;
}
for (int i = deficit; i < boardState.GetLength(0) - 2; i++)
{
int index = random.Next(options.Count);
boardState[1 + i * (1 - direction), 1 + i * direction] = options[index];
options.RemoveAt(index);
}
}
RandomFillLine(0);
RandomFillLine(1);
return;
}
......
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