IDA* with 15-puzzle, help needed - artificial-intelligence

I have to make a visualisation of the IDA*(iterative deepening A star) algorithm when it is running a 15-puzzle problem. Exactly, I need to visualize the tree and the puzzle.
IDA* algorithm is similar to the A* algorithm. link 1 2 3
There are 3 things I need to implement:
1)The IDA* code.
2)After that, the IDA* connected with the problem(15-puzzle).
3)And, after that, I need to visualize the tree of the algorithm.
But I believe that someone before must have implemented the code for the IDA* running the 15-puzzle problem. I need your help to find this source code so that I would not spent 2 months writing code that has been written by someone else before, so that I would have time to focus on the visualization.
15-puzzle link 1 , link 2
I know some C,C++ and C#.
I need a simple source code, that I would comprehend, in which you input a table as a puzzle and it gives you back as a table with the solved puzzle.
Secondly, what programming language from the 3 above do you suggest me to use for the visualization?
I have found some implementations:
IDA* in LISP
A* in C++, I need IDA*
IDA* in java
IDA* in pheudocode link1 link2 link3
IDA* in C
IDA* with 15-puzzle
15-puzzle solved in an applet
A* and IDA* that solves Sliding puzzle (This one uses templates that aren't defined)

IDA* takes approximately ten minutes to implement. Your heuristic function is trivial, I guess you at least manage to implement manhattan distance (there are better heuristics, but this'll do).
Then you simply implement A* and then add the cut-off limit criteria. The Wikipedia article you link to even has an implementation in Python you simply can translate.

Related

Search Algorithm for Pacman

I need to find the path with the lower cost in a graph represented by a matrix. I researched a bit on the Dijkstra's algorithm but I need a vector with the sequence of nodes in the shortest path, not the distance itself. The game is being made ​​for Assembly, but if anyone knows an implementation in C at least it's gonna help a lot. I will use it to calculate the route of ghosts, matching heuristic algorithms to create the Very Hard Mode of the game. I also tried something with A*, but the implementations I found used struct, which are not applicable to the situation. Thanks a lot since now. ^^
This problem is the basis for the edx AI course. I've managed to google a breadth first search code written in C here. From what I can remember breadth first search is guarenteed to find the shortest path if it exists.
I don't think it would be too hard to add a heuristic algorithm in there either, there should be notes on the edx link that would help with that.

PACMAN: a short path for eating all the dots

I am trying to find a solution for the PACMAN problem of finding a short path (not the shortest, but a good one) that eats all the dots in a big maze. I've seen a lot of people talking about TSP, Dijsktra, BFS, A*. I don't think this is a TSP since I don't have to go back where I started and I can repeat node if I want. And I don't think Dijsktra, BFS and A* would help because I'm not looking for the shortest path and even if that was the case, it wouldn't give a answer in a reasonable time.
Could anyone give me hints on this? What kind of problem is this? Is this a kind of TSP? What kind of algorithms approach this problem in a efficient way? I'd appreciate any hints on implementation.
I take it you're trying to do contest where you find the shortest path in the big maze in under 30 seconds?
I actually did this last year for fun (my college class didn't do the contest). After weeks of research, I was able to do an exact solution of the maze in under 30 seconds.
The heuristic I used was actually an exact heuristic. I wrote a bunch of code to find the minimal path length using a much more efficient algorithm based on graph decomposition and dynamic programming, and then fed the results back into A* as the 'heuristic' value.
The key thing to realize is that while the graph is very big (273 nodes), it has a low carving width (5), meaning that it can be solved efficiently using a fixed parameter tractable algorithm.
Hopefully that's enough keywords to get you on the right track.
Update: I wrote a blog post explaining the solution

how to align two meshes

I have a very nice & tricky question for you.
I need to align two meshes using a very fast algorithm. Given mesh1 and mesh2 I want to find how I need to traslate and rotate mesh1 to be in the same position of mesh2.
Firstly I did this using inertia moments of the two meshes, but the algorithm does not work if the second mesh is similar to the first one but with some missing parts. In other words, take two identical meshes and from one of them cut same parts off.
I'd like to write the code in C because I need to perform that on multiplatform machines (linux/win) and do that in a very fast way: it has to be put into a GA algorithm.
The two meshes are in STL (stereolitography) format (binary or ascii) but maybe can be useful using another kind of file format.
Do you have any idea how to perform this stuff?
question update:
first of all I want to thank you guys very much for all your suggestions. I've downloaded an install PCL on my machine and compiled the ICP (tutorial) algorithm successfully, taken from PCL web site.
But now I have some questions about that, maybe because for me is a brand new thing. what is the meaning of the 4x4 matrix output for the fitness? I should expect a rotational matrix and a traslational vector..
I hope some of you can help me.
If you need any other info please ask.
Point Cloud Library has several resources that you may find useful. As #Throwback1986 says, ICP is one excellent algorithm for aligning geometry. Pcl also features other, often faster alignment algorithms, based on identifying and matching features of interest in two pieces of geometry. The library finds a lot of use in the robotics communities, who, like you, are very performance conscious.
Pcl is written in c++. While not as portable as straight C, They offer installation instructions for windows, a few *nix flavors, and mac os. I've seen it running on ios and android as well. Check out the tutorials.
Iterative Closest Point (ICP) is one way of registering (aligning) 3D point clouds with rigid transformations. (It can also apply to meshes.)
Here is a good introduction: http://www.cs.duke.edu/courses/spring07/cps296.2/scribe_notes/lecture24.pdf
Here is a reasonable summary:
students.asl.ethz.ch/upl_pdf/314-report.pdf
Here is a matlab implementation:
http://www.mathworks.com/matlabcentral/fileexchange/12627-iterative-closest-point-method
Here are some potential optimizations:
http://www.cs.princeton.edu/~smr/papers/fasticp/

Matrix solving with C (within CUDA)

As part of a larger problem, I need to solve small linear systems (i.e NxN where N ~10) so using the relevant cuda libraries doesn't make any sense in terms of speed.
Unfortunately something that's also unclear is how to go about solving such systems without pulling in the big guns like GSL, EIGEN etc.
Can anyone point me in the direction of a dense matrix solver (Ax=B) in straight C?
For those interested, the basic structure of the generator for this section of code is:
ndarray=some.generator(N,N)
for v in range N:
B[v]=_F(v)*constant
for x in range N:
A[v,x]=-_F(v)*ndarray[x,v]
Unfortunately I have approximately zero knowledge of higher mathematics, so any advice would be appreciated.
UPDATE: I've been working away at this, and have a nearly-solution that runs but isn't working. Anyone lurking is welcome to check out what I've got so far on pastebin.
I'm using Crout Decomposition with Pivoting which seems to be the most general approach. The idea for this test is that every thread does the same work. Boring I know, but the plan is that the matrixcount variable is increased, actual data is put in, and each thread solves the small matrices individually.
Thanks for everyone who's been checking on this.
POST-ANSWER UPDATE: Finished the matrix solving code for CPU and GPU operation, check out my lazy-writeup here
CUDA won't help here, that's true. Matrices like that are just too small for it.
What you do to solve a system of linear equations is LU decomposition:
http://en.wikipedia.org/wiki/LU_decomposition
http://mathworld.wolfram.com/LUDecomposition.html
Or even better a QR decomposition with Householder reflections like in the Gram-Schmidt process.
http://en.wikipedia.org/wiki/QR_decomposition#Computing_the_QR_decomposition
Solving the linear equation becomes easy afterwards, but I'm afraid there always is some "higher mathematics" (linear algebra) involved. That, and there are many (many!) C libraries out there for solving linear equations. Doesn't seem like "big guns" to me.

A* implemented in C

Where can I find an A* implementation in C?
I was looking around but it seems my google-fu is not strong enough. I've started writing my own implementation, but then I remembered Stack Overflow and I thought I should ask here first. It seems a bit complicated to write a real A* implementation - I was tempted to just write an implementation of Dijkstra's algorithm for a binary grid, since that's all I really need, but I feel like I want to have a C A* implementation in my repertoire.
Your google-fu is indeed weak, young padawan :-)
Try googling for astar c.
The first and second links are actual code implementations (the first under a liberal MIT licence, no idea about the second).
here you can find the pseudocode: http://en.wikipedia.org/wiki/A*
to find the right code for you just search after:
astar graph search algorithm C

Resources