Archived
1
0

-Started to add distanceFromPoint to drone tools

-Continued implementation of move in Police

Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
Tony Grosinger 2011-10-04 14:47:09 -07:00
parent 9190e7c306
commit 589eb0f8e7
4 changed files with 19 additions and 2 deletions

View File

@ -387,4 +387,17 @@ public class DroneTools {
public int getTeamBalance() { public int getTeamBalance() {
return currentTeam.getBalance(); return currentTeam.getBalance();
} }
/**
* Calculates and returns the distance of the drone from a provided point.
* Number is rounded up to nearest whole number >= actual distance.
*
* @param p
* Point to find distance to
* @return <code>int</code>
*/
public int distanceFromPoint(Point p) {
return 1;
// TODO - Implement distanceFromePoint
}
} }

View File

@ -77,8 +77,12 @@ public class Police implements Drone {
for (NeighborDrone aDrone : tools.checkRadar()) { for (NeighborDrone aDrone : tools.checkRadar()) {
if (aDrone.getUID().equals(UIDofDroneIAmFollowing)) { if (aDrone.getUID().equals(UIDofDroneIAmFollowing)) {
// If I am within 1 space of it, attack // If I am within 1 space of it, attack
// TODO Point droneBeingFollowed = new Point(aDrone.getX(), aDrone.getY());
// Else move towards it if (tools.distanceFromPoint(droneBeingFollowed) <= 1) {
return EnumMove.Attack;
} else {
goToPoint(droneBeingFollowed);
}
} }
} }
} else if (iAmGoingToGiveBackup != null) { } else if (iAmGoingToGiveBackup != null) {