GameStrategy allgemein angelegt

This commit is contained in:
Daniel Herrmann
2014-06-05 11:38:33 +02:00
parent e53f2657aa
commit 5229f218da
3 changed files with 19 additions and 15 deletions

View File

@@ -5,38 +5,42 @@ using System.Text;
namespace WorldOfPeacecraft namespace WorldOfPeacecraft
{ {
class GameStrategy class GameStrategy : IGame
{ {
Decision cooperate;
Decision defect;
int counter = 0; int counter = 0;
public GameStrategy() public GameStrategy(Decision cooperate, Decision defect)
{ {
this.cooperate = cooperate;
this.defect = defect;
} }
public bool getFirstMove() public Decision getFirstMove()
{ {
return true; return cooperate;
} }
public bool nextMove(bool opCooperated) public Decision nextMove(Decision opLM)
{ {
if (opCooperated && counter==0) if (opLM == cooperate && counter == 0)
{ {
return true; return cooperate;
} }
else else
{ {
counter++; counter++;
if (counter < 10) if (counter < 10)
{ {
return false; return defect;
} }
else else
{ {
counter = 0; counter = 0;
return false; return defect;
} }
} }

View File

@@ -5,7 +5,7 @@ using System.Text;
namespace WorldOfPeacecraft namespace WorldOfPeacecraft
{ {
class Skirmish class Skirmish : IGame
{ {
Random random = new Random(); Random random = new Random();