diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-06 16:34:29 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-06 16:34:29 +0100 |
commit | 6710108573cf191ad1ceead4a344d77f7db62a62 (patch) | |
tree | 827870e30c4bbb710b639b1857677348077477c5 | |
parent | a3b6186a07ec266dd1283efd06062d23aede24d4 (diff) | |
download | wbs-6710108573cf191ad1ceead4a344d77f7db62a62.tar.gz wbs-6710108573cf191ad1ceead4a344d77f7db62a62.tar.bz2 wbs-6710108573cf191ad1ceead4a344d77f7db62a62.zip |
prisioners_dilemma: Dont pass user choice to module
-rw-r--r-- | prisoners_dilemma.pl | 5 | ||||
-rw-r--r-- | tit4tat.pl | 11 |
2 files changed, 6 insertions, 10 deletions
diff --git a/prisoners_dilemma.pl b/prisoners_dilemma.pl index 66578e8..a8e3a33 100644 --- a/prisoners_dilemma.pl +++ b/prisoners_dilemma.pl @@ -24,14 +24,15 @@ pay(d,c,4). pay2(A, B, PayA, PayB) :- pay(A, B, PayA), pay(B, A, PayB). -decide(Module, A, Hist, PayA, PayB) :- call(Module, A, Hist, PayA, PayB). +decide(Module, Hist, Decision) :- call(Module, Hist, Decision). sum([], 0). sum([H|T], S) :- sum(T, TMP), S is TMP + H. do(e, _, _, _, _) :- !. do(Choice, Module, Hist, PayedA, PayedB) :- - decide(Module, Choice, Hist, PayA, PayB), + decide(Module, Hist, ModuleDecision), + pay2(Choice, ModuleDecision, PayA, PayB), write('A Pay: '), write(PayA), write('\t'), write('B Pay: '), write(PayB), write('\t'), @@ -1,9 +1,4 @@ -% % Use opponents last decision -tit4tat_select(H,[H|_]). -% Fallback to coorporate at beginning -tit4tat_select(c,[]). - -tit4tat(A, Hist, PayA, PayB) :- - tit4tat_select(Old, Hist), - pay2(A, Old, PayA, PayB). +tit4tat([Last|_],Last). +% Fallback to coorporate if history is empty. +tit4tat([],c). |