943,515 Members | Top Members by Rank

Ad:
Oct 30th, 2006
0

Some Prolog Help Please

Expand Post »
Hey all. Anyone know prolog language?

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.
Similar Threads
Reputation Points: 13
Solved Threads: 0
Posting Whiz in Training
marceta is offline Offline
217 posts
since May 2004
Oct 30th, 2006
0

Re: Some Prolog Help Please

please do not wrap the program requirements in code tags because it is difficult to read with all of it on the same line.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,945 posts
since Aug 2005
Oct 30th, 2006
0

Re: Some Prolog Help Please

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.
Last edited by marceta; Oct 30th, 2006 at 10:56 pm.
Reputation Points: 13
Solved Threads: 0
Posting Whiz in Training
marceta is offline Offline
217 posts
since May 2004
Oct 31st, 2006
0

Re: Some Prolog Help Please

Click to Expand / Collapse  Quote originally posted by marceta ...
Where the heck is the edit button nowadays? I got it for this and other posts, but not my post above
I think you only have 30 minutes to edit a post.

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,945 posts
since Aug 2005
Nov 7th, 2006
0

Re: Some Prolog Help Please

nerd office
apple office
take nerd back
bully office
nerd office
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chrise2 is offline Offline
1 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Legacy and Other Languages Forum Timeline: MATLab random dots help
Next Thread in Legacy and Other Languages Forum Timeline: adding bit stuffing in NRZI algorithms (matlab)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC