GameStrategy allgemein angelegt
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace WorldOfPeacecraft
|
||||
{
|
||||
public enum Decision
|
||||
{
|
||||
FIGHT, REST, STAG, BUNNY, SWORD, ALCHEMY, MAGIC
|
||||
}
|
||||
public enum Decision
|
||||
{
|
||||
FIGHT, REST, STAG, BUNNY, SWORD, ALCHEMY, MAGIC
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,38 +5,42 @@ using System.Text;
|
||||
|
||||
namespace WorldOfPeacecraft
|
||||
{
|
||||
class GameStrategy
|
||||
class GameStrategy : IGame
|
||||
{
|
||||
|
||||
|
||||
Decision cooperate;
|
||||
Decision defect;
|
||||
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
|
||||
{
|
||||
counter++;
|
||||
if (counter < 10)
|
||||
{
|
||||
return false;
|
||||
return defect;
|
||||
}
|
||||
else
|
||||
{
|
||||
counter = 0;
|
||||
return false;
|
||||
return defect;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace WorldOfPeacecraft
|
||||
{
|
||||
class Skirmish
|
||||
class Skirmish : IGame
|
||||
{
|
||||
Random random = new Random();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user