Use the Positions hashcode implementation and utilize toStringHelper within Node.

This commit is contained in:
Ryley Kimmel
2015-02-25 23:50:42 -05:00
parent 5f2b1566de
commit 750b200d90
2 changed files with 5 additions and 4 deletions
@@ -5,6 +5,8 @@ import java.util.Optional;
import org.apollo.game.model.Position;
import com.google.common.base.MoreObjects;
/**
* A node representing a weighted {@link Position}.
*
@@ -100,7 +102,7 @@ final class Node {
@Override
public int hashCode() {
return position.getX() * 31 + position.getY();
return position.hashCode();
}
/**
@@ -141,8 +143,7 @@ final class Node {
@Override
public String toString() {
return Node.class.getSimpleName() + " [x=" + position.getX() + ", y=" + position.getY() + ", open=" + open + ", cost="
+ cost + "]";
return MoreObjects.toStringHelper(this).add("position", position).add("open", open).add("cost", cost).toString();
}
}
@@ -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
* blocked. TODO diagonal movement support.
* blocked.
*
* @author Major
*/