mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 08:39:17 +00:00
Use the Positions hashcode implementation and utilize toStringHelper within Node.
This commit is contained in:
@@ -5,6 +5,8 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import org.apollo.game.model.Position;
|
import org.apollo.game.model.Position;
|
||||||
|
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A node representing a weighted {@link Position}.
|
* A node representing a weighted {@link Position}.
|
||||||
*
|
*
|
||||||
@@ -100,7 +102,7 @@ final class Node {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return position.getX() * 31 + position.getY();
|
return position.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -141,8 +143,7 @@ final class Node {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return Node.class.getSimpleName() + " [x=" + position.getX() + ", y=" + position.getY() + ", open=" + open + ", cost="
|
return MoreObjects.toStringHelper(this).add("position", position).add("open", open).add("cost", cost).toString();
|
||||||
+ cost + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ import org.apollo.game.model.Position;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A very simple pathfinding algorithm that simply walks in the direction of the target until it either reaches it or is
|
* A very simple pathfinding algorithm that simply walks in the direction of the target until it either reaches it or is
|
||||||
* blocked. TODO diagonal movement support.
|
* blocked.
|
||||||
*
|
*
|
||||||
* @author Major
|
* @author Major
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user