calculate distance per task and sector size when solving
This commit is contained in:
parent
3cd69b92c8
commit
3bd5ff85d8
|
@ -40,10 +40,10 @@ final public class Solver extends JPanel {
|
||||||
private AtomicBoolean[][] visitedAtomic;
|
private AtomicBoolean[][] visitedAtomic;
|
||||||
|
|
||||||
private Semaphore[] sectors;
|
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
|
// 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
|
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() {
|
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
|
// dummy origin direction for start
|
||||||
PointAndDirection start = new PointAndDirection(labyrinth.getStart(), null);
|
PointAndDirection start = new PointAndDirection(labyrinth.getStart(), null);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue