thors
New Member
CS Dweeb
Posts: 23
|
Post by thors on Feb 8, 2009 8:19:24 GMT -5
Hi all, If anyboady is reading this, does someone have a clue on why the following fails ? Directly, this works: ?- bagof(Y, legal(xplayer,Y), Moves). Moves = [mark(1,1),mark(1,2),mark(1,3),mark(2,1),mark(2,2),mark(2,3),mark(3,1),mark(3,2),mark(3,3)] ? ;
But when defined: retrieve_valid_states( _l ) :- bagof( _r, legal( _l , _r ), _m ). ?- retrieve_valid_states(X). X = oplayer ? ; X = xplayer ? ;
It "fails" by returning the incorrect values. It's driving me slightly mad... Well.. even a little more than slightly
|
|
|
Post by kristjanbb02 on Feb 9, 2009 18:28:53 GMT -5
It's kinda late now and you have probably noticed by now.
You are asking it for _l and it is just returning that correctly while you probably want _m like:
?- assert((retrieve_valid_states( _m ) :- bagof( _r, legal( _l , _r ), _m ))). true ? yes ?- retrieve_valid_states( X ). X = [noop] ? ; X = [mark(1,1),mark(1,2),mark(1,3),mark(2,1),mark(2,2),mark(2,3),mark(3,1),mark(3,2),mark(3,3)] ? ; no
or more likely what you want is _m for specific role _l like:
?- assert((retrieve_valid_states( _l, _m ) :- bagof( _r, legal( _l , _r ), _m ))). true ? yes ?- retrieve_valid_states( xplayer, X ). X = [mark(1,1),mark(1,2),mark(1,3),mark(2,1),mark(2,2),mark(2,3),mark(3,1),mark(3,2),mark(3,3)] ? yes
|
|