preparation for a*search

master
Peter Babič 9 years ago
parent 13c09a8995
commit 76a9a7085e
  1. 0
      .metadata/.lock
  2. BIN
      .metadata/.mylyn/.taskListIndex/segments.gen
  3. BIN
      .metadata/.mylyn/.taskListIndex/segments_1
  4. BIN
      .metadata/.mylyn/repositories.xml.zip
  5. 1
      .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version
  6. BIN
      .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index
  7. 1
      .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version
  8. BIN
      .metadata/.plugins/org.eclipse.core.resources/.root/1.tree
  9. BIN
      .metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources
  10. 2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs
  11. 13
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs
  12. 2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs
  13. 2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs
  14. 4
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs
  15. 2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs
  16. 5
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs
  17. 2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs
  18. 2
      .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs
  19. 1886
      .metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi
  20. BIN
      .metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache
  21. BIN
      .metadata/.plugins/org.eclipse.jdt.core/externalFilesCache
  22. BIN
      .metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache
  23. BIN
      .metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache
  24. BIN
      .metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat
  25. 2
      .metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml
  26. 2
      .metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml
  27. 10
      .metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml
  28. BIN
      .metadata/.plugins/org.eclipse.mylyn.trac.core/repositoryConfigurations
  29. 2
      .metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties
  30. 11
      .metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml
  31. 4
      .metadata/.plugins/org.eclipse.ui.intro/dialog_settings.xml
  32. 15
      .metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml
  33. 4
      .metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml
  34. 3
      .metadata/version.ini
  35. 80
      src/myrobot/FirstRobot.java
  36. 87
      src/world/Node.java
  37. 23
      src/world/Point.java
  38. 8
      src/world/RouteFinder.java

@ -0,0 +1,13 @@
content_assist_proposals_background=255,255,255
content_assist_proposals_foreground=60,60,62
eclipse.preferences.version=1
fontPropagated=true
org.eclipse.jdt.ui.editor.tab.width=
org.eclipse.jdt.ui.formatterprofiles.version=12
org.eclipse.jdt.ui.javadoclocations.migrated=true
org.eclipse.jface.textfont=1|Monospace|10.0|0|GTK|1|;
proposalOrderMigrated=true
spelling_locale_initialized=true
tabWidthPropagated=true
useAnnotationsPrefPage=true
useQuickDiffPrefPage=true

@ -0,0 +1,2 @@
eclipse.preferences.version=1
mylyn.attention.migrated=true

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true

@ -0,0 +1,4 @@
eclipse.preferences.version=1
migrated.task.repositories.secure.store=true
org.eclipse.mylyn.tasks.ui.filters.nonmatching=true
org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true

@ -0,0 +1,2 @@
eclipse.preferences.version=1
pref_first_startup=false

@ -0,0 +1,5 @@
PROBLEMS_FILTERS_MIGRATE=true
eclipse.preferences.version=1
platformState=1426418472410
quickStart=false
tipsAndTricks=true

@ -0,0 +1,2 @@
eclipse.preferences.version=1
showIntro=false

@ -0,0 +1,2 @@
ENABLED_DECORATORS=org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator\:true,org.eclipse.jdt.ui.override.decorator\:true,org.eclipse.jdt.ui.interface.decorator\:false,org.eclipse.jdt.ui.buildpath.decorator\:true,org.eclipse.mylyn.context.ui.decorator.interest\:true,org.eclipse.mylyn.tasks.ui.decorators.task\:true,org.eclipse.mylyn.team.ui.changeset.decorator\:true,org.eclipse.pde.ui.binaryProjectDecorator\:false,org.eclipse.team.cvs.ui.decorator\:true,org.eclipse.ui.LinkedResourceDecorator\:true,org.eclipse.ui.SymlinkDecorator\:true,org.eclipse.ui.VirtualResourceDecorator\:true,org.eclipse.ui.ContentTypeDecorator\:true,org.eclipse.ui.ResourceFilterDecorator\:false,
eclipse.preferences.version=1

File diff suppressed because it is too large Load Diff

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<typeInfoHistroy/>

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<qualifiedTypeNameHistroy/>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart">
<item value="true" key="group_libraries"/>
<item value="false" key="linkWithEditor"/>
<item value="2" key="layout"/>
<item value="1" key="rootMode"/>
<item value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#x0A;&lt;packageExplorer group_libraries=&quot;1&quot; layout=&quot;2&quot; linkWithEditor=&quot;0&quot; rootMode=&quot;1&quot; workingSetName=&quot;Aggregate for window 1426418533468&quot;&gt;&#x0A;&lt;customFilters userDefinedPatternsEnabled=&quot;false&quot;&gt;&#x0A;&lt;xmlDefinedFilters&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.LibraryFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.LocalTypesFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.StaticsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.pde.ui.ExternalPluginLibrariesFilter1&quot; isEnabled=&quot;true&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.ClosedProjectsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonSharedProjectsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonJavaElementFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.ContainedLibraryFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.CuAndClassFileFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonJavaProjectsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.internal.ui.PackageExplorer.EmptyInnerPackageFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.PackageDeclarationFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.internal.ui.PackageExplorer.EmptyPackageFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.ImportDeclarationFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.FieldsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.internal.ui.PackageExplorer.HideInnerClassFilesFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonPublicFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer_patternFilterId_.*&quot; isEnabled=&quot;true&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.EmptyLibraryContainerFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.pde.ui.BinaryProjectFilter1&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.SyntheticMembersFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0A;&lt;child filterId=&quot;org.eclipse.mylyn.java.ui.MembersFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0A;&lt;/xmlDefinedFilters&gt;&#x0A;&lt;/customFilters&gt;&#x0A;&lt;/packageExplorer&gt;" key="memento"/>
</section>
</section>

@ -0,0 +1,2 @@
#Cached timestamps
#Sun Mar 15 12:22:27 CET 2015

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="ChooseWorkspaceDialogSettings">
<item value="122" key="DIALOG_Y_ORIGIN"/>
<item value="200" key="DIALOG_X_ORIGIN"/>
</section>
<section name="WORKBENCH_SETTINGS">
<list key="ENABLED_TRANSFERS">
</list>
</section>
</section>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<item value="1024" key="introLaunchBar.location"/>
</section>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="org.eclipse.ui.internal.QuickAccess">
<item value="900" key="dialogWidth"/>
<item value="562" key="dialogHeight"/>
<list key="orderedProviders">
</list>
<list key="textArray">
</list>
<list key="orderedElements">
</list>
<list key="textEntries">
</list>
</section>
</section>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<workingSetManager>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1426418533469_0" label="Window Working Set" name="Aggregate for window 1426418533468"/>
</workingSetManager>

@ -0,0 +1,3 @@
#Sun Mar 15 12:22:05 CET 2015
org.eclipse.core.runtime=2
org.eclipse.platform=4.4.2.v20150204-1700

@ -1,75 +1,74 @@
package myrobot;
import java.util.HashSet;
import java.util.Arrays;
//import java.util.HashSet;
import java.util.TreeSet;
import java.util.Set;
import robocode.Robot;
import world.Generator;
import world.Node;
import world.Point;
public class FirstRobot extends Robot {
// cost is always 1 because we do not move on diagonals
public static final int G = 1;
private static Generator gen = new Generator();
private Generator gen = new Generator();
private static Set<Point> open = new HashSet<>();
private static Set<Point> closed = new HashSet<>();
private TreeSet<Node> open = new TreeSet<Node>();
private TreeSet<Node> closed = new TreeSet<Node>();
// private Node[] open, closed = new Node[];
private static Point lowestP;
private static int lowestF = 0;
// private
// private static
public void run() {
Node n = new Node(gen.start, new Point());
open.add(n);
while (true) {
open.add(gen.start);
for (Point p : open) {
int H = Manhattan(p, gen.stop);
int F = G + H;
if (lowestF == 0 || lowestF >= F) {
lowestF = F;
lowestP = p;
}
}
open.remove(lowestP);
closed.add(lowestP);
Point pu = new Point(lowestP.getX(), lowestP.getY() + 1);
Point pr = new Point(lowestP.getX() + 1, lowestP.getY());
Point pd = new Point(lowestP.getX(), lowestP.getY() - 1);
Point pl = new Point(lowestP.getX() - 1, lowestP.getY());
n = open.first();
open.remove(n);
closed.add(n);
Point pu = new Point(n.getCurrent().getX(), n.getCurrent().getY() + 1);
Point pr = new Point(n.getCurrent().getX() + 1, n.getCurrent().getY());
Point pd = new Point(n.getCurrent().getX(), n.getCurrent().getY() - 1);
Point pl = new Point(n.getCurrent().getX() - 1, n.getCurrent().getY());
Node nu = new Node(pu, n.getCurrent());
Node nr = new Node(pr, n.getCurrent());
Node nd = new Node(pd, n.getCurrent());
Node nl = new Node(pl, n.getCurrent());
// if (lowestP)
//
//
//
//// if (lowestP)
}
}
private void calculatePoint(Point p) {
if (isWalkable(p)) {
if (!open.contains(p)) {
open.add(p);
}
private void processPoint(Point p) {
if (isWalkable(p) && !closed.contains(p) && !open.contains(p)) {
// open.add(p);
}
}
private boolean isWalkable(Point p) {
return (!gen.obstacles.contains(p) &&
!closed.contains(p) &&
p.getX() >= 0 &&
private boolean isInsideMap(Point p) {
return (p.getX() >= 0 &&
p.getX() < Generator.ROWS &&
p.getY() >= 0 &&
p.getY() < Generator.COLS);
}
private void turn(int dest) {
int curr = (int) getHeading();
if (curr != dest) {
@ -85,10 +84,7 @@ public class FirstRobot extends Robot {
ahead(num * world.Generator.PX_STEP);
}
private int Manhattan(Point start, Point stop) {
return Math.abs(start.getX() - stop.getX()) + Math.abs(start.getX() - stop.getY());
}
public void up() {
north();
steps(1);

@ -1,10 +1,89 @@
package world;
public class Node extends Point {
import world.Point;
public Node(int x, int y) {
super(x, y);
// TODO Auto-generated constructor stub
public class Node implements Comparable<Node>{
//
// public static int lowestF;
//
// public static Point lowestP;
public static final int G = 1;
private Point current, parent;
private int F, H;
public Node(Point current, Point parent) {
this.current = current;
this.parent = parent;
H = manhattan(parent, current);
F = G + H;
}
//
// public Node(Point current) {
// this.current = current;
//
// H = manhattan(new Point(), current);
// F = G + H;
// }
private int manhattan(Point start, Point stop) {
return Math.abs(start.getX() - stop.getX()) + Math.abs(start.getX() - stop.getY());
}
public int getF() {
return F;
}
public int getG() {
return G;
}
public int getH() {
return H;
}
public Point getCurrent() {
return current;
}
public Point getParent() {
return parent;
}
@Override
public int compareTo(Node compareNode) {
int compareQuantity = ((Node) compareNode).getF();
//ascending order
return this.F - compareQuantity;
//descending order
//return compareQuantity - this.quantity;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Node node = (Node) o;
if (current.getX() != node.current.getX()) return false;
if (current.getY() != node.current.getY()) return false;
return true;
}
@Override
public int hashCode() {
int result = current.getX();
result = Generator.PX_STEP * result + current.getY();
return result;
}
}

@ -9,12 +9,20 @@ public class Point{
this.y = y;
}
public Point() {
this.x = -1;
this.y = -1;
}
public int getX() {
return x;
return x * Generator.PX_STEP + Generator.PX_OFFSET;
}
public int getX_() {
return x * Generator.PX_STEP + Generator.PX_OFFSET;
public int getX(boolean withoutOffset) {
if (withoutOffset)
return x;
else
return this.getX();
}
public void setX(int x) {
@ -22,11 +30,14 @@ public class Point{
}
public int getY() {
return y;
return y * Generator.PX_STEP + Generator.PX_OFFSET;
}
public int getY_() {
return y * Generator.PX_STEP + Generator.PX_OFFSET;
public int getY(boolean withoutOffset) {
if (withoutOffset)
return y;
else
return this.getY();
}
public void setY(int y) {

@ -45,8 +45,8 @@ public class RouteFinder {
int NdxObstacle = 0;
for (Point p : gen.obstacles) {
// added offset so the tanks are in the middle of the tiles
double InitialObstacleCol = (double) p.getX_();
double InitialObstacleRow = (double) p.getY_();
double InitialObstacleCol = (double) p.getX();
double InitialObstacleRow = (double) p.getY();
existingRobots[NdxObstacle] = modelRobots[0];
robotSetups[NdxObstacle++] = new RobotSetup(InitialObstacleCol, InitialObstacleRow, 0.0);
}
@ -55,8 +55,8 @@ public class RouteFinder {
* Create the agent and place it in a random position without obstacle
*/
existingRobots[Generator.NUM_OBSTACLES] = modelRobots[1];
double InitialAgentCol = (double) gen.start.getX_();
double InitialAgentRow = (double) gen.start.getY_();
double InitialAgentCol = (double) gen.start.getX();
double InitialAgentRow = (double) gen.start.getY();
robotSetups[Generator.NUM_OBSTACLES] = new RobotSetup(InitialAgentCol, InitialAgentRow, 0.0);
/* Create and run the battle */

Loading…
Cancel
Save