diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-12 10:37:23 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-12 10:37:23 +0100 |
commit | 565fbb75729138607c75c9ddcaca385402d67944 (patch) | |
tree | 78dc67b79c891dcd5c953cc929b489accb930c68 | |
parent | 7e23cb0e2a2ad82cddf354ee0d3c2773b99b4d02 (diff) | |
download | wbs-565fbb75729138607c75c9ddcaca385402d67944.tar.gz wbs-565fbb75729138607c75c9ddcaca385402d67944.tar.bz2 wbs-565fbb75729138607c75c9ddcaca385402d67944.zip |
Prisoners Dilemma: Add parameter description to modules
-rw-r--r-- | rules/always_coorporate.pl | 2 | ||||
-rw-r--r-- | rules/always_defect.pl | 2 | ||||
-rw-r--r-- | rules/gradual_killer.pl | 2 | ||||
-rw-r--r-- | rules/grudger.pl | 2 | ||||
-rw-r--r-- | rules/hard_tit4tat.pl | 2 | ||||
-rw-r--r-- | rules/mistrust_tit4tat.pl | 2 | ||||
-rw-r--r-- | rules/naive_prober.pl | 2 | ||||
-rw-r--r-- | rules/pavlov.pl | 3 | ||||
-rw-r--r-- | rules/periodically_ddc.pl | 3 | ||||
-rw-r--r-- | rules/periodically_ssz.pl | 3 | ||||
-rw-r--r-- | rules/random_choice.pl | 3 | ||||
-rw-r--r-- | rules/tit42tat.pl | 2 | ||||
-rw-r--r-- | rules/tit4tat.pl | 2 |
13 files changed, 30 insertions, 0 deletions
diff --git a/rules/always_coorporate.pl b/rules/always_coorporate.pl index e6094df..c6646a3 100644 --- a/rules/always_coorporate.pl +++ b/rules/always_coorporate.pl @@ -1 +1,3 @@ +% Syntax: always_coorporate(+history, -choice, +state_in, -state_out) + always_coorporate(_, c, _, _). diff --git a/rules/always_defect.pl b/rules/always_defect.pl index f9fd91d..aea4bd6 100644 --- a/rules/always_defect.pl +++ b/rules/always_defect.pl @@ -1 +1,3 @@ +% Syntax: always_defect(+history, -choice, +state_in, -state_out) + always_defect(_, d, _, _). diff --git a/rules/gradual_killer.pl b/rules/gradual_killer.pl index 599ef3e..c40eeb9 100644 --- a/rules/gradual_killer.pl +++ b/rules/gradual_killer.pl @@ -3,6 +3,8 @@ % 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]). diff --git a/rules/grudger.pl b/rules/grudger.pl index 76f9629..7d8eb88 100644 --- a/rules/grudger.pl +++ b/rules/grudger.pl @@ -3,6 +3,8 @@ % that move defects forever (he does not forgive). % http://euler.fd.cvut.cz/predmety/game_theory/lecture_repeat.pdf +% Syntax: grudger(+history, -choice, +state_in, -state_out) + grudger([], c, _, _). grudger([d|_], d, _, _). grudger([c|Tail], Decision, _, _) :- grudger(Tail, Decision, _, _). diff --git a/rules/hard_tit4tat.pl b/rules/hard_tit4tat.pl index 8efc124..6ba56e6 100644 --- a/rules/hard_tit4tat.pl +++ b/rules/hard_tit4tat.pl @@ -2,5 +2,7 @@ % Cooperates unless the opponent has defected % at least once in the last two rounds. +% Syntax: hard_tit4tat(+history, -choice, +state_in, -state_out) + hard_tit4tat([A,B|_],d,_,_):-(A=d;B=d),!. hard_tit4tat(_,c,_,_). diff --git a/rules/mistrust_tit4tat.pl b/rules/mistrust_tit4tat.pl index 5e80c02..3ebfce9 100644 --- a/rules/mistrust_tit4tat.pl +++ b/rules/mistrust_tit4tat.pl @@ -1,6 +1,8 @@ % Mistrust Tit for Tat: % In the first round it defects, than it plays opponent’s move. +% Syntax: mistrust_tit4tat(+history, -choice, +state_in, -state_out) + % Use opponents last decision mistrust_tit4tat([Last|_],Last,_,_). % Fallback to defect if history is empty. diff --git a/rules/naive_prober.pl b/rules/naive_prober.pl index df2bcf5..72debd3 100644 --- a/rules/naive_prober.pl +++ b/rules/naive_prober.pl @@ -2,6 +2,8 @@ % Like Tit for Tat, but sometimes, after the opponent has cooperated, it % defects (e.g. at random, in one of ten rounds in average). +% Syntax: naive_prober(+history, -choice, +state_in, -state_out) + 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/rules/pavlov.pl b/rules/pavlov.pl index 0da8011..5fe3702 100644 --- a/rules/pavlov.pl +++ b/rules/pavlov.pl @@ -1,6 +1,9 @@ % Pavlov: % Cooperates if and only if both players opted for the % same choice in the previous move, otherwise it defects. + +% Syntax: pavlov(+history, -choice, +state_in, -state_out) + pavlov([], c, _, c):-!. pavlov([Choice|_], c, Choice, c):-!. pavlov(_, d, _, d). diff --git a/rules/periodically_ddc.pl b/rules/periodically_ddc.pl index 897986d..e76f5ab 100644 --- a/rules/periodically_ddc.pl +++ b/rules/periodically_ddc.pl @@ -1,4 +1,7 @@ % Plays periodically: Defect–Defect–Coop. +% +% Syntax: periodically_ddc(+history, -choice, +state_in, -state_out) + periodically_ddc(_, d, [], [1]). periodically_ddc(_, d, [1], [2]). periodically_ddc(_, c, [2], []). diff --git a/rules/periodically_ssz.pl b/rules/periodically_ssz.pl index 21cb017..bfcb8d7 100644 --- a/rules/periodically_ssz.pl +++ b/rules/periodically_ssz.pl @@ -1,4 +1,7 @@ % Plays periodically: Coop-Coop-Defect + +% Syntax: periodically_ssz(+history, -choice, +state_in, -state_out) + periodically_ssz(_, c, [], [1]). periodically_ssz(_, c, [1], [2]). periodically_ssz(_, d, [2], []). diff --git a/rules/random_choice.pl b/rules/random_choice.pl index 3bd4a91..8075afb 100644 --- a/rules/random_choice.pl +++ b/rules/random_choice.pl @@ -1,2 +1,5 @@ + +% Syntax: random_choice(+history, -choice, +state_in, -state_out) + random_choice(_, Choice, _, _) :- random(Number), (Number < 0.5 -> Choice=c ; Choice=d). diff --git a/rules/tit42tat.pl b/rules/tit42tat.pl index 281bc4d..1e66062 100644 --- a/rules/tit42tat.pl +++ b/rules/tit42tat.pl @@ -1,5 +1,7 @@ % Select distraction only if opponents both last decision were to distract. % See: http://en.wikipedia.org/wiki/Tit_for_tat#Tit_for_two_tats +% Syntax: tit42tat(+history, -choice, +state_in, -state_out) + tit42tat([d,d|_],d,_,_):-!. tit42tat(_,c,_,_). diff --git a/rules/tit4tat.pl b/rules/tit4tat.pl index 2fe0a8f..cacbe16 100644 --- a/rules/tit4tat.pl +++ b/rules/tit4tat.pl @@ -3,6 +3,8 @@ % 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. |