diff options
author | Pacien TRAN-GIRARD | 2015-11-24 11:11:17 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-11-24 11:11:17 +0100 |
commit | bc477506342411e9156b3230d847cb92bcb8e5f9 (patch) | |
tree | d952a5d14dccef38bfba3f8e27bfe10ea65d446a /src/ch/epfl/maze/physical | |
parent | 903553fe9e03e4af75eb7f8547e08b480bc58ec4 (diff) | |
download | maze-solver-bc477506342411e9156b3230d847cb92bcb8e5f9.tar.gz |
Reformat code
Diffstat (limited to 'src/ch/epfl/maze/physical')
-rw-r--r-- | src/ch/epfl/maze/physical/Animal.java | 7 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/GhostPredator.java | 4 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/Maze.java | 6 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/World.java | 16 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/pacman/Pinky.java | 3 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/Hamster.java | 5 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/Monkey.java | 5 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/Panda.java | 2 | ||||
-rw-r--r-- | src/ch/epfl/maze/physical/zoo/SpaceInvader.java | 4 |
9 files changed, 10 insertions, 42 deletions
diff --git a/src/ch/epfl/maze/physical/Animal.java b/src/ch/epfl/maze/physical/Animal.java index 9123d82..0079d11 100644 --- a/src/ch/epfl/maze/physical/Animal.java +++ b/src/ch/epfl/maze/physical/Animal.java | |||
@@ -9,7 +9,6 @@ import ch.epfl.maze.util.Vector2D; | |||
9 | * | 9 | * |
10 | * @author Pacien TRAN-GIRARD | 10 | * @author Pacien TRAN-GIRARD |
11 | */ | 11 | */ |
12 | |||
13 | abstract public class Animal { | 12 | abstract public class Animal { |
14 | 13 | ||
15 | private Vector2D position; | 14 | private Vector2D position; |
@@ -19,7 +18,6 @@ abstract public class Animal { | |||
19 | * | 18 | * |
20 | * @param position Position of the animal in the labyrinth | 19 | * @param position Position of the animal in the labyrinth |
21 | */ | 20 | */ |
22 | |||
23 | public Animal(Vector2D position) { | 21 | public Animal(Vector2D position) { |
24 | this.position = position; | 22 | this.position = position; |
25 | } | 23 | } |
@@ -33,7 +31,6 @@ abstract public class Animal { | |||
33 | * World.getChoices(Vector2D)}) | 31 | * World.getChoices(Vector2D)}) |
34 | * @return The next direction of the animal, chosen in {@code choices} | 32 | * @return The next direction of the animal, chosen in {@code choices} |
35 | */ | 33 | */ |
36 | |||
37 | abstract public Direction move(Direction[] choices); | 34 | abstract public Direction move(Direction[] choices); |
38 | 35 | ||
39 | /** | 36 | /** |
@@ -44,7 +41,6 @@ abstract public class Animal { | |||
44 | * | 41 | * |
45 | * @param dir Direction that the animal has taken | 42 | * @param dir Direction that the animal has taken |
46 | */ | 43 | */ |
47 | |||
48 | public final void update(Direction dir) { | 44 | public final void update(Direction dir) { |
49 | this.position = this.position.addDirectionTo(dir); | 45 | this.position = this.position.addDirectionTo(dir); |
50 | } | 46 | } |
@@ -57,7 +53,6 @@ abstract public class Animal { | |||
57 | * | 53 | * |
58 | * @param position | 54 | * @param position |
59 | */ | 55 | */ |
60 | |||
61 | public final void setPosition(Vector2D position) { | 56 | public final void setPosition(Vector2D position) { |
62 | this.position = position; | 57 | this.position = position; |
63 | } | 58 | } |
@@ -67,10 +62,10 @@ abstract public class Animal { | |||
67 | * | 62 | * |
68 | * @return Current position of animal. | 63 | * @return Current position of animal. |
69 | */ | 64 | */ |
70 | |||
71 | public final Vector2D getPosition() { | 65 | public final Vector2D getPosition() { |
72 | return this.position; | 66 | return this.position; |
73 | } | 67 | } |
74 | 68 | ||
75 | abstract public Animal copy(); | 69 | abstract public Animal copy(); |
70 | |||
76 | } | 71 | } |
diff --git a/src/ch/epfl/maze/physical/GhostPredator.java b/src/ch/epfl/maze/physical/GhostPredator.java index 8188c00..5408bf6 100644 --- a/src/ch/epfl/maze/physical/GhostPredator.java +++ b/src/ch/epfl/maze/physical/GhostPredator.java | |||
@@ -122,7 +122,7 @@ abstract public class GhostPredator extends Predator { | |||
122 | /** | 122 | /** |
123 | * Calculates the Euclidean distance from the adjacent position at the given Direction to the target position. | 123 | * Calculates the Euclidean distance from the adjacent position at the given Direction to the target position. |
124 | * | 124 | * |
125 | * @param dir The adjacent Direction | 125 | * @param dir The adjacent Direction |
126 | * @param targetPosition The targeted position | 126 | * @param targetPosition The targeted position |
127 | * @return The Euclidean distance between the two positions | 127 | * @return The Euclidean distance between the two positions |
128 | */ | 128 | */ |
@@ -138,7 +138,7 @@ abstract public class GhostPredator extends Predator { | |||
138 | * Selects the best Direction in the given choices by minimizing the Euclidean distance to the targeted position. | 138 | * Selects the best Direction in the given choices by minimizing the Euclidean distance to the targeted position. |
139 | * | 139 | * |
140 | * @param targetPosition The targeted position | 140 | * @param targetPosition The targeted position |
141 | * @param choices An array of Direction choices | 141 | * @param choices An array of Direction choices |
142 | * @return An array of optimal Direction choices | 142 | * @return An array of optimal Direction choices |
143 | */ | 143 | */ |
144 | private Direction[] selectBestPaths(Vector2D targetPosition, Direction[] choices) { | 144 | private Direction[] selectBestPaths(Vector2D targetPosition, Direction[] choices) { |
diff --git a/src/ch/epfl/maze/physical/Maze.java b/src/ch/epfl/maze/physical/Maze.java index bff8791..51b9811 100644 --- a/src/ch/epfl/maze/physical/Maze.java +++ b/src/ch/epfl/maze/physical/Maze.java | |||
@@ -10,7 +10,6 @@ import java.util.List; | |||
10 | * | 10 | * |
11 | * @author Pacien TRAN-GIRARD | 11 | * @author Pacien TRAN-GIRARD |
12 | */ | 12 | */ |
13 | |||
14 | public final class Maze extends World { | 13 | public final class Maze extends World { |
15 | 14 | ||
16 | private final List<Animal> animals; | 15 | private final List<Animal> animals; |
@@ -21,7 +20,6 @@ public final class Maze extends World { | |||
21 | * | 20 | * |
22 | * @param labyrinth Structure of the labyrinth, an NxM array of tiles | 21 | * @param labyrinth Structure of the labyrinth, an NxM array of tiles |
23 | */ | 22 | */ |
24 | |||
25 | public Maze(int[][] labyrinth) { | 23 | public Maze(int[][] labyrinth) { |
26 | super(labyrinth); | 24 | super(labyrinth); |
27 | 25 | ||
@@ -46,7 +44,6 @@ public final class Maze extends World { | |||
46 | * @return <b>true</b> if the animal belongs to the world, <b>false</b> | 44 | * @return <b>true</b> if the animal belongs to the world, <b>false</b> |
47 | * otherwise. | 45 | * otherwise. |
48 | */ | 46 | */ |
49 | |||
50 | public boolean hasAnimal(Animal a) { | 47 | public boolean hasAnimal(Animal a) { |
51 | return this.animals.contains(a); | 48 | return this.animals.contains(a); |
52 | } | 49 | } |
@@ -56,7 +53,6 @@ public final class Maze extends World { | |||
56 | * | 53 | * |
57 | * @param a The animal to add | 54 | * @param a The animal to add |
58 | */ | 55 | */ |
59 | |||
60 | public void addAnimal(Animal a) { | 56 | public void addAnimal(Animal a) { |
61 | a.setPosition(this.getStart()); | 57 | a.setPosition(this.getStart()); |
62 | this.animals.add(a); | 58 | this.animals.add(a); |
@@ -67,7 +63,6 @@ public final class Maze extends World { | |||
67 | * | 63 | * |
68 | * @param a The animal to remove | 64 | * @param a The animal to remove |
69 | */ | 65 | */ |
70 | |||
71 | public void removeAnimal(Animal a) { | 66 | public void removeAnimal(Animal a) { |
72 | boolean contained = this.animals.remove(a); | 67 | boolean contained = this.animals.remove(a); |
73 | if (contained) this.animalHistory.add(a); | 68 | if (contained) this.animalHistory.add(a); |
@@ -80,4 +75,5 @@ public final class Maze extends World { | |||
80 | this.animalHistory.forEach(a -> this.addAnimal(a.copy())); | 75 | this.animalHistory.forEach(a -> this.addAnimal(a.copy())); |
81 | this.animalHistory.clear(); | 76 | this.animalHistory.clear(); |
82 | } | 77 | } |
78 | |||
83 | } | 79 | } |
diff --git a/src/ch/epfl/maze/physical/World.java b/src/ch/epfl/maze/physical/World.java index f13b2b1..9afbd5e 100644 --- a/src/ch/epfl/maze/physical/World.java +++ b/src/ch/epfl/maze/physical/World.java | |||
@@ -12,7 +12,6 @@ import java.util.List; | |||
12 | * | 12 | * |
13 | * @author Pacien TRAN-GIRARD | 13 | * @author Pacien TRAN-GIRARD |
14 | */ | 14 | */ |
15 | |||
16 | public abstract class World { | 15 | public abstract class World { |
17 | 16 | ||
18 | /* tiles constants */ | 17 | /* tiles constants */ |
@@ -25,7 +24,6 @@ public abstract class World { | |||
25 | /** | 24 | /** |
26 | * Structure of the labyrinth, an NxM array of tiles | 25 | * Structure of the labyrinth, an NxM array of tiles |
27 | */ | 26 | */ |
28 | |||
29 | private final int[][] labyrinth; | 27 | private final int[][] labyrinth; |
30 | 28 | ||
31 | private final Vector2D start; | 29 | private final Vector2D start; |
@@ -36,7 +34,6 @@ public abstract class World { | |||
36 | * | 34 | * |
37 | * @param labyrinth Structure of the labyrinth, an NxM array of tiles | 35 | * @param labyrinth Structure of the labyrinth, an NxM array of tiles |
38 | */ | 36 | */ |
39 | |||
40 | public World(int[][] labyrinth) { | 37 | public World(int[][] labyrinth) { |
41 | this.labyrinth = labyrinth; | 38 | this.labyrinth = labyrinth; |
42 | 39 | ||
@@ -50,7 +47,6 @@ public abstract class World { | |||
50 | * @param tileType Type of the tile | 47 | * @param tileType Type of the tile |
51 | * @return A Vector2D of the first occurrence of the given tile type | 48 | * @return A Vector2D of the first occurrence of the given tile type |
52 | */ | 49 | */ |
53 | |||
54 | private Vector2D findFirstTileOfType(int tileType) { | 50 | private Vector2D findFirstTileOfType(int tileType) { |
55 | for (int x = 0; x < this.getWidth(); ++x) | 51 | for (int x = 0; x < this.getWidth(); ++x) |
56 | for (int y = 0; y < this.getHeight(); ++y) | 52 | for (int y = 0; y < this.getHeight(); ++y) |
@@ -65,13 +61,11 @@ public abstract class World { | |||
65 | * | 61 | * |
66 | * @return <b>true</b> if no more moves can be made, <b>false</b> otherwise | 62 | * @return <b>true</b> if no more moves can be made, <b>false</b> otherwise |
67 | */ | 63 | */ |
68 | |||
69 | abstract public boolean isSolved(); | 64 | abstract public boolean isSolved(); |
70 | 65 | ||
71 | /** | 66 | /** |
72 | * Resets the world as when it was instantiated. | 67 | * Re |