Merge branch 'master' into 'maurizio-branch'
# Conflicts: # src/game/Game.java # src/game/Main.java
This commit is contained in:
commit
f6062f8530
4
Makefile
4
Makefile
|
@ -17,8 +17,8 @@ src/game/GameHistory.java \
|
||||||
src/game/GameEntry.java \
|
src/game/GameEntry.java \
|
||||||
src/game/PlayerObject.java \
|
src/game/PlayerObject.java \
|
||||||
src/player/Player.java \
|
src/player/Player.java \
|
||||||
src/player/Player1.java \
|
src/player/MalteAI.java \
|
||||||
src/player/Player2.java
|
src/player/MaurizioAI.java
|
||||||
|
|
||||||
OBJECTS=$($(subst $(CLASSPATH),$(BUILDS),$(CLASSES)):.java=.class)
|
OBJECTS=$($(subst $(CLASSPATH),$(BUILDS),$(CLASSES)):.java=.class)
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,14 @@
|
||||||
package game;
|
package game;
|
||||||
|
|
||||||
import player.Player;
|
import player.Player;
|
||||||
import player.Player1;
|
import player.MaurizioAI;
|
||||||
import player.Player2;
|
import player.MalteAI;
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Player p1 = new Player1("Malte");
|
Player p1 = new MalteAI("Malte");
|
||||||
Player p2 = new Player2("Maurizio");
|
Player p2 = new MaurizioAI("Maurizio");
|
||||||
|
new Game(p1, p2).start();
|
||||||
// Analysis of how often the starting player wins, when both player make completely
|
|
||||||
// random moves.
|
|
||||||
Game game = new Game(p1, p2);
|
|
||||||
int count1 = 0; // number of times Player1 aka Malte wins
|
|
||||||
int count2 = 0; // number of times Player2 aka Mauri wins
|
|
||||||
Scanner scan = new Scanner(System.in);
|
|
||||||
System.out.print("Bitte geben sie die Anzahl der Partien ein: ");
|
|
||||||
int rounds = scan.nextInt();
|
|
||||||
for(int i=1;i<=rounds;i++){
|
|
||||||
int res = game.start(false, false);
|
|
||||||
if(res == 1){
|
|
||||||
count1++;
|
|
||||||
}
|
|
||||||
if(res == 2){
|
|
||||||
count2++;
|
|
||||||
}
|
|
||||||
game.reset();
|
|
||||||
}
|
|
||||||
System.out.println(rounds + " rounds with " + count1 + " wins for Player1 " +
|
|
||||||
count2 + " wins for Player2 and " + (rounds-count1-count2) + " draws");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@ package player;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class Player1 implements Player {
|
public class MalteAI implements Player{
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private Random ran;
|
private Random ran;
|
||||||
|
|
||||||
public Player1(String name){
|
public MalteAI(String name){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.ran = new Random();
|
this.ran = new Random();
|
||||||
}
|
}
|
|
@ -2,12 +2,12 @@ package player;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class Player2 implements Player{
|
public class MaurizioAI implements Player {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private Random ran;
|
private Random ran;
|
||||||
|
|
||||||
public Player2(String name){
|
public MaurizioAI(String name){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.ran = new Random();
|
this.ran = new Random();
|
||||||
}
|
}
|
Loading…
Reference in a new issue