strange behaviuor
- From: Marco <cimmo@xxxxxxxxx>
- Date: Tue, 10 Jan 2006 17:21:49 +0100
Hi,
I'm coding my first program in prolog and I have some difficulties:
I'm trying to code a program that given a random number without repeats the same number.
The problem is when the program starts no random numbers are choosen of course, but "casuale" with the "not" should give true and exit from the loop.
However only the second "casuale" give true and enter in a loop.
What's wrong?
Thanx in advance to all who will help me.
Marco
this is the code:
initial_state([ domandefatte([]), risposte([]), status([asking]) ]).
get_state(State, domandefatte, N) :- member(domandefatte(Done), State), member(N, Done).
casual(S,N,N1):-N is random(3),casuale(S,N,N1).
casuale(S,N,N1):-not(get_state(S,domandefatte,N)), N1 is N.
casuale(S,N,N1):-get_state(S,domandefatte,N), N2 is random(3),casuale(S,N2,N1,B).
start:-initial_state(Old),casual(Old, N, N1). .
- Follow-Ups:
- Re: strange behaviuor
- From: Geoffrey Summerhayes
- Re: strange behaviuor
- From: Marco
- Re: strange behaviuor
- Prev by Date: Re: Generic term search in a list
- Next by Date: for loop in prolog
- Previous by thread: Generic term search in a list
- Next by thread: Re: strange behaviuor
- Index(es):
Relevant Pages
|
|