GameStrategy allgemein angelegt
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace WorldOfPeacecraft
|
namespace WorldOfPeacecraft
|
||||||
{
|
{
|
||||||
class Skirmish
|
class Skirmish : IGame
|
||||||
{
|
{
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user