-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
68 lines (43 loc) · 2.16 KB
/
Copy pathMain.java
File metadata and controls
68 lines (43 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main;
import GameTheory.Strategies.*;
import GameTheory.Tournament;
import java.io.IOException;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Strategy PAPER = new AlwaysPaper();
Strategy ROCK = new AlwaysRock();
Strategy SCISSORS = new AlwaysScissors();
// Create TitForTat strategy
Strategy titForTat = new TitForTat();
// Create TitForTatTat startefy
Strategy titForTatTat = new TitForTatTat();
// Create Grudger strategy
Strategy grudger = new Grudger();
// Create Simpleton startefy
Strategy simpleton = new Simpleton();
// Create a list of all strategies
List<Strategy> allStrategies = new ArrayList<>(Arrays.asList(
ROCK, PAPER, SCISSORS,
titForTat, titForTatTat,
grudger, simpleton
));
// Create a Tournament for all strategies
Tournament tournament = new Tournament(allStrategies);
// Specify the number of rounds for each iteration
int numRounds = 10;
// Run the tournament for all strategies
System.out.println("Results:");
for (int iteration = 0; iteration < 5; iteration++) {
// Execute the tournament rounds
HashMap<Strategy, Integer> results = tournament.executeTournamentRounds(numRounds);
System.out.println("Iteration " + iteration + " Results:");
for (Map.Entry<Strategy, Integer> entry : results.entrySet()) {
System.out.println(entry.getKey().getStrategyName() + ": " + entry.getValue() + " points");
System.out.println(" Player 1 score is :" + entry.getKey().getPlayer1Score());
System.out.println(" Player 2 score is :" + entry.getKey().getPlayer2Score());
}
System.out.println("-----------------------------------------------------------------------------------");
}
}
}