Skip to content

Commit 421ba3e

Browse files
author
Gabriel Derrien
committed
Version RENDUE finale
1 parent 27223cd commit 421ba3e

File tree

9 files changed

+32
-13
lines changed

9 files changed

+32
-13
lines changed

bin/AStarSolver$1.class

155 Bytes
Binary file not shown.

bin/AStarSolver$2.class

137 Bytes
Binary file not shown.

bin/AStarSolver.class

0 Bytes
Binary file not shown.

bin/DFS_Solver.class

36 Bytes
Binary file not shown.

bin/Main.class

-1 Bytes
Binary file not shown.
File renamed without changes.

src/AStarSolver.java

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,22 @@ public AStarSolver(Maze m, Boolean manhattan)
1919
{
2020
public int compare(Node<Maze> s1, Node<Maze> s2)
2121
{
22-
Double cs1 = s1.getContent().getCurrState().getF();
23-
Double cs2 = s2.getContent().getCurrState().getF();
22+
Double sf1 = s1.getContent().getCurrState().getF();
23+
Double sf2 = s2.getContent().getCurrState().getF();
24+
Double sh1 = s1.getContent().getCurrState().getH();
25+
Double sh2 = s2.getContent().getCurrState().getH();
2426

25-
if(cs1 > cs2)
27+
if(sf1 > sf2)
2628
return 1;
27-
else if(cs1 == cs2)
28-
return 0;
29+
else if(sf1 == sf2)
30+
{
31+
if(sh1 > sh2)
32+
return 1;
33+
else if(sh1 == sh2)
34+
return 0;
35+
else
36+
return -1;
37+
}
2938
else
3039
return -1;
3140
}
@@ -34,13 +43,22 @@ else if(cs1 == cs2)
3443
{
3544
public int compare(Square s1, Square s2)
3645
{
37-
Double cs1 = s1.getF();
38-
Double cs2 = s2.getF();
46+
Double sf1 = s1.getF();
47+
Double sf2 = s2.getF();
48+
Double sh1 = s1.getH();
49+
Double sh2 = s2.getH();
3950

40-
if(cs1 > cs2)
51+
if(sf1 > sf2)
4152
return 1;
42-
else if(cs1 == cs2)
43-
return 0;
53+
else if(sf1 == sf2)
54+
{
55+
if(sh1 > sh2)
56+
return 1;
57+
else if(sh1 == sh2)
58+
return 0;
59+
else
60+
return -1;
61+
}
4462
else
4563
return -1;
4664
}

src/DFS_Solver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ public String solve()
8989

9090
if(endfound)
9191
{
92-
this.maze.initMaze();
92+
this.maze.resetGrid();
9393
Node<Maze> revertedTree = ((Stack<Node<Maze>>) this.frontier).pop();
9494

95+
revertedTree = revertedTree.getFather().getFather();
9596
this.result += "Path: " + this.maze.getEnd().toString() + "(End) <- ";
9697
this.pathLength++;
9798

src/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public static void main(String[] args) throws IOException
2222
//====================
2323
//====================
2424

25-
Maze lab2 = new Maze("./data/test.txt");
25+
Maze lab2 = new Maze("./data/lab.txt");
2626

27-
//char[] order = {'N', 'W', 'S', 'E'};
27+
//char[] order = {'W', 'E', 'N', 'S'};
2828
//lab2.setOrder(order);
2929

3030
//System.out.println(lab2.toString());

0 commit comments

Comments
 (0)