meine Game Strategy
This commit is contained in:
47
src/GameStrategy.cs
Normal file
47
src/GameStrategy.cs
Normal 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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user