Finished implementation of multi-mode
This commit is contained in:
parent
5df378e315
commit
56e4de5695
5
Makefile
5
Makefile
|
@ -28,6 +28,8 @@ BUILDFILES=$(OBJECTS) $(FXMLS_BUILD)
|
||||||
|
|
||||||
MAIN=game.Main
|
MAIN=game.Main
|
||||||
|
|
||||||
|
N=100
|
||||||
|
|
||||||
|
|
||||||
all: $(CLASSES) $(FXMLS_BUILD)
|
all: $(CLASSES) $(FXMLS_BUILD)
|
||||||
$(JAVAC) $(JAVAC_OPTIONS) -cp $(CLASSPATH):$(LIBARIES) $(CLASSES) -d $(BUILDS)
|
$(JAVAC) $(JAVAC_OPTIONS) -cp $(CLASSPATH):$(LIBARIES) $(CLASSES) -d $(BUILDS)
|
||||||
|
@ -35,6 +37,9 @@ all: $(CLASSES) $(FXMLS_BUILD)
|
||||||
run: $(CLASSES)
|
run: $(CLASSES)
|
||||||
$(JAVA) -cp $(BUILDS):$(LIBARIES) $(MAIN)
|
$(JAVA) -cp $(BUILDS):$(LIBARIES) $(MAIN)
|
||||||
|
|
||||||
|
simulate: $(CLASSES)
|
||||||
|
$(JAVA) -cp $(BUILDS):$(LIBARIES) $(MAIN) $(N)
|
||||||
|
|
||||||
doc: $(CLASSES)
|
doc: $(CLASSES)
|
||||||
$(JAVADOC) $(JAVADOC_OPTIONS) -cp $(CLASSPATH):$(LIBARIES) $(CLASSES) -d $(DOC)
|
$(JAVADOC) $(JAVADOC_OPTIONS) -cp $(CLASSPATH):$(LIBARIES) $(CLASSES) -d $(DOC)
|
||||||
|
|
||||||
|
|
|
@ -88,14 +88,18 @@ public class Game {
|
||||||
// TODO: Improve IDs
|
// TODO: Improve IDs
|
||||||
statistic[result]++;
|
statistic[result]++;
|
||||||
}
|
}
|
||||||
|
double[] percents = new double[3];
|
||||||
|
for (int i = 0; i < statistic.length; i++) {
|
||||||
|
percents[i] = ((double)statistic[i]) / runs * 100.0;
|
||||||
|
}
|
||||||
System.out.println("Draws : " + statistic[0]);
|
System.out.println("Draws : " + statistic[0]);
|
||||||
System.out.println(p1.getName() + ": " + statistic[1] + " wins");
|
System.out.println(p1.getName() + ": " + statistic[1] + " wins");
|
||||||
System.out.println(p2.getName() + ": " + statistic[2] + " wins");
|
System.out.println(p2.getName() + ": " + statistic[2] + " wins");
|
||||||
|
|
||||||
System.out.println("PERCENTAGE:");
|
System.out.println("PERCENTAGE:");
|
||||||
System.out.println("Draws : " + (statistic[0] / runs * 100.0) + "%");
|
System.out.println("Draws : " + percents[0] + "%");
|
||||||
System.out.println(p1.getName() + ": " + (statistic[1] / runs * 100.0) + "% wins");
|
System.out.println(p1.getName() + ": " + percents[1] + "% wins");
|
||||||
System.out.println(p2.getName() + ": " + (statistic[2] / runs * 100.0) + "% wins");
|
System.out.println(p2.getName() + ": " + percents[2] + "% wins");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,12 @@ import player.malte.MalteAI;
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Player p1 = new MalteAI("Malte");
|
if (args.length == 1) {
|
||||||
Player p2 = new MaurizioAI("Maurizio");
|
Game.simulate(Integer.parseInt(args[0]));
|
||||||
new Game(p1, p2).start(true, true); //1. param = output mode, 2. param = random beginner
|
} else {
|
||||||
|
Player p1 = new MalteAI("Malte");
|
||||||
|
Player p2 = new MaurizioAI("Maurizio");
|
||||||
|
new Game(p1, p2).start(true, true); //1. param = output mode, 2. param = random beginner
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue