From 3bd5ff85d8bfe032502995ca03125b660cfe2aad Mon Sep 17 00:00:00 2001 From: Luca Conte Date: Wed, 11 Jun 2025 04:52:32 +0200 Subject: [PATCH] calculate distance per task and sector size when solving --- projekt/Solver.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/projekt/Solver.java b/projekt/Solver.java index 103308b..e030c55 100644 --- a/projekt/Solver.java +++ b/projekt/Solver.java @@ -40,10 +40,10 @@ final public class Solver extends JPanel { private AtomicBoolean[][] visitedAtomic; private Semaphore[] sectors; - private static final int SECTOR_SIZE = (int) Math.sqrt(DEFAULT_WIDTH_IN_CELLS * DEFAULT_HEIGHT_IN_CELLS) / 50; + private static int SECTOR_SIZE; // determined by trial and error - private static final int DISTANCE_PER_TASK = DEFAULT_WIDTH_IN_CELLS * DEFAULT_HEIGHT_IN_CELLS / 128; + private static int DISTANCE_PER_TASK; private Point[] solution = null; // set to solution path once that has been computed @@ -140,6 +140,10 @@ final public class Solver extends JPanel { } public Point[] solveConcurrently() { + + DISTANCE_PER_TASK = labyrinth.getWidth() * labyrinth.getHeight() / 128; + SECTOR_SIZE = (int) Math.sqrt(labyrinth.getWidth() * labyrinth.getHeight()) / 50; + // dummy origin direction for start PointAndDirection start = new PointAndDirection(labyrinth.getStart(), null);