From 6710108573cf191ad1ceead4a344d77f7db62a62 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 6 Nov 2012 16:34:29 +0100 Subject: prisioners_dilemma: Dont pass user choice to module --- prisoners_dilemma.pl | 5 +++-- 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'), diff --git a/tit4tat.pl b/tit4tat.pl index e03fd5d..6362ecc 100644 --- a/tit4tat.pl +++ b/tit4tat.pl @@ -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). -- cgit