Skip to content
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

Merged
merged 2 commits into from
Feb 15, 2024
Merged

Conversation

LifeIsAParadox
Copy link
Member

This solver uses the A* search algorithm to get the shortest path.

image

@LifeIsAParadox LifeIsAParadox added new feature This issue or PR is a new feature reviews needed This PR needs reviews labels Feb 11, 2024
@LifeIsAParadox LifeIsAParadox added this to the 1.18 milestone Feb 11, 2024
Copy link
Collaborator

@kevinthegreat1 kevinthegreat1 left a 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);
Copy link
Collaborator

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.)

Comment on lines 112 to 125
/**
* 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();
}
}
Copy link
Collaborator

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.

Comment on lines 87 to 93
/**
* 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) {}
Copy link
Collaborator

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).

@kevinthegreat1 kevinthegreat1 added changes requested This PR need changes and removed reviews needed This PR needs reviews labels Feb 11, 2024
- it.unimi.dsi.fastutil.Pair instead of record Pair
- printbard use of stringbuilder
- render lines one at a time
@LifeIsAParadox LifeIsAParadox added reviews needed This PR needs reviews and removed changes requested This PR need changes labels Feb 13, 2024
@kevinthegreat1 kevinthegreat1 added merge me please Pull requests that are ready to merge and removed reviews needed This PR needs reviews labels Feb 14, 2024
@kevinthegreat1 kevinthegreat1 merged commit f11f206 into SkyblockerMod:master Feb 15, 2024
1 check passed
@AzureAaron AzureAaron removed the merge me please Pull requests that are ready to merge label Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This issue or PR is a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants