diff options
author | pacien | 2018-01-14 19:07:12 +0100 |
---|---|---|
committer | pacien | 2018-01-14 19:07:12 +0100 |
commit | c50045ae937aa9284d7051ec5d0fe74b79a3e626 (patch) | |
tree | 47862507adbd0333e9840fafc0a9b9c88e515152 | |
parent | 1d07ffaa79712e22159ce4adb38a1c902915980e (diff) | |
download | wallj-c50045ae937aa9284d7051ec5d0fe74b79a3e626.tar.gz |
Make garbage blocks non-traversable
Signed-off-by: pacien <pacien.trangirard@pacien.net>
-rw-r--r-- | src/docs/user.md | 18 | ||||
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/board/BoardValidator.java | 3 | ||||
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/model/BlockType.java | 2 | ||||
-rw-r--r-- | src/test/resources/maps/bigValid.txt | 2 |
4 files changed, 13 insertions, 12 deletions
diff --git a/src/docs/user.md b/src/docs/user.md index 735daf5..cba47eb 100644 --- a/src/docs/user.md +++ b/src/docs/user.md | |||
@@ -69,8 +69,8 @@ Entity type Appearance Pushable by bomb Traversable by robot | |||
69 | ----------- ------------ ---------------- -------------------- | 69 | ----------- ------------ ---------------- -------------------- |
70 | Wall Black square No No | 70 | Wall Black square No No |
71 | Trash can Red square No No | 71 | Trash can Red square No No |
72 | Bomb Black disk No No | ||
72 | Free Empty No Yes | 73 | Free Empty No Yes |
73 | Bomb Black disk No Yes | ||
74 | Garbage Brown disk Yes Yes | 74 | Garbage Brown disk Yes Yes |
75 | Robot Blue disk / / | 75 | Robot Blue disk / / |
76 | 76 | ||
@@ -105,8 +105,8 @@ Wall W Yes No | |||
105 | A world is defined as valid if its blocks fulfill the following criteria: | 105 | A world is defined as valid if its blocks fulfill the following criteria: |
106 | 106 | ||
107 | * The bounding box of the defined world must be made of bounding blocks. | 107 | * The bounding box of the defined world must be made of bounding blocks. |
108 | * The interior space formed by bounding blocks must be unique and simple. | 108 | * The interior space formed by traversable blocks must be unique and simple. |
109 | * Reachable blocks are either adjacent or belong to the interior space. | 109 | * Reachable blocks are either adjacent or belonging to the interior space. |
110 | * The world must contain at least one trash can and one garbage block. | 110 | * The world must contain at least one trash can and one garbage block. |
111 | * The world must have enough free tiles to contain all droppable bombs. | 111 | * The world must have enough free tiles to contain all droppable bombs. |
112 | 112 | ||
@@ -118,11 +118,11 @@ The validity of a world may not guaranty the solvability of the puzzle. | |||
118 | 118 | ||
119 | __Example of invalid world definition:__ | 119 | __Example of invalid world definition:__ |
120 | ``` | 120 | ``` |
121 | WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW | 121 | WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW W |
122 | W W W | 122 | W W W WWW W |
123 | W W W T | 123 | W W W WTW W |
124 | WWWWWWWWWW W | 124 | WWWWWWWWWW W WWW W |
125 | W W W | 125 | W W W W |
126 | W W WWWWWWWWWWW | 126 | W W WWWWWWWWWWW |
127 | WWWWWWWWWW W | 127 | WWWWWWWWWW W |
128 | W W W | 128 | W W W |
@@ -137,7 +137,7 @@ W WWWWWWWWWWW | |||
137 | W WWWWWWWWWWW | 137 | W WWWWWWWWWWW |
138 | T WWWWWWWWWW WWWWWWWWWWW | 138 | T WWWWWWWWWW WWWWWWWWWWW |
139 | T WWWWWWWWWW GGGGGGGGGGGGG WWWWWWWWWWW | 139 | T WWWWWWWWWW GGGGGGGGGGGGG WWWWWWWWWWW |
140 | T WWWWWWWWWW GGGGGGGG G WWWWWWWWWWW | 140 | T WWWWWWWWWW GGGGGGGG WWWWWWWWWWW |
141 | T WWWWWWWWWW GGGGGGGGGGGGG W | 141 | T WWWWWWWWWW GGGGGGGGGGGGG W |
142 | W W W | 142 | W W W |
143 | W W W | 143 | W W W |
diff --git a/src/main/java/fr/umlv/java/wallj/board/BoardValidator.java b/src/main/java/fr/umlv/java/wallj/board/BoardValidator.java index e238955..e95446b 100644 --- a/src/main/java/fr/umlv/java/wallj/board/BoardValidator.java +++ b/src/main/java/fr/umlv/java/wallj/board/BoardValidator.java | |||
@@ -91,7 +91,8 @@ public class BoardValidator { | |||
91 | .filter(blockEntry -> blockEntry.getValue().mustBeReachable()) | 91 | .filter(blockEntry -> blockEntry.getValue().mustBeReachable()) |
92 | .allMatch(blockEntry -> blockEntry.getKey().neighbors().stream() | 92 | .allMatch(blockEntry -> blockEntry.getKey().neighbors().stream() |
93 | .filter(neighbor -> inBoard(dim, neighbor)) | 93 | .filter(neighbor -> inBoard(dim, neighbor)) |
94 | .anyMatch(neighbor -> b.getBlockTypeAt(neighbor).isTraversable())); | 94 | .anyMatch(neighbor -> b.getBlockTypeAt(neighbor).isTraversable() || |
95 | b.getBlockTypeAt(neighbor).isMovableByExplosion())); | ||
95 | } | 96 | } |
96 | 97 | ||
97 | /** | 98 | /** |
diff --git a/src/main/java/fr/umlv/java/wallj/model/BlockType.java b/src/main/java/fr/umlv/java/wallj/model/BlockType.java index 9051715..9c5d4f5 100644 --- a/src/main/java/fr/umlv/java/wallj/model/BlockType.java +++ b/src/main/java/fr/umlv/java/wallj/model/BlockType.java | |||
@@ -10,7 +10,7 @@ public enum BlockType { | |||
10 | FREE(false, true, true, false), | 10 | FREE(false, true, true, false), |
11 | WALL(true, false, false, false), | 11 | WALL(true, false, false, false), |
12 | TRASH(true, true, false, false), | 12 | TRASH(true, true, false, false), |
13 | GARBAGE(false, true, true, true), | 13 | GARBAGE(false, true, false, true), |
14 | ROBOT(false, false, true, false), | 14 | ROBOT(false, false, true, false), |
15 | BOMB(false, false, true, false); | 15 | BOMB(false, false, true, false); |
16 | 16 | ||
diff --git a/src/test/resources/maps/bigValid.txt b/src/test/resources/maps/bigValid.txt index 45bcacf..80c83fc 100644 --- a/src/test/resources/maps/bigValid.txt +++ b/src/test/resources/maps/bigValid.txt | |||
@@ -3,7 +3,7 @@ W WWWWWWWWWWW | |||
3 | W WWWWWWWWWWW | 3 | W WWWWWWWWWWW |
4 | T WWWWWWWWWW WWWWWWWWWWW | 4 | T WWWWWWWWWW WWWWWWWWWWW |
5 | T WWWWWWWWWW GGGGGGGGGGGGG WWWWWWWWWWW | 5 | T WWWWWWWWWW GGGGGGGGGGGGG WWWWWWWWWWW |
6 | T WWWWWWWWWW GGGGGGGG G WWWWWWWWWWW | 6 | T WWWWWWWWWW GGGGGGGG WWWWWWWWWWW |
7 | T WWWWWWWWWW GGGGGGGGGGGGG W | 7 | T WWWWWWWWWW GGGGGGGGGGGGG W |
8 | W W W | 8 | W W W |
9 | W W W | 9 | W W W |