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