diff options
-rw-r--r-- | tit4tat.pl | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -33,15 +33,21 @@ tit4tat(A, Hist, PayA, PayB) :- tit4tat_select(Old, Hist), step(A, Old, PayA, PayB). +sum([], 0). +sum([H|T], S):-sum(T, TMP), S is TMP + H. + loop(end, _). -loop(End, Hist):- End\=end, - write('Type c,d or end to end: '), read(Choice), +loop(End, Hist, PayedA, PayedB):- End\=end, + write('Type c,d or e to end: '), read(Choice), tit4tat(Choice, Hist, PAY_A, PAY_B), - write('A Pay: '),write(PAY_A),nl, - write('B Pay: '),write(PAY_B),nl, + write('A Pay: '),write(PAY_A),write('\t'), + write('B Pay: '),write(PAY_B),write('\t'), + write('A: '), sum([PAY_A|PayedA], SumA), write(SumA), write('\t'), + write('B: '), sum([PAY_B|PayedB], SumB), write(SumB), nl, + - loop(Choice, [Choice|Hist]). + loop(Choice, [Choice|Hist], [PAY_A|PayedA], [PAY_B|PayedB]). -start:-loop(noend, []). +start:-loop(noend, [], [], []). |