| | |
Some Prolog Help Please
![]() |
•
•
Join Date: May 2004
Posts: 217
Reputation:
Solved Threads: 0
Hey all. Anyone know prolog language?
My dillema is:
and my code:
What must I do to make it check that bully is not with nerd, nerd not with apple and that they are all at the office?
HUGE thanks in advance.
My dillema is:
A teacher is on playground duty encounters a problem with a bully, a hungry nerd and an apple and he must escort these three to the office. The teacher, by school rules, can only escort one at a time to the office. This is compounded by the fact that if the bully is left with the nerd the bully will beat up the nerd and if the nerd is left with the apple then the nerd will eat the apple. This will happen both in the playground as well as in the office.
and my code:
move(state(X,X,X,notsolved), solved, state(X,X,X,solved)). move(state(P1,B,A,notsolved), movenerd(P1,P2), state(P2,B,A,notsolved)). move(state(N, P1, P,notsolved), moveapple(P1,P2), state(N, P2, B,notsolved)). move(state(N, A, P1,notsolved), movebully(P1, P2), state(N, A, P2, H,notsolved)). escort(state(_,_,_,solved)). escort(OldState) :- move(OldState, Move, NewState), escort(NewState), write(Newstate), nl.
What must I do to make it check that bully is not with nerd, nerd not with apple and that they are all at the office?
HUGE thanks in advance.
•
•
Join Date: May 2004
Posts: 217
Reputation:
Solved Threads: 0
Where the heck is the edit button nowadays? I got it for this and other posts, but not my post above 
anyway the problem is:
A teacher is on playground duty encounters a problem with a bully, a hungry nerd and an apple and he must escort these three to the office. The teacher, by school rules, can only escort one at a time to the office. This is compounded by the fact that if the bully is left with the nerd the bully will beat up the nerd and if the nerd is left with the apple then the nerd will eat the apple. This will happen both in the playground as well as in the office.

anyway the problem is:
A teacher is on playground duty encounters a problem with a bully, a hungry nerd and an apple and he must escort these three to the office. The teacher, by school rules, can only escort one at a time to the office. This is compounded by the fact that if the bully is left with the nerd the bully will beat up the nerd and if the nerd is left with the apple then the nerd will eat the apple. This will happen both in the playground as well as in the office.
Last edited by marceta; Oct 30th, 2006 at 10:56 pm.
•
•
•
•
Where the heck is the edit button nowadays? I got it for this and other posts, but not my post above
As for the problem: I don't know the answer. If you first move the nerd to the office, that leave the bully and apple together on the playground -- that's ok. But I don't know how to solve the problem at that point. Do you ? If not, please repost this in the Geek's Lounge and hopefully some (or lots) of people can help solve it.
Last edited by Ancient Dragon; Nov 1st, 2006 at 12:04 am.
![]() |
Similar Threads
- Need Help In prolog Language (Legacy and Other Languages)
- Prolog permutation (Legacy and Other Languages)
- Programming Prolog in C++ (C++)
- Prolog (Computer Science)
Other Threads in the Legacy and Other Languages Forum
- Previous Thread: MATLab random dots help
- Next Thread: adding bit stuffing in NRZI algorithms (matlab)
| Thread Tools | Search this Thread |






