Reputation: 59
School Project: Create an AI who will use A* search to resolve a rotating pipe puzzle (similar to this game pipes_puzzle_game).
To solve this project I represented every possible board configuration as a node of the graph and an move/edge when you can move from one configuration of a Board to another with just 1 move, so every path to a solving configuration it´s just a series of moves which will be transversed by the A* search.
Unlike the above linked game, in my project you can move any piece in any direction, for example the piece on column and line 0 can move "up, down, left or right", thus on the picture below only needing maximum of 16 moves to get the correct configuration
Picture of the game :
The A* Search Algorithm is already implemented I only need to overwrite the h function. The function A* search will use is f(n) = g(n) + h(n), the g(n) or the cost to move from one configuration to another is uniform and it's 1, the estimated cost h(n) is what i need to implement.
With some research I found two candidates for a Heuristic (could be more it's just what I found):
Count the number of misplacements
Calculates the number of mismatched connections for each piece. A mismatch occurs when the connecting ends of adjacent pieces don't align correctly. When everything is connecting h(n) = 0.
-->Problem: The Heuristic in the example above could calculate >16 thus h(n) > h*(n) (the real cost) which is 16, overestimating the cost
Number of minimum rotations to align in it's correct position
The title is self explanatory the piece is either in his correct position so 0 rotations needed or off his correct position so 1 rotation needed.
-->Problem: I don't know the correct position for each piece, for example the piece in column 1 and line 0 could be to either to right or either to the left. Or to be fair I don´t know how to implement this heuristic
Any ideas are welcome and appreciated, any idea for a new heuristic or any correction to the ones I made are appreciated, thank you!
Anything comment it out I and will answer / change
Upvotes: 1
Views: 128