From 54b9dee6afaa475a7ed17935f07754a58b14ea3d Mon Sep 17 00:00:00 2001 From: zentox Date: Mon, 28 Aug 2023 14:34:36 +0200 Subject: [PATCH 1/3] Remove duplicate code --- src/main/java/h06/ui/MazeVisualizer.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/h06/ui/MazeVisualizer.java b/src/main/java/h06/ui/MazeVisualizer.java index 7807f57..d70f20a 100644 --- a/src/main/java/h06/ui/MazeVisualizer.java +++ b/src/main/java/h06/ui/MazeVisualizer.java @@ -60,8 +60,6 @@ public void run(ProblemSolver solver, Point s, Point e, DirectionVector d) { fopbot.World.getGlobalWorld().setFieldColor(s.x, s.y, Color.BLUE); fopbot.World.getGlobalWorld().setFieldColor(e.x, e.y, Color.YELLOW); - fopbot.World.getGlobalWorld().setFieldColor(s.x, s.y, Color.BLUE); - fopbot.World.getGlobalWorld().setFieldColor(s.x, s.y, Color.YELLOW); for (int i = 1; i < path.length; i++) { Point p = path[i]; int x = robot.getX(); From 24e6222f6f81785c6f47e6fe9960eb44c86725e2 Mon Sep 17 00:00:00 2001 From: zentox Date: Mon, 28 Aug 2023 14:35:03 +0200 Subject: [PATCH 2/3] Remove unrelated comments to task --- src/main/java/h06/world/World.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/h06/world/World.java b/src/main/java/h06/world/World.java index 49da027..ae8f537 100644 --- a/src/main/java/h06/world/World.java +++ b/src/main/java/h06/world/World.java @@ -135,8 +135,6 @@ public boolean isBlocked(Point p, DirectionVector d) { int x; int y; boolean horizontal; - // 1 point for vertical - // 1 point for special case if (p.x > r.x) { // Right, vertical check x = r.x; From 43007bd234f3d04c2b4ebe3d35914adc672bffe5 Mon Sep 17 00:00:00 2001 From: zentox Date: Mon, 28 Aug 2023 14:35:19 +0200 Subject: [PATCH 3/3] Add example solution for ungraded task --- src/main/java/h06/Main.java | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/main/java/h06/Main.java b/src/main/java/h06/Main.java index bcb69d7..c3e92eb 100644 --- a/src/main/java/h06/Main.java +++ b/src/main/java/h06/Main.java @@ -1,5 +1,14 @@ package h06; +import h06.problems.MazeSolverRecursive; +import h06.problems.ProblemSolver; +import h06.ui.MazeVisualizer; +import h06.ui.ProblemVisualizer; +import h06.world.DirectionVector; +import h06.world.World; + +import java.awt.Point; + /** * Main entry point in executing the program. */ @@ -12,5 +21,33 @@ public class Main { */ public static void main(String[] args) { System.out.println("Hello World!"); + + World world = new World(5, 5); + world.placeWall(0, 0, false); + world.placeWall(0, 1, false); + world.placeWall(0, 2, false); + world.placeWall(0, 3, false); + world.placeWall(1, 1, true); + world.placeWall(2, 1, true); + world.placeWall(3, 1, true); + world.placeWall(3, 1, false); + world.placeWall(2, 0, true); + world.placeWall(2, 0, false); + world.placeWall(1, 4, false); + world.placeWall(1, 3, false); + world.placeWall(2, 2, true); + world.placeWall(3, 3, true); + world.placeWall(3, 3, false); + world.placeWall(4, 2, true); + + + ProblemVisualizer visualizer = new MazeVisualizer(); + ProblemSolver solver = new MazeSolverRecursive(); + Point start = new Point(2, 0); + Point end = new Point(2, 4); + DirectionVector direction = DirectionVector.UP; + visualizer.init(world); + visualizer.show(); + visualizer.run(solver, start, end, direction); } }