diff options
author | Pacien TRAN-GIRARD | 2015-11-26 10:28:22 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-11-26 10:28:22 +0100 |
commit | 093fd685341c334be63ec950e44aa3a1edc82915 (patch) | |
tree | 5f8b1083833ded4efa90ccf3323c48f18df1db81 /src/ch/epfl/maze/main/Program.java | |
parent | 1e2eff1e9829f8ffa694f3258433c91c804ab473 (diff) | |
download | maze-solver-093fd685341c334be63ec950e44aa3a1edc82915.tar.gz |
Refactor main programs
Diffstat (limited to 'src/ch/epfl/maze/main/Program.java')
-rw-r--r-- | src/ch/epfl/maze/main/Program.java | 83 |
1 files changed, 7 insertions, 76 deletions
diff --git a/src/ch/epfl/maze/main/Program.java b/src/ch/epfl/maze/main/Program.java index 347eace..4692d2a 100644 --- a/src/ch/epfl/maze/main/Program.java +++ b/src/ch/epfl/maze/main/Program.java | |||
@@ -1,18 +1,8 @@ | |||
1 | package ch.epfl.maze.main; | 1 | package ch.epfl.maze.main; |
2 | 2 | ||
3 | import ch.epfl.maze.graphics.Display; | 3 | import ch.epfl.maze.graphics.Display; |
4 | import ch.epfl.maze.physical.Daedalus; | ||
5 | import ch.epfl.maze.physical.Maze; | ||
6 | import ch.epfl.maze.physical.pacman.*; | ||
7 | import ch.epfl.maze.physical.zoo.Hamster; | ||
8 | import ch.epfl.maze.physical.zoo.Monkey; | ||
9 | import ch.epfl.maze.physical.zoo.Mouse; | ||
10 | import ch.epfl.maze.physical.zoo.Panda; | ||
11 | import ch.epfl.maze.simulation.DaedalusSimulation; | ||
12 | import ch.epfl.maze.simulation.MazeSimulation; | ||
13 | import ch.epfl.maze.simulation.Simulation; | 4 | import ch.epfl.maze.simulation.Simulation; |
14 | import ch.epfl.maze.util.LabyrinthGenerator; | 5 | import ch.epfl.maze.util.SimulationGenerator; |
15 | import ch.epfl.maze.util.Vector2D; | ||
16 | 6 | ||
17 | /** | 7 | /** |
18 | * Mini-project main program that will run the simulations on a {@code Display}. | 8 | * Mini-project main program that will run the simulations on a {@code Display}. |
@@ -21,79 +11,20 @@ import ch.epfl.maze.util.Vector2D; | |||
21 | */ | 11 | */ |
22 | public class Program { | 12 | public class Program { |
23 | 13 | ||
14 | public static final String DEFAULT_SIM = "maze"; | ||
15 | |||
24 | /** | 16 | /** |
25 | * Runs one of the two available simulations | 17 | * Runs one of the two available simulations |
26 | * | 18 | * |
27 | * @see #getMazeSimulation() | 19 | * @see ch.epfl.maze.util.SimulationGenerator#getMazeSimulation() |
28 | * @see #getDaedalusSimulation() | 20 | * @see ch.epfl.maze.util.SimulationGenerator#getMultiPreyDaedalusSimulation() |
29 | */ | 21 | */ |
30 | public static void main(String[] args) { | 22 | public static void main(String[] args) { |
31 | Simulation simulation; | 23 | String simName = args.length > 0 ? args[0] : DEFAULT_SIM; |
32 | 24 | Simulation simulation = SimulationGenerator.getSimulation(simName); | |
33 | simulation = getMazeSimulation(); | ||
34 | //simulation = getDaedalusSimulation(); | ||
35 | 25 | ||
36 | Display display = new Display(simulation); | 26 | Display display = new Display(simulation); |
37 | display.run(); | 27 | display.run(); |
38 | } | 28 | } |
39 | 29 | ||
40 | /** | ||
41 | * Creates a {@code MazeSimulation} with every animal implementations. | ||
42 | * | ||
43 | * @return A {@code MazeSimulation} to display | ||
44 | */ | ||
45 | public static Simulation getMazeSimulation() { | ||
46 | int[][] labyrinth = LabyrinthGenerator.getMedium(); | ||
47 | Maze m = new Maze(labyrinth); | ||
48 | Simulation simulation = new MazeSimulation(m); | ||
49 | |||
50 | // adds a Mouse | ||
51 | m.addAnimal(new Mouse(m.getStart())); | ||
52 | |||
53 | // adds a Monkey | ||
54 | m.addAnimal(new Monkey(m.getStart())); | ||
55 | |||
56 | // adds a Hamster | ||
57 | m.addAnimal(new Hamster(m.getStart())); | ||
58 | |||
59 | // adds a Bear (if this bonus is coded) | ||
60 | //m.addAnimal(new Bear(m.getStart())); | ||
61 | |||
62 | // adds a Panda | ||
63 | m.addAnimal(new Panda(m.getStart())); | ||
64 | |||
65 | return simulation; | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * Creates a {@code DaedalusSimulation} with every ghost implementation and | ||
70 | * 3 Pac-Mans. | ||
71 | * | ||
72 | * @return A {@code DaedalusSimulation} to display | ||
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-Mans | ||
80 | d.addPrey(new PacMan(new Vector2D(9, 15))); | ||
81 | d.addPrey(new PacMan(new Vector2D(10, 15))); | ||
82 | d.addPrey(new PacMan(new Vector2D(8, 15))); | ||
83 | |||
84 | // adds Blinky | ||
85 | d.addPredator(new Blinky(new Vector2D(17, 1))); | ||
86 | |||
87 | // adds Pinky | ||
88 | d.addPredator(new Pinky(new Vector2D(1, 1))); | ||
89 | |||
90 | // adds Inky | ||
91 | d.addPredator(new Inky(new Vector2D(17, 17))); | ||
92 | |||
93 | // adds Clyde | ||
94 | d.addPredator(new Clyde(new Vector2D(1, 17))); | ||
95 | |||
96 | return simulation; | ||
97 | } | ||
98 | |||
99 | } | 30 | } |