Pathfinder for a puzzle game - path-finding

I want to develop a game like this one : https://gamesge.com/fr/fill-one-line-puzzle-game/
Starting with an empty grid I have to create a pathfinder to fill the grid with one line.
I only heard of A* pathfinder and flood-fill algorithm, but I don't think it can help me.
Do you know algorithms which would help me to create my own algorithm to generate the paths?

Backtracking algorithm should be good enough to solve that problem

Related

How to Transform Graph into Grid Map?

I'm making a program that implements procedural content generation (PCG) to create maps in a 2d game.
I use the graph data structure as the basis. then the graph will be transformed into a map like in the example image I attached.
with graph specifications as follows:
-vertex can have more than 4 edges
-allowed the formation of cycles in the graph
any suggestions on what method I can use to transform the graph to a 2d map in a grid with space-tight results?
thanks
Uh, that is a tough one. The first problem you will encounter is whether this is even possible for the graph you use. See more below for that specific topic.
Let's say we ignore the fact that your graph could be impossible to map to a grid. I faced the same issue in my Master's Thesis a few years back. (PDF available here; 3.4 World Generation; page 25). I tried to find an algorithm, that could generate my world from a graph structure but ultimately failed. I tried placing one element after the other and implemented some backtracking in case it got stuck. But in the end you're facing a similar complexity to calculating chess moves. At some point you know you messed up, but you don't know how many steps you should go back/reverse, before trying the next one. If you try to solve this by brute force, you're not going to have a good time. And I did not come up with good heuristics to solve it in an adequate time.
My solution: I decided in the end to go with AnswerSet Programming. You're basically not solving the problem with an algorithm, but you find a (more or less) elegant logical representation of your problem and let a logic solver (program specifically made to find a valid solution to your logical problem-representation) do the work. Have a look in my thesis about the details, it was a few years ago and I didn't use one since. I remember however, that this process was not easy and it took me a few days to find a good logical representation of my problem.
Another question to ask: Could you work on the grid directly? Or maybe on a graph structure representing a grid? In the end a grid is nothing else than a graph; every cell is a node and neighbouring connections are the edges. I have quite some experience in the field and would be happy to help you, if you'd like to share what you want to achieve with your generator. I have also a vast collection of resources about procedural generation, maybe you find something helpful there, too.
More on the planarity of a graph: For your graph to be mappable to a plane, it needs to be planar, and checking so is also not trivial. The easiest way - if I'm not mistaken - is to prove the existence of a non-planar sub-graph, e.g. the K5 (the smallest non-planar a complete graph) or K3,3 (the smallest non-planar complete bipartite graph). And even if your graph is planar, it is not necessarily guaranteed that you can put it on your grid.

Shortest path in a 3D maze

I'm trying to write a program to find the shortest path in a 3D maze using recursion.
I am able to write the code that finds a random path through the maze but I'm wondering how I can modify my code in order to find the shortest path.
Please note that I want to keep the recursive approach.
Can someone suggest a solution?
Here is a sample 2D maze:
s
XXXX
XX X
XXX
Xe X
One starts from s going to e. X is an obstacle and is the route.
It depends on the algorithm you are implementing. If you want a recursive approach then finding a random path is a good start point (although if the problem is too complex then a bad choice could have huge effects on number of attempts needed for convergence). Afterwards you need to modify the path and for example check whether the new path is shorter than the pervious one; if yes then you continue modifying your parameters in the same direction. Otherwise you have to change your direction.
Exit criterium for the algorithm/ program is normally the difference between the found solution and the ideal solution. So if you know the length of the ideal path (the optimal solution, you need not know the path itself but only its length) in advance then you can define an error margin of 10^-9 for example and once the difference between both solutions is less than this margin your algorithm exits.
In conclusion, this question is a mathematical optimization problem. Optimization is a field which has well-established literature eventhough it is a little bit complex. However if I were you I would search for shortest path algorithms and implement one which is best suited to my application (3D Maze)

Shortest Path Algorithm in a partial graph

I am recursively building a graph in java using the graphstream library.. however this graph is so huge so that the recursion is very deep and this ends in stackoverflow. Believe me, even an iteration wouldn't solve my problem.. I will just get a runtime error down the road.
My goal is to use a search algorithm such as Disjktra or A* or whatsoever on the graph in the end.
As I dont have the whole graph, I have been looking in the literature for things such as a shortest path algorithm in a partial maps; use of heuristics I couldn't find much.
I would appreciate it if someone could give me some hints (papers, ideas; an implementation would be a jackpot!!!! :-D) I have looked at algorithms such as PHA* or some others..
I know this post is very old... But I solved it back then using a 1990 Algorithm, from Korf, R. E. (1990) "Real-time heuristic search" Can be found here: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.137.1955&rep=rep1&type=pdf

How to recognise numbers in images using Netlogo programming sudoku

Hi everyone i have a problem of being able to identify numbers in an image using netlogo programming, Please any ideas or techniques on how to be able to identify numbers in a cell? I am making a sudoku game using netlogo coding. First i need to import an image into the screen and be able to setup the image.
I need to be able to use the image(s) to generate random sudoku puzzles without any repetitions. But first to make the sudoku game i have to be able to use the numbers from the image.
I have got this code so far
to setup
clear-all
import-pcolors "s1.png"
reset-ticks
end
to go
ask patches with [pcolor != black]
[ set pcolor white ]
end
Please i need a simple algorithm for recognizing numbers in sudoku netlogo
It seems like what you are asking is how to do OCR (optical character recognition) in NetLogo.
This is not something that NetLogo does "out of the box", and as far as I know, there is currently no NetLogo extension that does that either.
And no, there is no "simple algorithm for recognising numbers" that you can just copy-paste in your NetLogo code.
So what can you do?
In theory, you could write a new NetLogo extension that interfaces with an existing OCR package, but that's not a trivial task.
You could also ask the NetLogo users group if anyone has ever tried to do that before. Maybe someone there will have more insight for you.
If I were doing this I would do 10 breads of turtles with shapes "0".."9". So I would not have to recognize numbers but simply recognize breed of turtles.
You could try and build the pattern recognition within NetLogo, provided your individual Sudoku cells have a decent resolution (say at least 9x9 patches). Then match each cell to a predefined 9x9 patch pattern representing each of the 9 digits. Save your result as the 9 different breeds of turtles.
(I have not tried this myself)

what is the best way to draw automata using the mouse?

I need a efficient way the draw some finite automata , I tried using word shapes but it very exhausting. I looking for another way to do that only by mouse drawing (not java extant like jgraph or graphviz).
EDIT :
Since no one answered me , after some tests I think that best way to draw simple automata is using power point .
If you want alternatives for windows the famous one is xfig. There is also IPE. The hardcore automators use gastex.

Resources