A Jugs Representation and Successor Function

You can use this code and set up classic jug problems to help debug your search algorithm. Then you can modify it for the "precious fluid" problem. Then you get to figure out your own representations and operators (or successor functions) for the Sam Loyd problems.

People have been getting wrapped around the axle on how to name N operators when N is unknown. I recommend using ONE operator, and naming what it does with its arguments. So (5 8) would be "pour jug 5 into jug 8". Also why not make the pump a jug with special properties and the sink another one with special properties? This makes the operator look very uniform and elegant.

So given those insights, here is CB's solution. It's been 10 years since I did any LISP programming, so it's not inspirational lisp. The successor-generating function directly produces successor nodes that have the operator description (who poured into whom) in them.



[ csc242 Home ]