summaryrefslogtreecommitdiff
path: root/rules/tit4tat.pl
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-08 13:17:20 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-08 13:17:20 +0100
commit553e4655f2227783051d5ea7fba65d9135310ad4 (patch)
treedf7ddbc67de4cef8c0eda917c76233ddc63d3feb /rules/tit4tat.pl
parentf22d7a9894d530fa2f8ceaeff3a8a52746ad7a1c (diff)
downloadwbs-553e4655f2227783051d5ea7fba65d9135310ad4.tar.gz
wbs-553e4655f2227783051d5ea7fba65d9135310ad4.tar.bz2
wbs-553e4655f2227783051d5ea7fba65d9135310ad4.zip
Prisoners Dilemma: Move rules to subdirectory
Diffstat (limited to 'rules/tit4tat.pl')
-rw-r--r--rules/tit4tat.pl11
1 files changed, 11 insertions, 0 deletions
diff --git a/rules/tit4tat.pl b/rules/tit4tat.pl
new file mode 100644
index 0000000..2cf520c
--- /dev/null
+++ b/rules/tit4tat.pl
@@ -0,0 +1,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: MODULE(UserDecisionHistry [in], ModuleDecision [out])
+
+% Use opponents last decision
+tit4tat([Last|_],Last,_,_).
+% Fallback to coorporate if history is empty.
+tit4tat([],c,_,_).