summaryrefslogtreecommitdiff
path: root/rules/tit4tat.pl
blob: cacbe1661da4a4d835f466c68128afc838488d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
% Tit for Tat:
% Begins with cooperation and then plays what its opponent played in the last
% move (if the opponent defects in some round, Tit for Tat will defect in the
% following one; to cooperation it responds with cooperation).

% Syntax: tit4tat(+history, -choice, +state_in, -state_out)

% Use opponents last decision
tit4tat([Last|_],Last,_,_).
% Fallback to coorporate if history is empty.
tit4tat([],c,_,_).