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
18 changes: 12 additions & 6 deletions RobotPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import battlecode.common.*; //imports Battlecode UI
import java.util.Random; //Use this instead of Math.random(); seeded by the robot's id so more likely to be random than Math.random
import java.util.Arrays;

public class RobotPlayer{
/**
Expand Down Expand Up @@ -115,7 +116,7 @@ public void run(){
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);
FancyMessage.sendMessage(0,0b11101,31,30);
}
}
Clock.yield();
Expand Down Expand Up @@ -171,8 +172,11 @@ public void run(){
int counted = 0;
for(int i = 0; i < signals.length; i++){
if(signals[i].getTeam() == rc.getTeam() && rc.senseRobot(signals[i].getID()).type == RobotType.ARCHON){
approxxCoordinates.first += signals[i].getLocation().x;
approxxCoordinates.second += signals[i].getLocation().y;
FancyMessage f = FancyMessage.getFromRecievedSignal(signals[i]);
rc.setIndicatorString(0,"Type:" + f.type + "::Key:" + f.key);
rc.setIndicatorString(1,"Info:" + Arrays.toString(f.bits));
approxxCoordinates.first += f.senderLocation.x;
approxxCoordinates.second += f.senderLocation.y;
counted++;
}
}
Expand All @@ -182,7 +186,7 @@ public void run(){

//sets @base to this
base = new MapLocation(approxxCoordinates.first,approxxCoordinates.second);
rc.setIndicatorString(0,"x:" + base.x + "::y:" + base.y);
//rc.setIndicatorString(0,"x:" + base.x + "::y:" + base.y);
}
}
}else{
Expand Down Expand Up @@ -414,7 +418,7 @@ public static boolean moveAsFarAwayAsPossibleFrom(MapLocation epicenter) throws
}
}
//returns false if it can't move
rc.setIndicatorString(1,"max:none");
//rc.setIndicatorString(1,"max:none");
return false;
}

Expand Down Expand Up @@ -486,6 +490,7 @@ public static class FancyMessage{
public MapLocation senderLocation;
public boolean[] bits;
public int type;
public int key;
public FancyMessage(){
}
public static FancyMessage getFromRecievedSignal(Signal s){
Expand All @@ -496,6 +501,7 @@ public static FancyMessage getFromRecievedSignal(Signal s){
Tuple<Integer,boolean[]> info = decrypt(new Tuple<Integer,Integer>(is[0],is[1]));
ret.type = info.first;
ret.bits = info.second;
ret.key = (is[0] & 0b11110000) >> 4;
return ret;
}
public static boolean sendMessage(int type,boolean[] data,int radiusSqr) throws GameActionException{
Expand All @@ -515,7 +521,7 @@ public static boolean sendMessage(Tuple<Integer,Integer> encodeddata, int radius
}
public static Tuple<Integer,boolean[]> decrypt(Tuple<Integer,Integer> inputs){
int typeIn = inputs.first & 0b1111;
int keyIn = inputs.first & 0b11110000;
int keyIn = (inputs.first & 0b11110000) >> 4;
int encryptor = 0;
for(int i = 0; i < 8; i++){
encryptor |= (keyIn & 0b1111) << (i * 4);
Expand Down