Search code examples
pythonartificial-intelligence

how to implement an AI python solution for the plumbing puzzle


I am currently working on an AI Agent that will be able to identify both the start state and the goal state of the famous old plumbing game found here

https://i.sstatic.net/ngxdI.png

http://html5.gamedistribution.com/a73b1e79af45414a88ce3fa091307084/

The idea is to allow the water to flow from the start point to the exit point, the AI only rotate the tiles, and not all tiles and populated, The problem that this will be an unguided search. I am really lost and help will be appreciated.

What I thought about is that I should assign a number for each tile and rotation and make a series of allowed sequence ? but I am not sure if that's the best way to go or not, because they sequence will be 10! which is huge. The other approach can be assigning the holes of each pipe as North,West,South,East and check if the tiles link ?

The solution should be flexible and tiles might shuffle/Change so assigning the goal state manually won't work.

Any idea will be greatly appreciated.


Solution

  • In the original plumbing game, the player can click on a tile and change it's direction clockwise. This allows to generate a path for the water flow from start to the goal. The amount of possible actions is indeed exponential and can't calculated on a normal computer. To overcome the problem, macro actions are the perfect choice. A macro action is a virtual action not available in the original game. It's a self-invented abstract game on top of the original one. A possible macro action would build a path to a waypoint in the middle, and a second macro action generates a path from the middle to the end. The newly created macro actions can solved independently by a hierarchical planner and the resulting low level actions are executed in the original game.

    A possible programming language to realize macro actions is the game description language, PDDL or a formal grammar. If the concept was understood, even normal Python code can be used to realize the abstract game. A possible macro action results into a state, similar to what is called in the deeplearning community a reward. This allows to subdivide the problem into smaller chunks.

    For the plumbing game, no ready-to-run solver is described in the literature, but the sokoban game was discussed before: Zhou, Neng-Fa, and Agostino Dovier. "A tabled Prolog program for solving Sokoban." Fundamenta Informaticae 124.4 (2013): 561-575.