summaryrefslogtreecommitdiff
path: root/rules/gradual_killer.pl
blob: 2fb15cb98194fa432c9cf5fedb7fd930a45ed053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
% Gradual Killer:
% In the first five rounds it defects, than it cooperates in two rounds.
% If the opponent has defected in rounds 6 and 7, than the Gradual Killer
% keeps defecting forever, otherwise he keeps cooperation forever.

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

gradual_killer(_, d,  [], [1]).
gradual_killer(_, d, [1], [2]).
gradual_killer(_, d, [2], [3]).
gradual_killer(_, d, [3], [4]).
gradual_killer(_, d, [4], [5]).

gradual_killer(_, c, [5], [6]).
gradual_killer(_, c, [6], [7]).

gradual_killer([d,d|_], d, [7], [8,d]):-!.
gradual_killer(_,       c, [7], [8,c]).

gradual_killer(_, Choice, [8,Choice], [8,Choice]).