Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/group10player/DeliveryDrone.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ public void dropOnWall() throws GameActionException {
}

int distance = myLocation.distanceSquaredTo(dropTarget);

if(distance <= 0) {
// System.out.println("Drone too close!");
tryMoveDirection(randomDirection());
Expand Down Expand Up @@ -333,7 +332,6 @@ public void searchForEnemy()
public void searchForLandscaper() throws GameActionException {
RobotInfo[] allied_robots = rc.senseNearbyRobots(24, rc.getTeam());
RobotInfo[] enemy_robots = rc.senseNearbyRobots(24, rc.getTeam().opponent());

if (HQLocation == null){
tryFindHQLocation();
return;
Expand Down
146 changes: 146 additions & 0 deletions test/group10player/DeliveryDroneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.scalactic.Or;
import scala.collection.immutable.Map;

import java.util.ArrayList;
import java.util.Vector;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -242,4 +243,149 @@ public void dropOnWallTest2() throws GameActionException{
DDtest.dropOnWall();
}

@Test
public void dropOnWallTest3() throws GameActionException{
when(RCtest.getLocation()).thenReturn(new MapLocation(100,100));
DDtest.HQLocation = new MapLocation(2,2);
DDtest.dropOnWall();
}

@Test
public void dropOnWallTest4() throws GameActionException{
MapLocation temp = new MapLocation(1,1);
when(RCtest.getLocation()).thenReturn(temp);
DDtest.HQLocation = new MapLocation(2,2);
when(RCtest.canSenseLocation(temp.add(Direction.NORTH))).thenReturn(true);
when(RCtest.isLocationOccupied(temp.add(Direction.NORTH))).thenReturn(false);
DDtest.dropOnWall();
}

@Test
public void dropOnWallTest5() throws GameActionException{
MapLocation temp = new MapLocation(1,1);
when(RCtest.getLocation()).thenReturn(temp);
DDtest.HQLocation = new MapLocation(1,1);
when(RCtest.canSenseLocation(temp.add(Direction.NORTH))).thenReturn(true);
when(RCtest.isLocationOccupied(temp.add(Direction.NORTH))).thenReturn(false);
when(RCtest.canDropUnit(temp.directionTo(temp.add(Direction.NORTH)))).thenReturn(true);
DDtest.dropOnWall();
}

@Test
public void dropOnWallTest6() throws GameActionException{
MapLocation temp = new MapLocation(4,4);
when(RCtest.getLocation()).thenReturn(temp);
DDtest.HQLocation = new MapLocation(1,1);
when(RCtest.canSenseLocation(temp.add(Direction.NORTH))).thenReturn(true);
when(RCtest.isLocationOccupied(temp.add(Direction.NORTH))).thenReturn(false);
DDtest.dropOnWall();
}

@Test
public void searchForLandscaperTest1() throws GameActionException{
DDtest.searchForLandscaper();
}

@Test
public void searchForLandscaperTest2() throws GameActionException{
DDtest.HQLocation = new MapLocation(1,1);
DDtest.searchForLandscaper();
}

@Test
public void searchForLandscaperTest3() throws GameActionException{
when(RCtest.senseNearbyRobots(24,Team.A)).thenReturn(new RobotInfo[]{new RobotInfo(12, Team.A, RobotType.DELIVERY_DRONE, 0, true, 0, 0, 0, new MapLocation(4, 4))});
when(RCtest.senseNearbyRobots(24,Team.B)).thenReturn(new RobotInfo[]{new RobotInfo(12, Team.B, RobotType.DELIVERY_DRONE, 0, true, 0, 0, 0, new MapLocation(5, 5))});
DDtest.HQLocation = new MapLocation(1,1);
DDtest.searchForLandscaper();
}

@Test
public void searchForLandscaperTest4() throws GameActionException{
when(RCtest.senseNearbyRobots(24,Team.A)).thenReturn(new RobotInfo[]{new RobotInfo(12, Team.A, RobotType.DELIVERY_DRONE, 0, true, 0, 0, 0, new MapLocation(4, 4))});
when(RCtest.senseNearbyRobots(24,Team.B)).thenReturn(new RobotInfo[]{new RobotInfo(12, Team.B, RobotType.LANDSCAPER, 0, true, 0, 0, 0, new MapLocation(5, 5))});
DDtest.HQLocation = new MapLocation(1,1);
DDtest.searchForLandscaper();
}

@Test
public void searchForLandscaperTest5() throws GameActionException{
when(RCtest.senseNearbyRobots(24,Team.A)).thenReturn(new RobotInfo[]{new RobotInfo(12, Team.A, RobotType.DELIVERY_DRONE, 0, true, 0, 0, 0, new MapLocation(4, 4))});
when(RCtest.senseNearbyRobots(24,Team.B)).thenReturn(new RobotInfo[]{new RobotInfo(12, Team.B, RobotType.MINER, 0, true, 0, 0, 0, new MapLocation(5, 5))});
DDtest.HQLocation = new MapLocation(1,1);
DDtest.searchForLandscaper();
}

@Test
public void searchForLandscaperTest6() throws GameActionException{
when(RCtest.senseNearbyRobots(24,Team.A)).thenReturn(new RobotInfo[]{new RobotInfo(12, Team.A, RobotType.LANDSCAPER, 0, true, 0, 0, 0, new MapLocation(4, 4))});
when(RCtest.senseNearbyRobots(24,Team.B)).thenReturn(new RobotInfo[]{new RobotInfo(12, Team.B, RobotType.DELIVERY_DRONE, 0, true, 0, 0, 0, new MapLocation(5, 5))});
DDtest.HQLocation = new MapLocation(1,1);
DDtest.searchForLandscaper();
}

@Test
public void searchForLandscaperTest7() throws GameActionException{
DDtest.HQLocation = new MapLocation(1,1);
DDtest.target = 1;
when(RCtest.senseNearbyRobots(24,Team.A)).thenReturn(new RobotInfo[]{new RobotInfo(12, Team.A, RobotType.LANDSCAPER, 0, true, 0, 0, 0, new MapLocation(4, 4))});
when(RCtest.senseNearbyRobots(24,Team.B)).thenReturn(new RobotInfo[]{new RobotInfo(12, Team.B, RobotType.DELIVERY_DRONE, 0, true, 0, 0, 0, new MapLocation(5, 5))});
when(RCtest.senseRobot(1)).thenReturn(new RobotInfo(12, Team.A, RobotType.LANDSCAPER, 0, true, 0, 0, 0, new MapLocation(4, 4)));
when(RCtest.getLocation()).thenReturn(new MapLocation(2,2));
DDtest.HQLocation = new MapLocation(1,1);
DDtest.searchForLandscaper();
}

@Test
public void grabLandscaperTest1() throws GameActionException{
DDtest.grabLandscaper();
}

@Test
public void grabLandscaperTest2() throws GameActionException{
DDtest.target = 1;
when(RCtest.senseRobot(1)).thenReturn(new RobotInfo(12, Team.A, RobotType.LANDSCAPER, 0, true, 0, 0, 0, new MapLocation(3, 3)));
DDtest.HQLocation = new MapLocation(2,2);
DDtest.grabLandscaper();
}

@Test
public void grabLandscaperTest3() throws GameActionException{
DDtest.target = 1;
when(RCtest.senseRobot(1)).thenReturn(new RobotInfo(12, Team.A, RobotType.LANDSCAPER, 0, true, 0, 0, 0, new MapLocation(5, 5)));
DDtest.HQLocation = new MapLocation(2,2);
when(RCtest.getLocation()).thenReturn(new MapLocation(1,1));
DDtest.grabLandscaper();
}

@Test
public void grabLandscaperTest4() throws GameActionException{
DDtest.target = 1;
when(RCtest.senseRobot(1)).thenReturn(new RobotInfo(12, Team.A, RobotType.LANDSCAPER, 0, true, 0, 0, 0, new MapLocation(5, 5)));
DDtest.HQLocation = new MapLocation(2,2);
when(RCtest.getLocation()).thenReturn(new MapLocation(4,4));
when(RCtest.canPickUpUnit(1)).thenReturn(true);
DDtest.grabLandscaper();
}

@Test
public void surroundHQtest1() throws GameActionException{
DDtest.surroundHQ();
}

@Test
public void surroundHQtest2() throws GameActionException{
DDtest.current_ring_pos = 10;
DDtest.ring_positions = new ArrayList<MapLocation>(5);
DDtest.surroundHQ();
}

@Test
public void surroundHQtest3() throws GameActionException{
DDtest.current_ring_pos = 3;
DDtest.ring_positions = new ArrayList<MapLocation>(5);
when(RCtest.getLocation()).thenReturn(new MapLocation(2,2));
DDtest.surroundHQ();
}

}