I think I identified the problem.
It seems to come from the Maze menu painting. The ovals that should be underneath are not painted, probably because the menu folds after the path is painted, causing this zone to be repainted, but without the path drawn.
I think I identified the problem.
It seems to come from the Maze menu painting. The ovals that should be underneath are not painted, probably because the menu folds after the path is painted, causing this zone to be repainted, but without the path drawn.
I finally found the answer ! The problem starts at Dijkstra.java#L29 where we ask for g.getCost(pivot, vertex). In the getCost method we execute return generateNeighbours(startBox).contains(endBox) ? 1 : 0;. The thing is that the neighbourList had never been previously generated ! We iterated on the pivot's neighbourListList at Dijkstra.java#L25 but never actually generated it, so the neighbourList attribute of pivot was never changed. This caused that all g.getCost(pivot, vertex) were equal to 0, so that was never a priority to any vertex when looking for the shortest path.
What I had to change was :
Dijkstra.java#L25 : Switch for (VertexInterface vertex: g.generateNeighbours(pivot)) { to for (VertexInterface vertex: pivot.generateNeighbours()) {
Change the generateNeighbours() method of Box.java so it actually updates the neighbourList attribute
Add the generateNeighbours() to VertexInterface.java
Change the attribute private ArrayList<Box> neighbourList = new ArrayList<Box>() ; to private ArrayList<Box> neighbourList; and the following methods using it.
And now it works fine !
I finally found the answer ! The problem starts at [Dijkstra.java#L29](https://git.regar42.fr/antograb/TpMazeJava/src/branch/drawShortestPath/src/dijkstra/Dijkstra.java#L29) where we ask for `g.getCost(pivot, vertex)`. In the `getCost` method we execute `return generateNeighbours(startBox).contains(endBox) ? 1 : 0;`. The thing is that the `neighbourList` had never been previously generated ! We iterated on the `pivot`'s `neighbourListList` at [Dijkstra.java#L25](https://git.regar42.fr/antograb/TpMazeJava/src/branch/master/src/dijkstra/Dijkstra.java#L25) but never actually generated it, so the `neighbourList` attribute of `pivot` was never changed. This caused that all `g.getCost(pivot, vertex)` were equal to 0, so that was never a priority to any vertex when looking for the shortest path.
What I had to change was :
- [Dijkstra.java#L25](https://git.regar42.fr/antograb/TpMazeJava/src/branch/master/src/dijkstra/Dijkstra.java#L25) : Switch `for (VertexInterface vertex: g.generateNeighbours(pivot)) {` to `for (VertexInterface vertex: pivot.generateNeighbours()) {`
- [Box.java](https://git.regar42.fr/antograb/TpMazeJava/src/branch/master/src/dijkstra/Dijkstra.java) :
- Change the `generateNeighbours()` method of `Box.java` so it actually updates the `neighbourList` attribute
- Add the `generateNeighbours()` to `VertexInterface.java`
- Change the attribute `private ArrayList<Box> neighbourList = new ArrayList<Box>() ;` to `private ArrayList<Box> neighbourList;` and the following methods using it.
And now it works fine !
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
It appears that on horizontal trajectories, circles representing the shortest path are halfdrawn or even not drawn (see screenshot).
Ow, never seen this before, that's fun.
There are probably some nasty things going on…
I think I identified the problem.
It seems to come from the Maze menu painting. The ovals that should be underneath are not painted, probably because the menu folds after the path is painted, causing this zone to be repainted, but without the path drawn.
Here is the exemple maze :
The shortest path bug :
It's even worse in this case and seems to create an infinite path if we keep adding lines :
I finally found the answer ! The problem starts at Dijkstra.java#L29 where we ask for
g.getCost(pivot, vertex). In thegetCostmethod we executereturn generateNeighbours(startBox).contains(endBox) ? 1 : 0;. The thing is that theneighbourListhad never been previously generated ! We iterated on thepivot'sneighbourListListat Dijkstra.java#L25 but never actually generated it, so theneighbourListattribute ofpivotwas never changed. This caused that allg.getCost(pivot, vertex)were equal to 0, so that was never a priority to any vertex when looking for the shortest path.What I had to change was :
for (VertexInterface vertex: g.generateNeighbours(pivot)) {tofor (VertexInterface vertex: pivot.generateNeighbours()) {generateNeighbours()method ofBox.javaso it actually updates theneighbourListattributegenerateNeighbours()toVertexInterface.javaprivate ArrayList<Box> neighbourList = new ArrayList<Box>() ;toprivate ArrayList<Box> neighbourList;and the following methods using it.And now it works fine !