:- dynamic (currentPlayer/1).
currentPlayer(ucup).
printtest(X):-
currentPlayer(X),
format('Current player is: ~w\n', [X]),
retract(currentPlayer(X)),
assertz(currentPlayer(asep)).
I dont get why it keeps telling me there are syntax error, while last time i check my syntax is right. The error i got is :
syntax error: . or operator expected after expression
1 error(s)
and it this error leads to the first line. My expectation: if i run the printtest query (printtest(ucup)), it will prints out, but the second time, it change to no as the current player is now asep, so it should be printtest(asep) which would printout the text.
The ISO Prolog standard, which GNU Prolog follows closely, doesn't require the atom
dynamic
to be declared as an operator. You get that error due to the space afterdynamic
. Write instead: