diff options
author | Khaled Yakdan <yakdan@code-intelligence.com> | 2022-02-21 20:48:54 +0100 |
---|---|---|
committer | Fabian Meumertzheim <fabian@meumertzhe.im> | 2022-02-22 18:06:15 +0100 |
commit | 8c8e87b22645ba7681e72cef0caaf05bab492b75 (patch) | |
tree | ccdacb29ce5d4da7952fb31cfed5272dba9fb904 | |
parent | 197c593fe832995e36d410f845e895bb1da927d8 (diff) | |
download | jazzer-api-8c8e87b22645ba7681e72cef0caaf05bab492b75.tar.gz |
Make MazeFuzzer more challenging
-rw-r--r-- | examples/src/main/java/com/example/MazeFuzzer.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/examples/src/main/java/com/example/MazeFuzzer.java b/examples/src/main/java/com/example/MazeFuzzer.java index 8a3c590a..9d3448c7 100644 --- a/examples/src/main/java/com/example/MazeFuzzer.java +++ b/examples/src/main/java/com/example/MazeFuzzer.java @@ -61,9 +61,9 @@ public final class MazeFuzzer { // every new combination of x and y as a new feature. Without it, the fuzzer would be // completely lost in the maze as guessing an escaping path by chance is close to impossible. Jazzer.exploreState(hash(x, y), 0); - if (REACHED_FIELDS[x][y] == ' ') { + if (REACHED_FIELDS[y][x] == ' ') { // Fuzzer reached a new field in the maze, print its progress. - REACHED_FIELDS[x][y] = '.'; + REACHED_FIELDS[y][x] = '.'; System.out.println(renderMaze(REACHED_FIELDS)); } }); @@ -95,23 +95,25 @@ public final class MazeFuzzer { for (byte command : commands) { byte nextX = x; byte nextY = y; - switch (command % 4) { - case 0: + switch (command) { + case 'L': nextX--; break; - case 1: + case 'R': nextX++; break; - case 2: + case 'U': nextY--; break; - case 3: + case 'D': nextY++; break; + default: + return; } char nextFieldType; try { - nextFieldType = MAZE[nextX][nextY]; + nextFieldType = MAZE[nextY][nextX]; } catch (IndexOutOfBoundsException e) { // Fuzzer tried to walk through the exterior walls of the maze. continue; @@ -139,7 +141,7 @@ public final class MazeFuzzer { char[][] mutableMaze = parseMaze(); executeCommands(commands, (x, y, won) -> { if (!won) { - mutableMaze[x][y] = '.'; + mutableMaze[y][x] = '.'; } }); return renderMaze(mutableMaze); |