[英]Use a queries result for calculation
當然這是一個愚蠢的問題,但我自己無法回答。 我有以下代碼:
%% Ownedby-relationship in monopoly
ownedby(bank,weststation).
%% Account-Value:
account(player1,1500).
%% Prices
price(weststation,200).
%% Buy an estate in monopoly
buy(X,Y):-
ownedby(bank,X),
!,
retract(ownedby(bank, X)),
assert(ownedby(Y,X)),
price(X,Price),
account(Y,Accountold),
retract(account(Y,Accountold)),
assert(account(Y,Accountold-Price)).
%% Example:
buy(player1,weststation).
%% RESULT:
account(player1,X).
1500-200
所以字符串1500和200是連接在一起的,但是沒有數字被減去... :(這是什么原因?
您的規則需要更正
...
NewValue is Accountold-Price,
assert(account(Y,NewValue)).
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.