Hi, well i'm having a hard time working with prolog (gprolog). My problem is this, I've the next predicate:
prob(factA,factB,X,first):- X=<50.
prob(factA,factB,X,second):- X>50,X=<80.
prob(factA,factB,X,none):- X>80,X=<100.
that is factA have 50% of probability of occur, factB a 30%, and lastly 20% of non of the facts occur. Also i've others predicate where change the factB but not factA, also change the X intervals.
Now i have the functor:
result(X,Y,N):- random(1,100,I),
prob(X,Y,I,N).
this predicate tells what is N for X an Y in prob. This predicate handle the case:
result(factA,factB,N).
but now i have to handle:
result(factB,factA,N).
and it will return a valid result, any idea?, i did something like this:
result(X,Y,N):- Y = factA,
random(1,100,I),
prob(Y,X,I,N).
J is 100-I,
prob(Y,X,J,N).
but this doesn't manage well the 'none' result.
Somebody has any idea?
Thanks!