summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/main/Console.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze/main/Console.java')
-rw-r--r--src/ch/epfl/maze/main/Console.java81
1 files changed, 4 insertions, 77 deletions
diff --git a/src/ch/epfl/maze/main/Console.java b/src/ch/epfl/maze/main/Console.java
index 0c273e1..ebe1e3e 100644
--- a/src/ch/epfl/maze/main/Console.java
+++ b/src/ch/epfl/maze/main/Console.java
@@ -1,18 +1,8 @@
1package ch.epfl.maze.main; 1package ch.epfl.maze.main;
2 2
3import ch.epfl.maze.physical.Daedalus;
4import ch.epfl.maze.physical.Maze;
5import ch.epfl.maze.physical.pacman.*;
6import ch.epfl.maze.physical.zoo.Hamster;
7import ch.epfl.maze.physical.zoo.Monkey;
8import ch.epfl.maze.physical.zoo.Mouse;
9import ch.epfl.maze.physical.zoo.Panda;
10import ch.epfl.maze.simulation.DaedalusSimulation;
11import ch.epfl.maze.simulation.MazeSimulation;
12import ch.epfl.maze.simulation.Simulation; 3import ch.epfl.maze.simulation.Simulation;
13import ch.epfl.maze.util.LabyrinthGenerator; 4import ch.epfl.maze.util.SimulationGenerator;
14import ch.epfl.maze.util.Statistics; 5import ch.epfl.maze.util.Statistics;
15import ch.epfl.maze.util.Vector2D;
16 6
17import java.util.Collections; 7import java.util.Collections;
18import java.util.List; 8import java.util.List;
@@ -30,12 +20,11 @@ public class Console {
30 * Number of simulations launched. 20 * Number of simulations launched.
31 */ 21 */
32 public static final int NUMBER_OF_SIMULATIONS = 1000; 22 public static final int NUMBER_OF_SIMULATIONS = 1000;
23 public static final String DEFAULT_SIM = "maze";
33 24
34 public static void main(String[] args) { 25 public static void main(String[] args) {
35 Simulation simulation; 26 String simName = args.length > 0 ? args[0] : DEFAULT_SIM;
36 27 Simulation simulation = SimulationGenerator.getSimulation(simName);
37 simulation = getMazeSimulation();
38 //simulation = getDaedalusSimulation();
39 28
40 System.out.print("Launching " + NUMBER_OF_SIMULATIONS + " simulations..."); 29 System.out.print("Launching " + NUMBER_OF_SIMULATIONS + " simulations...");
41 Map<String, List<Integer>> results = 30 Map<String, List<Integer>> results =
@@ -46,68 +35,6 @@ public class Console {
46 } 35 }
47 36
48 /** 37 /**
49 * Creates a {@code MazeSimulation} suitable for statistics.
50 * <p>
51 * Note that there should be only <b>ONE</b> animal of each kind in the
52 * corresponding {@code Maze}.
53 *
54 * @return A {@code MazeSimulation} suitable for statistics
55 */
56 public static Simulation getMazeSimulation() {
57 int[][] labyrinth = LabyrinthGenerator.getMedium();
58 Maze m = new Maze(labyrinth);
59 Simulation simulation = new MazeSimulation(m);
60
61 // adds a Mouse
62 m.addAnimal(new Mouse(m.getStart()));
63
64 // adds a Monkey
65 m.addAnimal(new Monkey(m.getStart()));
66
67 // adds a Hamster
68 m.addAnimal(new Hamster(m.getStart()));
69
70 // adds a Bear (if this bonus is coded)
71 // m.addAnimal(new Bear(m.getStart()));
72
73 // adds a Panda
74 m.addAnimal(new Panda(m.getStart()));
75
76 return simulation;
77 }
78
79 /**
80 * Creates a {@code DaedalusSimulation} suitable for statistics.
81 * <p>
82 * Note that there should be only <b>ONE</b> animal of each kind in the
83 * corresponding {@code Daedalus}.
84 *
85 * @return A {@code DaedalusSimulation} suitable for statistics
86 */
87 public static Simulation getDaedalusSimulation() {
88 int[][] labyrinth = LabyrinthGenerator.getPacMan();
89 Daedalus d = new Daedalus(labyrinth);
90 Simulation simulation = new DaedalusSimulation(d);
91
92 // adds Pac-Man
93 d.addPrey(new PacMan(new Vector2D(9, 15)));
94
95 // adds Blinky
96 d.addPredator(new Blinky(new Vector2D(17, 1)));
97
98 // adds Pinky
99 d.addPredator(new Pinky(new Vector2D(1, 1)));
100
101 // adds Inky
102 d.addPredator(new Inky(new Vector2D(17, 17)));
103
104 // adds Clyde
105 d.addPredator(new Clyde(new Vector2D(1, 17)));
106
107 return simulation;
108 }
109
110 /**
111 * Pretty-prints the statistics computed in the parameters. 38 * Pretty-prints the statistics computed in the parameters.
112 * 39 *
113 * @param results Statistics of arrival times for every animals/preys 40 * @param results Statistics of arrival times for every animals/preys