Help!!

Discussions related to Visual Prolog
sealrochinha
Posts: 1
Joined: 25 Sep 2012 18:09

Help!!

Unread post by sealrochinha » 25 Sep 2012 18:19

Code: Select all

emission(alfa). emission(beta). emission(gama). detected(X) :- emission(alfa), emission(beta). detected(X) :- emission(gama).
Sorry for my bad english.

Harrison Pratt
VIP Member
Posts: 295
Joined: 5 Nov 2000 0:01

Re: Help!!

Unread post by Harrison Pratt » 25 Sep 2012 22:38

Hint:

(1) You have declared three different types of possible emissions as facts.

(2) You have defined two "rules" for what was detected, but those rules have no way of knowing what emissions were observed. That is, there is no way to input the observed ray emissions to the rule.

Think about rewriting your rules to return the name of a sub-atomic particle when one or more emissions are detected.

Sometimes it's helpful to think in natural language: "If I detect emission 'X' and emission 'Y' then what kind of sub-atomic particle is associated with these emissions?" The emissions detected are the input and the particle type is the output.

I assume you are not ready to work with lists at this stage, so you might need to add an additional type of emission ('nil'). This way you can deal with single or two ray emissions without searching a list. So, you might have a clause like this:

particle_detect( proton, alpha, beta ):- !.
particle_detect( proton, gamma, nil ):- !.
particle_detect( proton, nil, gamma ):- !.
particle_detect( unknown, _, _ ).

This is not a formal solution, just a "thinking model" ... a "gedanken experiment", so to speak.


sealrochinha wrote:

Code: Select all

emission(alfa). emission(beta). emission(gama). detected(X) :- emission(alfa), emission(beta). detected(X) :- emission(gama).
Sorry for my bad english.

Post Reply