summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/World.java
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-24 11:11:17 +0100
committerPacien TRAN-GIRARD2015-11-24 11:11:17 +0100
commitbc477506342411e9156b3230d847cb92bcb8e5f9 (patch)
treed952a5d14dccef38bfba3f8e27bfe10ea65d446a /src/ch/epfl/maze/physical/World.java
parent903553fe9e03e4af75eb7f8547e08b480bc58ec4 (diff)
downloadmaze-solver-bc477506342411e9156b3230d847cb92bcb8e5f9.tar.gz
Reformat code
Diffstat (limited to 'src/ch/epfl/maze/physical/World.java')
-rw-r--r--src/ch/epfl/maze/physical/World.java16
1 files changed, 1 insertions, 15 deletions
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
16public abstract class World { 15public 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 * Resets the world as when it was instantiated.
73 */ 68 */
74
75 abstract public void reset(); 69 abstract public void reset();
76 70
77 /** 71 /**
@@ -79,7 +73,6 @@ public abstract class World {
79 * 73 *
80 * @return A list of all animals in the world 74 * @return A list of all animals in the world
81 */ 75 */
82
83 abstract public List<Animal> getAnimals(); 76 abstract public List<Animal> getAnimals();
84 77
85 /** 78 /**
@@ -90,7 +83,6 @@ public abstract class World {
90 * @return The tile number at position (x, y), or the NOTHING tile if x or y is 83 * @return The tile number at position (x, y), or the NOTHING tile if x or y is
91 * incorrect. 84 * incorrect.
92 */ 85 */
93
94 public final int getTile(int x, int y) { 86 public final int getTile(int x, int y) {
95 if (x < 0 || x >= this.getWidth()) return World.NOTHING; 87 if (x < 0 || x >= this.getWidth()) return World.NOTHING;
96 if (y < 0 || y >= this.getHeight()) return World.NOTHING; 88 if (y < 0 || y >= this.getHeight()) return World.NOTHING;
@@ -104,7 +96,6 @@ public abstract class World {
104 * @param y Vertical coordinate 96 * @param y Vertical coordinate
105 * @return <b>true</b> if an animal can walk on tile, <b>false</b> otherwise 97 * @return <b>true</b> if an animal can walk on tile, <b>false</b> otherwise
106 */ 98 */
107
108 public final boolean isFree(int x, int y) { 99 public final boolean isFree(int x, int y) {
109 int tile = this.getTile(x, y); 100 int tile = this.getTile(x, y);
110 return !(tile == World.WALL || tile == World.NOTHING); 101 return !(tile == World.WALL || tile == World.NOTHING);
@@ -116,7 +107,6 @@ public abstract class World {
116 * @param position The position vector 107 * @param position The position vector
117 * @return <b>true</b> if an animal can walk on tile, <b>false</b> otherwise 108 * @return <b>true</b> if an animal can walk on tile, <b>false</b> otherwise
118 */ 109 */
119
120 public final boolean isFree(Vector2D position) { 110 public final boolean isFree(Vector2D position) {
121 return this.isFree(position.getX(), position.getY()); 111 return this.isFree(position.getX(), position.getY());
122 } 112 }
@@ -129,7 +119,6 @@ public abstract class World {
129 * @param position A position in the maze 119 * @param position A position in the maze
130 * @return An array of all available choices at a position 120 * @return An array of all available choices at a position
131 */ 121 */
132
133 public final Direction[] getChoices(Vector2D position) { 122 public final Direction[] getChoices(Vector2D position) {
134 List<Direction> choices = new ArrayList<>(); 123 List<Direction> choices = new ArrayList<>();
135 for (Direction dir : Direction.POSSIBLE_DIRECTIONS) 124 for (Direction dir : Direction.POSSIBLE_DIRECTIONS)
@@ -144,7 +133,6 @@ public abstract class World {
144 * 133 *
145 * @return The horizontal length of the labyrinth 134 * @return The horizontal length of the labyrinth
146 */ 135 */
147
148 public final int getWidth() { 136 public final int getWidth() {
149 return this.labyrinth[0].length; 137 return this.labyrinth[0].length;
150 } 138 }
@@ -154,7 +142,6 @@ public abstract class World {
154 * 142 *
155 * @return The vertical length of the labyrinth 143 * @return The vertical length of the labyrinth
156 */ 144 */
157
158 public final int getHeight() { 145 public final int getHeight() {
159 return this.labyrinth.length; 146 return this.labyrinth.length;
160 } 147 }
@@ -165,7 +152,6 @@ public abstract class World {
165 * 152 *
166 * @return Start position of the labyrinth, null if none. 153 * @return Start position of the labyrinth, null if none.
167 */ 154 */
168
169 public final Vector2D getStart() { 155 public final Vector2D getStart() {
170 return this.start; 156 return this.start;
171 } 157 }
@@ -175,8 +161,8 @@ public abstract class World {
175 * 161 *
176 * @return Exit position of the labyrinth, null if none. 162 * @return Exit position of the labyrinth, null if none.
177 */ 163 */
178
179 public final Vector2D getExit() { 164 public final Vector2D getExit() {
180 return this.exit; 165 return this.exit;
181 } 166 }
167
182} 168}