Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ExampleStrategies;
- import java.util.Random;
- import PrisonersDilemma.Choice;
- import PrisonersDilemma.PrisonersStrategy;
- public class SpecialByApcnc implements PrisonersStrategy{
- @Override
- public Choice turn(Choice[] myChoices, Choice[] otherChoices, Random rand) {
- int u = 0;
- for(int i = 0;i<otherChoices.length;i++){
- if(otherChoices[i]==Choice.betray)
- u++;
- }
- if(u>0){
- if(otherChoices.length/u>2){
- System.out.println("cooperate");
- return Choice.cooperate;
- }
- else{
- System.out.println("betray");
- return Choice.betray;
- }
- }
- else{
- System.out.println("cooperate");
- return Choice.cooperate;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement