Prolog if elseif else
正如问题所说,这就是我想在prolog中模拟的。我在做一个游戏,这里有一些代码:Prolog if elseif else,prolog,Prolog,正如问题所说,这就是我想在prolog中模拟的。我在做一个游戏,这里有一些代码: move(X):- get_char(Y) get_char(_), get_char(Z), not(OldLoc='Z'), not(NewLoc = 'Z'), validmove(OldLoc,NewLoc). move(_):- write('Thanks for playing!'), nl. move(X):- write('Invali
move(X):-
get_char(Y)
get_char(_),
get_char(Z),
not(OldLoc='Z'),
not(NewLoc = 'Z'),
validmove(OldLoc,NewLoc).
move(_):-
write('Thanks for playing!'), nl.
move(X):-
write('Invalid move!'), nl,
write('Try Again?'), nl,
move(X).
我想做的是,如果第一个谓词检查在not(OldLoc='Z')、not(NewLoc='Z')、
处失败,那么就转到下一个谓词移动(u),在validmove(OldLoc,NewLoc)
处失败,然后转到下一个移动(X)。我对prolog非常陌生,几乎一无所知。If then else:
另一个if-then-else:
(*-%3E)/2
样本#1:
样本#2:
?- test = test -> print('TRUTH') ; print('FALSE').
TRUTH
?- test = test -> (test2 = test3 -> print('TRUTH'); print('FALSE2')); print('FALSE').
FALSE2