-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boulder Solver #540
Boulder Solver #540
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked through the code and checked it with intellisense. Looks good other than some small things.
float lineWidth = 5.0f; | ||
|
||
if (linePoints != null && linePoints.length > 0) { | ||
RenderHelper.renderLinesFromPoints(context, linePoints, ORANGE_COLOR_COMPONENTS, alpha, lineWidth, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lines need to be rendered one at a time for the line width and normals to not get messed up. (See the last part of Waterboard#render
.)
/** | ||
* Prints the current state of the game board to the console. | ||
* Each character represents a type of BoulderObject or an empty space. | ||
*/ | ||
public void printBoard() { | ||
for (int x = 0; x < height; x++) { | ||
for (int y = 0; y < width; y++) { | ||
BoulderObject boulderObject = grid[x][y]; | ||
String displayChar = (boulderObject != null) ? boulderObject.type() : "."; | ||
System.out.print(displayChar); | ||
} | ||
System.out.println(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't really matter but maybe something like Waterboard#boardToString
would be better since System.out.print
is not hardcoded.
/** | ||
* Represents a pair of objects, such as a game state and its associated path. | ||
* | ||
* @param <T> The type of the first object. | ||
* @param <U> The type of the second object. | ||
*/ | ||
private record Pair<T, U>(T first, U second) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it.unimi.dsi.fastutil.Pair
should be a drop in replacement (except constructors calls has to be changed to Pair.of
).
- it.unimi.dsi.fastutil.Pair instead of record Pair - printbard use of stringbuilder - render lines one at a time
This solver uses the A* search algorithm to get the shortest path.