Skip to content
Merged
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
59 changes: 57 additions & 2 deletions RobotPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class RobotPlayer{
static Random randall;
static Team ourTeam;
static Team opponentTeam;
static int[] zombieRounds;

/**
* run
Expand Down Expand Up @@ -45,8 +46,42 @@ public static void run(RobotController r){
Scout s = new RobotPlayer().new Scout();
s.run();
}
else if(selftype == RobotType.GUARD) {
Guard s = new RobotPlayer().new Guard();
s.run();
}
}

/** class Guard
*
* The class outlining our Guard bots
*
*
*/
private class Guard {

public Guard() {
}

public void run() {
while(true){
try{
if(rc.isCoreReady()){
RobotInfo[] robots = rc.senseNearbyRobots(1, Team.ZOMBIE);
for(RobotInfo robot: robots) {
if(rc.canAttackLocation(robot.location)) {
rc.attackLocation(robot.location);
}
}
rc.move(Direction.EAST);
}
Clock.yield();
}catch(Exception e){
e.printStackTrace();
}
}
}
}

/**
* class Archon
*
Expand All @@ -60,6 +95,7 @@ private class Archon{
*
*/
public Archon(){
zombieRounds = rc.getZombieSpawnSchedule().getRounds();
}

/**
Expand All @@ -74,7 +110,8 @@ public void run(){
try{
//If it can, always tries to build Scouts.
if(rc.isCoreReady()){
if(RESOURCE_FUNCTIONS.tryBuild(RobotType.SCOUT)){ //See function in RESOURCE_FUNCTIONS to know what it does
RobotType type = RESOURCE_FUNCTIONS.chooseRobotType();
if(RESOURCE_FUNCTIONS.tryBuild(type)){ //See function in RESOURCE_FUNCTIONS to know what it does
//After building scout, waits a turn, then signals it the location, so it has a good idea of where base is
Clock.yield();
rc.broadcastMessageSignal(0,0,9);
Expand Down Expand Up @@ -409,6 +446,24 @@ public static boolean trySendMessage(Tuple<Integer,Integer> information,int type
rc.broadcastMessageSignal(first,second,radiusSqr);
return true;
}

/**
* RobotType chooseRobotType
* @param none
* @return RobotType that will be produced
*/
public static RobotType chooseRobotType() {
for(int i: zombieRounds){
int currentRound = rc.getRoundNum();
if(i-currentRound<=15 && i-currentRound>=0){
return RobotType.SCOUT;
}
}
if(Math.random()*10>1) {
return RobotType.SCOUT;
}
return RobotType.GUARD;
}
}

/**
Expand Down