summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pavlov.pl5
1 files changed, 5 insertions, 0 deletions
diff --git a/pavlov.pl b/pavlov.pl
new file mode 100644
index 0000000..4ca359f
--- /dev/null
+++ b/pavlov.pl
@@ -0,0 +1,5 @@
+% Cooperates if and only if both players opted for the
+% same choice in the previous move, otherwise it defects.
+pavlov([], c, _, c).
+pavlov([Choice|_], c, Choice, c):-!.
+pavlov([_], d, _, d).