From fd99135d56318546bd6a7d811fd16771f64114f8 Mon Sep 17 00:00:00 2001 From: Floris <f.k.h.vandezande@students.uu.nl> Date: Wed, 18 Dec 2024 11:30:14 +0100 Subject: [PATCH] skyscraper... --- PuzzlePlayer/Board.cs | 28 +--------------------------- PuzzlePlayer/PuzzlePlayer.cs | 2 +- PuzzlePlayer/Skyscrapers.cs | 27 +++------------------------ 3 files changed, 5 insertions(+), 52 deletions(-) diff --git a/PuzzlePlayer/Board.cs b/PuzzlePlayer/Board.cs index a18ffc6..611e5c5 100644 --- a/PuzzlePlayer/Board.cs +++ b/PuzzlePlayer/Board.cs @@ -60,19 +60,6 @@ namespace PuzzlePlayer_Namespace } - // checks if the board is valid and solvable before setting the variable. - public bool setBoardState(int[,] newState) - { - int[,] copy = boardState; - boardState = newState; - if (IsBoardValid(newState) && Solve(false) == SOLUTIONS.UNIQUE) - return true; - else - { - boardState = copy; - return false; - } - } public abstract void Draw(Graphics gr, Rectangle r); // a methode for solving the whole board. It uses the private SolveStep methode untill the whole board is solved @@ -108,20 +95,7 @@ namespace PuzzlePlayer_Namespace } // abstract methode for solving one step - private Move? SolveStep(int[,] currentBoardState) - { - // get a list with all the possible moves - List<Move> moves = GetSolveList(currentBoardState); - - // if there are no moves found then null is returned - if (moves.Count == 0) - return null; - - // return one of the possible moves - // (if the first one is always chosen than that may lead to expected behavior. For example if the possible moves are checked in a certain order) - Random rnd = new Random(); - return moves[rnd.Next(0, moves.Count - 1)]; - } + public virtual Point Hint() { return new Point(0, 0); } // a abstract methode to get a list of all possible moves protected abstract List<Move> GetSolveList(int[,] boardToSolve); diff --git a/PuzzlePlayer/PuzzlePlayer.cs b/PuzzlePlayer/PuzzlePlayer.cs index b1d6742..5486c3b 100644 --- a/PuzzlePlayer/PuzzlePlayer.cs +++ b/PuzzlePlayer/PuzzlePlayer.cs @@ -10,7 +10,7 @@ namespace PuzzlePlayer_Namespace { internal static void Main(string[] args) { - Application.Run(new PuzzleForm(new Skyscrapers(6))); + Application.Run(new MainForm()); } } diff --git a/PuzzlePlayer/Skyscrapers.cs b/PuzzlePlayer/Skyscrapers.cs index cb24eea..b38470d 100644 --- a/PuzzlePlayer/Skyscrapers.cs +++ b/PuzzlePlayer/Skyscrapers.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; using System.Drawing.Text; using System.IO; @@ -9,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Forms.Design; +using System.Windows.Forms.VisualStyles; namespace PuzzlePlayer_Namespace { @@ -96,30 +98,7 @@ namespace PuzzlePlayer_Namespace public override void Generate() { - 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; + } public override void TileInput(Point? p, Keys k) -- GitLab