Ok Im rather stuck as I cant find many examples similar too this (and prolog isnt my strong point). Basically I need to find out the value of a state. If it is the goal then the value is 0, if the goal can be reached in 1 move then the value if 1 (all possible moves from a current state can be found using nextstate([1,1,1,1],X) etc.) If the value of the next state is 0 then the value of the current state is 1 and vice versa. How do I start doing this?
Prolog - depth first search
Started by Praetorian, Apr 15 2007 04:21 PM
1 reply to this topic
#1
Posted 15 April 2007 - 04:21 PM
#2
Posted 15 April 2007 - 04:28 PM
Try a predicate that looks something like: (not in prolog syntax)
parity(S1) is
0 if S1 is goal OR nextstate(S1, S2) and parity(S2) = 1,
1 if nextstate(S1, S2) and parity(S2) = 0.
This might cause problems if there are multiple paths from the states to the goal, where some are even length and others are odd length. In that case the parity's not uniquely definable.
parity(S1) is
0 if S1 is goal OR nextstate(S1, S2) and parity(S2) = 1,
1 if nextstate(S1, S2) and parity(S2) = 0.
This might cause problems if there are multiple paths from the states to the goal, where some are even length and others are odd length. In that case the parity's not uniquely definable.
reedbeta.com - developer blog, OpenGL demos, and other projects
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











