diff options
Diffstat (limited to 'src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java')
| -rw-r--r-- | src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java b/src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java deleted file mode 100644 index 71e23a0..0000000 --- a/src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * - */ -package de.fhswf.in.inf.java1.aufgabe7; - -/** - * Calculates the the success rate of different players. - * - * @author $Author: $ - * @version $Revision: $, $Date: $ UTC - */ -public final class Simulation -{ - - private static final int VERSUCHE = 100000; - - /** - * Prevents instantiation of the utility class. - * - */ - private Simulation() - { - } - - /** - * Makes anzahl games. - * - * @param anzahl - * How often the game will be run. - * @return Victory count - */ - private static int nDurchlaufeAusfuehren(Spiel spiel, Spieler spieler, - int anzahl) - { - - int erfolge = 0; - for (int i = 0; i < anzahl; i++) - { - if (spiel.spielDurchlauf(spieler)) - { - erfolge++; - } - } - - return erfolge; - } - - /** - * Calculates the success rate of every player. - * - * @param erfolg - * An array with the last game stats. - */ - private static double wahrscheinlichkeitErrechnen(int erfolge, int versuche) - { - return (double) erfolge / versuche; - } - - /** - * Main method of the package. - * - * @param args - * Command line arguments - */ - public static void main(String[] args) - { - - Spieler[] spieler = {new GleichSpieler(), new WechselSpieler(), - new ZufallsSpieler(0.5)}; - - Spiel spiel = new Spiel(); - - for (int i = 0; i < spieler.length; i++) - { - int spielerGewinne = nDurchlaufeAusfuehren(spiel, spieler[i], - VERSUCHE); - double spielerProb = wahrscheinlichkeitErrechnen(spielerGewinne, - VERSUCHE); - System.out.printf("%17s war %05.2f%s erfolgreich\n", spieler[i] - .getClass().getSimpleName(), spielerProb * 100, "%"); - } - } - -} |
