From 0021f75b4d0f9297dd97fd494c152c1cb64507cf Mon Sep 17 00:00:00 2001 From: Daniel Herrmann Date: Thu, 5 Jun 2014 10:08:35 +0200 Subject: [PATCH] meine Game Strategy --- src/GameStrategy.cs | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/GameStrategy.cs diff --git a/src/GameStrategy.cs b/src/GameStrategy.cs new file mode 100644 index 0000000..842915d --- /dev/null +++ b/src/GameStrategy.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace inf3.src +{ + class GameStrategy + { + // 0 = defect, 1 = cooperate + + int opponentLastMove; + bool opDefected = false; + int counter = 0; + + public GameStrategy(int opLM) + { + opponentLastMove = opLM; + } + + public int nextMove() + { + if (opponentLastMove != 0) + { + return opponentLastMove; + } + else + { + opDefected = true; + counter++; + if (counter < 10) + { + return 0; + } + else + { + counter = 0; + opDefected = false; + return 0; + + } + } + } + + } + +}