meine Game Strategy

This commit is contained in:
Daniel Herrmann
2014-06-05 10:08:35 +02:00
parent a0eb217332
commit 0021f75b4d

47
src/GameStrategy.cs Normal file
View File

@@ -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;
}
}
}
}
}