From f22d7a9894d530fa2f8ceaeff3a8a52746ad7a1c Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 8 Nov 2012 11:04:25 +0100 Subject: Prisoners Dilemma: Add descriptions to non-trivial understandable modules --- grudger.pl | 1 + hard_tit4tat.pl | 4 ++++ mistrust_tit4tat.pl | 3 ++- naive_prober.pl | 7 ++++--- pavlov.pl | 1 + tit4tat.pl | 5 +++++ 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/grudger.pl b/grudger.pl index b075a42..76f9629 100644 --- a/grudger.pl +++ b/grudger.pl @@ -1,3 +1,4 @@ +% Grudger, Spiteful: % Cooperates until the second has defected, after % that move defects forever (he does not forgive). % http://euler.fd.cvut.cz/predmety/game_theory/lecture_repeat.pdf diff --git a/hard_tit4tat.pl b/hard_tit4tat.pl index 5bff447..8efc124 100644 --- a/hard_tit4tat.pl +++ b/hard_tit4tat.pl @@ -1,2 +1,6 @@ +% Hard Tit for Tat: +% Cooperates unless the opponent has defected +% at least once in the last two rounds. + hard_tit4tat([A,B|_],d,_,_):-(A=d;B=d),!. hard_tit4tat(_,c,_,_). diff --git a/mistrust_tit4tat.pl b/mistrust_tit4tat.pl index 3c150c5..5e80c02 100644 --- a/mistrust_tit4tat.pl +++ b/mistrust_tit4tat.pl @@ -1,4 +1,5 @@ -% Syntax: MODULE(UserDecisionHistry [in], ModuleDecision [out]) +% Mistrust Tit for Tat: +% In the first round it defects, than it plays opponent’s move. % Use opponents last decision mistrust_tit4tat([Last|_],Last,_,_). diff --git a/naive_prober.pl b/naive_prober.pl index dde376d..df2bcf5 100644 --- a/naive_prober.pl +++ b/naive_prober.pl @@ -1,6 +1,7 @@ -% Naive Prober: Like Tit for Tat, but sometimes, after the -% opponent has cooperated, it defects (e.g. at random, in -% one of ten rounds in average). +% Naive Prober: +% Like Tit for Tat, but sometimes, after the opponent has cooperated, it +% defects (e.g. at random, in one of ten rounds in average). + naive_prober([d|_],d,_,_). % but only for for 90% if coorporated naive_prober([c|_],Choice,_,_):-random(Number), (Number < 0.1 -> Choice=d; Choice=c). diff --git a/pavlov.pl b/pavlov.pl index cc33a73..0da8011 100644 --- a/pavlov.pl +++ b/pavlov.pl @@ -1,3 +1,4 @@ +% Pavlov: % Cooperates if and only if both players opted for the % same choice in the previous move, otherwise it defects. pavlov([], c, _, c):-!. diff --git a/tit4tat.pl b/tit4tat.pl index 47d8535..2cf520c 100644 --- a/tit4tat.pl +++ b/tit4tat.pl @@ -1,3 +1,8 @@ +% 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: MODULE(UserDecisionHistry [in], ModuleDecision [out]) % Use opponents last decision -- cgit