diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..91063aa21119ce3a01ff083d564fc9ebcd1fa1e9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_15" default="true" project-jdk-name="15" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/out" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..484d39196d06f8451ce895e1e95d20e6daa81586 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/paralleleprogrammierung.iml" filepath="$PROJECT_DIR$/.idea/paralleleprogrammierung.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/.idea/paralleleprogrammierung.iml b/.idea/paralleleprogrammierung.iml new file mode 100644 index 0000000000000000000000000000000000000000..5ea232f730a454bf2dbf5e31735c5b02b13047a1 --- /dev/null +++ b/.idea/paralleleprogrammierung.iml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/Semester/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000000000000000000000000000000000000..e96534fb27b68192f27f985d3879e173ec77adb8 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Palette2"> + <group name="Swing"> + <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> + </item> + <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> + </item> + <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"> + <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> + <initial-values> + <property name="text" value="Button" /> + </initial-values> + </item> + <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="RadioButton" /> + </initial-values> + </item> + <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="CheckBox" /> + </initial-values> + </item> + <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="Label" /> + </initial-values> + </item> + <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> + <preferred-size width="200" height="200" /> + </default-constraints> + </item> + <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> + <preferred-size width="200" height="200" /> + </default-constraints> + </item> + <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> + </item> + <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> + <preferred-size width="-1" height="20" /> + </default-constraints> + </item> + <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> + </item> + <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> + </item> + </group> + </component> +</project> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/src/algorithm/Explorer.java b/src/algorithm/Explorer.java index 720407b0177267a732005c67d0315673a697d54b..eee1875fbad8ed67b658105157ea4fc37abda92c 100644 --- a/src/algorithm/Explorer.java +++ b/src/algorithm/Explorer.java @@ -20,6 +20,11 @@ public class Explorer { private Direction direction; + + public int getSteps() { + return steps; + } + public Explorer(int x, int y, int steps, Direction direction) { this.x = x; this.y = y; @@ -28,18 +33,21 @@ public class Explorer { } public void explore() { - + int index = x + y * SharedRessources.getInstance().getWidth(); int currentStepsOnField = - (int) SharedRessources.getInstance().getVisitMatrix()[x + y * SharedRessources.getInstance().getWidth()] + (int) SharedRessources.getInstance().getVisitMatrix()[index] .getZ(); - if(currentStepsOnField < steps) + if (currentStepsOnField <= steps + SharedRessources.getInstance().getEpsilon()) { return; + } + + boolean wall = - SharedRessources.getInstance().getWallMatrix()[x + y * SharedRessources.getInstance().getWidth()]; + SharedRessources.getInstance().getWallMatrix()[index]; if (wall) return; @@ -49,22 +57,22 @@ public class Explorer { switch (direction) { case North: - if (steps < currentStepsOnField) { - SharedRessources - .getInstance().getVisitMatrix()[x + y * SharedRessources.getInstance().getWidth()] - = new Vec3(0, +1, steps); - } + + SharedRessources + .getInstance().getVisitMatrix()[index] + = new Vec3(0, +1, steps); + recursiveNext = new Explorer(x, y - 1, steps++, direction); addLeftRight(); break; case East: - if (steps < currentStepsOnField) { - SharedRessources - .getInstance().getVisitMatrix()[x + y * SharedRessources.getInstance().getWidth()] - = new Vec3(-1, 0, steps); - } + + SharedRessources + .getInstance().getVisitMatrix()[index] + = new Vec3(-1, 0, steps); + recursiveNext = new Explorer(x + 1, y, steps++, direction); @@ -72,22 +80,22 @@ public class Explorer { break; case South: - if (steps < currentStepsOnField) { - SharedRessources - .getInstance().getVisitMatrix()[x + y * SharedRessources.getInstance().getWidth()] - = new Vec3(0, -1, steps); - } + + SharedRessources + .getInstance().getVisitMatrix()[index] + = new Vec3(0, -1, steps); + recursiveNext = new Explorer(x, y + 1, steps++, direction); addLeftRight(); break; case West: - if (steps < currentStepsOnField) { - SharedRessources - .getInstance().getVisitMatrix()[x + y * SharedRessources.getInstance().getWidth()] - = new Vec3(+1, 0, steps); - } + + SharedRessources + .getInstance().getVisitMatrix()[index] + = new Vec3(+1, 0, steps); + recursiveNext = new Explorer(x - 1, y, steps++, direction); addUpDown(); diff --git a/src/algorithm/ParallelPathfinder.java b/src/algorithm/ParallelPathfinder.java index d0b20c7a409fd8f0c5b5746926e451bcdc9631cf..e98b076a64264d44d6178771ee0d6790fd88834d 100644 --- a/src/algorithm/ParallelPathfinder.java +++ b/src/algorithm/ParallelPathfinder.java @@ -18,7 +18,16 @@ public class ParallelPathfinder { SharedRessources .getInstance().add(new Explorer(destX, destY + 1, 1, Explorer.Direction.South)); - while (!SharedRessources.getInstance().done()); + + synchronized (SharedRessources.getInstance().getSignalingObject()) { + while (!SharedRessources.getInstance().done()) { + try { + SharedRessources.getInstance().getSignalingObject().wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } } public ArrayList<Point> calculatePath(int startX, int startY, int destX, int destY) { @@ -41,7 +50,7 @@ public class ParallelPathfinder { int dx = (int) currentDir.getX(); int dy = (int) currentDir.getY(); - if(dx == 0 && dy == 0) + if (dx == 0 && dy == 0) return null; x += dx; @@ -57,26 +66,10 @@ public class ParallelPathfinder { for (int i = 0; i < SharedRessources.getInstance().getWidth(); i++) { boolean b = SharedRessources.getInstance().getWallMatrix()[i + j * SharedRessources.getInstance().getWidth()]; - if (b) + if (b) { g.setColor(Color.blue); - else { - Vec3 currentVec - = - SharedRessources.getInstance().getVisitMatrix()[i + j * SharedRessources.getInstance().getWidth()]; - if (currentVec.getX() == 0 && currentVec.getY() == 0) - g.setColor(Color.black); - else { - int green = (int)currentVec.getZ(); - - Color color - = new Color(0, green, 0); - - g.setColor(color); - - } + g.fillRect(i * 1, j * 1, 1, 1); } - - g.fillRect(i * 10, j * 10, 10, 10); } } } diff --git a/src/algorithm/WorkingExplorers.java b/src/algorithm/WorkingExplorers.java index 4307730e9b3e1bf693c25d7bfc44b9951973644a..3c9d2eb567551d289c0dcd2df199236669ce98e8 100644 --- a/src/algorithm/WorkingExplorers.java +++ b/src/algorithm/WorkingExplorers.java @@ -3,23 +3,21 @@ package algorithm; import parallel.EagerWorkingThread; import parallel.SharedRessources; -import java.util.ArrayList; -import java.util.PriorityQueue; -import java.util.Queue; -import java.util.Stack; +import java.util.*; +import java.util.concurrent.ConcurrentLinkedDeque; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.LinkedBlockingQueue; public class WorkingExplorers extends EagerWorkingThread { public WorkingExplorers() { super(); - this.setAllowRunning(true); - + this.startListen(); System.out.println("[*] Thread initialized @" + this.getName()); } - private Stack<Explorer> currentWaitingExplorers = new Stack<>(); + private ConcurrentLinkedQueue<Explorer> currentWaitingExplorers = new ConcurrentLinkedQueue<Explorer>(); @Override public void onBegin() { @@ -28,15 +26,20 @@ public class WorkingExplorers extends EagerWorkingThread { @Override public void onTrigger() { if (!currentWaitingExplorers.isEmpty()) - currentWaitingExplorers.pop().explore(); + currentWaitingExplorers + .poll() + .explore(); } @Override public void onEnd() { + synchronized (SharedRessources.getInstance().getSignalingObject()){ + SharedRessources.getInstance().getSignalingObject().notifyAll(); + } } - public void add(Explorer explorer) throws InterruptedException { - this.currentWaitingExplorers.push(explorer); + public void add(Explorer explorer) { + this.currentWaitingExplorers.offer(explorer); this.trigger(); } diff --git a/src/parallel/EagerWorkingThread.java b/src/parallel/EagerWorkingThread.java index 696512811a58d7b626bf69e9cb9171f29d85aea7..cb1bba64b97f0f82c0a04b414edcea1cf72b9982 100644 --- a/src/parallel/EagerWorkingThread.java +++ b/src/parallel/EagerWorkingThread.java @@ -1,27 +1,22 @@ package parallel; public abstract class EagerWorkingThread extends Thread { - private static volatile boolean RUN_THREADS = true; - - public static void stopAllThreads() { - RUN_THREADS = false; - } private volatile int triggerCount; private volatile boolean isTriggered; - private volatile boolean allowRunning; + private volatile boolean listen; - public void setAllowRunning(boolean allowRunning) { - this.allowRunning = allowRunning; + public void startListen() { + listen = true; } - public boolean isAllowedRunning() { - return allowRunning; + public void stopListen() { + listen = false; } @Override public void run() { - while (RUN_THREADS && allowRunning) { + while (listen) { synchronized (this) { while (!isTriggered) { try { @@ -31,28 +26,27 @@ public abstract class EagerWorkingThread extends Thread { } } } - onBegin(); for (int i = 0; i < triggerCount; i++) onTrigger(); onEnd(); - triggerCount = 0; isTriggered = false; - } } - public synchronized boolean trigger() { + public boolean trigger() { triggerCount++; isTriggered = true; - this.notifyAll(); + synchronized (this) { + this.notify(); + } return true; } - public synchronized boolean isReady(){ + public boolean isReady() { return this.triggerCount == 0; } diff --git a/src/parallel/MapLoader.java b/src/parallel/MapLoader.java index 52d1aee846f68b02db5d80164d72f1a1aa859121..d0721bae7f44421934b8faba899ba279372888bf 100644 --- a/src/parallel/MapLoader.java +++ b/src/parallel/MapLoader.java @@ -33,7 +33,7 @@ public class MapLoader { SharedRessources.getInstance().setWallMatrix(new boolean[width * height]); for (int i = 0; i < SharedRessources.getInstance().getVisitMatrix().length; i++) - SharedRessources.getInstance().getVisitMatrix()[i] = new Vec3(0, 0, 10000); + SharedRessources.getInstance().getVisitMatrix()[i] = new Vec3(0, 0, Integer.MAX_VALUE); // https://stackoverflow.com/a/9470843/14727115 diff --git a/src/parallel/SharedRessources.java b/src/parallel/SharedRessources.java index a2616e8888569ebbf50ba65cb33a8166cc40f9c5..40c8f5636d1b618f4daf54abfa18bfc8cd3baa04 100644 --- a/src/parallel/SharedRessources.java +++ b/src/parallel/SharedRessources.java @@ -4,6 +4,8 @@ import algorithm.Explorer; import algorithm.WorkingExplorers; import structs.Vec3; +import java.util.Stack; + public class SharedRessources { private static int USING_CORES; @@ -12,33 +14,63 @@ public class SharedRessources { * @param cores */ public static void setMaximumCores(int cores) { + if (cores >= Runtime.getRuntime().availableProcessors()) + cores = Runtime.getRuntime().availableProcessors(); USING_CORES = cores; } private static SharedRessources sharedRessources; - public static synchronized SharedRessources getInstance() { + public static SharedRessources getInstance() { if (sharedRessources == null) sharedRessources = new SharedRessources(USING_CORES); return sharedRessources; } + private SharedRessources(int cores) { + maxCores = cores; + System.out.println("[*] Using " + maxCores + " cores."); + + signalingObject = new Object(); + + workingThreads = new WorkingExplorers[maxCores]; + for (int i = 0; i < maxCores; i++) { + workingThreads[i] = new WorkingExplorers(); + workingThreads[i].start(); + } + + currentCore = 0; + } + + private int width; + private int height; + + private boolean[] wallMatrix; + private Vec3[] visitMatrix; + private int maxCores; private int currentCore; private WorkingExplorers[] workingThreads; - public void start() { - for (int i = 0; i < maxCores; i++) - this.workingThreads[i].start(); + private Object signalingObject; + + private int epsilon; + + public void setEpsilon(int epsilon) { + this.epsilon = epsilon; + } + + public int getEpsilon() { + return epsilon; + } + + public Object getSignalingObject() { + return signalingObject; } public void add(Explorer explorer) { - try { - this.workingThreads[(currentCore++) % maxCores].add(explorer); - } catch (InterruptedException e) { - e.printStackTrace(); - } + this.workingThreads[(currentCore++) % maxCores].add(explorer); } public boolean done() { @@ -48,27 +80,6 @@ public class SharedRessources { return true; } - private SharedRessources(int cores) { - if (cores >= Runtime.getRuntime().availableProcessors()) - maxCores = Runtime.getRuntime().availableProcessors(); - else maxCores = cores; - - System.out.println("[*] Using " + maxCores + " cores."); - - workingThreads = new WorkingExplorers[maxCores]; - for (int i = 0; i < maxCores; i++) - workingThreads[i] = new WorkingExplorers(); - - start(); - currentCore = 0; - } - - private int width; - private int height; - - private boolean[] wallMatrix; - private Vec3[] visitMatrix; - public Vec3[] getVisitMatrix() { return visitMatrix; } diff --git a/src/window/Game.java b/src/window/Game.java index 297efd2959eb655be42b65debed2343dff6eb8cc..6a328a32aaf765fe0b7bf5485e35ca48449c1e42 100644 --- a/src/window/Game.java +++ b/src/window/Game.java @@ -12,13 +12,13 @@ public abstract class Game extends JFrame { private boolean running; - protected boolean[] keys; + private boolean[] pressedKeyMap; public Game(String title, int w, int h) { super(title); this.setSize(w, h); - keys = new boolean[1024]; + pressedKeyMap = new boolean[1024]; this.windowThread = new Thread(() -> { loadGame(); @@ -46,14 +46,14 @@ public abstract class Game extends JFrame { public void keyPressed(KeyEvent e) { super.keyPressed(e); - keys[e.getKeyCode()] = true; + pressedKeyMap[e.getKeyCode()] = true; } @Override public void keyReleased(KeyEvent e) { super.keyReleased(e); - keys[e.getKeyCode()] = false; + pressedKeyMap[e.getKeyCode()] = false; } }); @@ -62,6 +62,14 @@ public abstract class Game extends JFrame { } + public boolean isKeyDown(int key) { + return pressedKeyMap[key]; + } + + public boolean isKeyUp(int key) { + return !isKeyDown(key); + } + public final void run() { this.setVisible(true); this.running = true; diff --git a/src/window/MainWindow.java b/src/window/MainWindow.java index 5ff08b527e87f4dc05f53c770bbf3afc37f66913..eb666b05072496a0ba749d4b5f06696160a8b80e 100644 --- a/src/window/MainWindow.java +++ b/src/window/MainWindow.java @@ -23,8 +23,9 @@ public class MainWindow extends Game { @Override public void loadGame() { SharedRessources.setMaximumCores(Integer.MAX_VALUE); + SharedRessources.getInstance().setEpsilon(0); try { - MapLoader.getDefault().load(ImageIO.read(new File("c:/users/enesh/desktop/tests/debug.png"))); + MapLoader.getDefault().load(ImageIO.read(new File("c:/users/enesh/desktop/tests/maze2.png"))); } catch (IOException e) { e.printStackTrace(); } @@ -36,8 +37,8 @@ public class MainWindow extends Game { @Override public void updateGame() { - if (keys[KeyEvent.VK_ENTER]) - pts = parallelPathfinder.calculatePath(10, 114, 33, 30); + if (isKeyDown(KeyEvent.VK_ENTER)) + pts = parallelPathfinder.calculatePath(8, 5, 1590, 800); } @@ -55,7 +56,7 @@ public class MainWindow extends Game { g.setColor(Color.red); for (var pt : pts) { - g.fillRect(pt.x * 10, pt.y * 10, 10, 10); + g.fillRect(pt.x * 1, pt.y * 1, 1, 1); } }