summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/util/SimulationGenerator.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze/util/SimulationGenerator.java')
-rw-r--r--src/ch/epfl/maze/util/SimulationGenerator.java128
1 files changed, 128 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/util/SimulationGenerator.java b/src/ch/epfl/maze/util/SimulationGenerator.java
new file mode 100644
index 0000000..6d7bbcb
--- /dev/null
+++ b/src/ch/epfl/maze/util/SimulationGenerator.java
@@ -0,0 +1,128 @@
1package ch.epfl.maze.util;
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.*;
7import ch.epfl.maze.simulation.DaedalusSimulation;
8import ch.epfl.maze.simulation.MazeSimulation;
9import ch.epfl.maze.simulation.Simulation;
10
11/**
12 * Generates a set of pre-computed labyrinth structures
13 *
14 * @author EPFL
15 * @author Pacien TRAN-GIRARD
16 */
17public final class SimulationGenerator {
18
19 /**
20 * Returns the simulation with the given name.
21 *
22 * @param name The name
23 * @return The Simulation
24 */
25 public static Simulation getSimulation(String name) {
26 switch (name) {
27 case "maze":
28 return SimulationGenerator.getMazeSimulation();
29 case "daedalus":
30 return SimulationGenerator.getDaedalusSimulation();
31 case "multi-daedalus":
32 return SimulationGenerator.getMultiPreyDaedalusSimulation();
33 default:
34 return null;
35 }
36 }
37
38 /**
39 * Creates a {@code MazeSimulation} with every animal implementations.
40 *
41 * @return A {@code MazeSimulation} to display
42 */
43 public static Simulation getMazeSimulation() {
44 int[][] labyrinth = LabyrinthGenerator.getMedium();
45 Maze m = new Maze(labyrinth);
46 Simulation simulation = new MazeSimulation(m);
47
48 // adds a Mouse
49 m.addAnimal(new Mouse(m.getStart()));
50
51 // adds a Monkey
52 m.addAnimal(new Monkey(m.getStart()));
53
54 // adds a Hamster
55 m.addAnimal(new Hamster(m.getStart()));
56
57 // adds a Bear (if this bonus is coded)
58 m.addAnimal(new Bear(m.getStart()));
59
60 // adds a Panda
61 m.addAnimal(new Panda(m.getStart()));
62
63 return simulation;
64 }
65
66 /**
67 * Creates a {@code DaedalusSimulation} suitable for statistics.
68 * <p>
69 * Note that there should be only <b>ONE</b> animal of each kind in the
70 * corresponding {@code Daedalus}.
71 *
72 * @return A {@code DaedalusSimulation} suitable for statistics
73 */
74 public static Simulation getDaedalusSimulation() {
75 int[][] labyrinth = LabyrinthGenerator.getPacMan();
76 Daedalus d = new Daedalus(labyrinth);
77 Simulation simulation = new DaedalusSimulation(d);
78
79 // adds Pac-Man
80 d.addPrey(new PacMan(new Vector2D(9, 15)));
81
82 // adds Blinky
83 d.addPredator(new Blinky(new Vector2D(17, 1)));
84
85 // adds Pinky
86 d.addPredator(new Pinky(new Vector2D(1, 1)));
87
88 // adds Inky
89 d.addPredator(new Inky(new Vector2D(17, 17)));
90
91 // adds Clyde
92 d.addPredator(new Clyde(new Vector2D(1, 17)));
93
94 return simulation;
95 }
96
97 /**
98 * Creates a {@code DaedalusSimulation} with every ghost implementation and
99 * 3 Pac-Mans.
100 *
101 * @return A {@code DaedalusSimulation} to display
102 */
103 public static Simulation getMultiPreyDaedalusSimulation() {
104 int[][] labyrinth = LabyrinthGenerator.getPacMan();
105 Daedalus d = new Daedalus(labyrinth);
106 Simulation simulation = new DaedalusSimulation(d);
107
108 // adds Pac-Mans
109 d.addPrey(new PacMan(new Vector2D(9, 15)));
110 d.addPrey(new PacMan(new Vector2D(10, 15)));
111 d.addPrey(new PacMan(new Vector2D(8, 15)));
112
113 // adds Blinky
114 d.addPredator(new Blinky(new Vector2D(17, 1)));
115
116 // adds Pinky
117 d.addPredator(new Pinky(new Vector2D(1, 1)));
118
119 // adds Inky
120 d.addPredator(new Inky(new Vector2D(17, 17)));
121
122 // adds Clyde
123 d.addPredator(new Clyde(new Vector2D(1, 17)));
124
125 return simulation;
126 }
127
128}