Skip to content

Commit

Permalink
Fix nextStep input must be not the rotated vector. The rotation will …
Browse files Browse the repository at this point in the history
…be checked in the method (#4)
  • Loading branch information
zentox authored Jul 26, 2023
1 parent 9786d92 commit 7703378
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/h06/problems/MazeSolverRecursive.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public MazeSolverRecursive() {

@Override
public DirectionVector nextStep(World world, Point p, DirectionVector d) {
return !world.isBlocked(p, d) ? d : nextStep(world, p, d.rotate90());
return !world.isBlocked(p, d.rotate270()) ? d.rotate270() : nextStep(world, p, d.rotate90());
}

@Override
public int numberOfSteps(World world, Point s, Point e, DirectionVector d) {
if (s.equals(e)) {
return 1;
}
DirectionVector next = nextStep(world, s, d.rotate270());
DirectionVector next = nextStep(world, s, d);
return 1 + numberOfSteps(world, next.getMovement(s), e, next);
}

Expand Down Expand Up @@ -57,7 +57,7 @@ private void solveHelper(World world, Point p, Point e, DirectionVector d, Point
return;
}
path[index++] = p;
DirectionVector next = nextStep(world, p, d.rotate270());
DirectionVector next = nextStep(world, p, d);
solveHelper(world, next.getMovement(p), e, next, path, index);
}
}

0 comments on commit 7703378

Please sign in to comment.