package ntc; |
static StringBuffer? headDelta; static StringBuffer? velocity; |
static String headDelta; static String velocity; |
|
int direction = 1; |
headDelta=new StringBuffer?(); velocity=new StringBuffer?(); |
headDelta=""; velocity=""; |
// After trying out your robot, try uncommenting the import at the top, // and the next line: setColors(Color.WHITE,Color.BLACK,new Color(0,255,0)); |
setFire(0.1); setColors(Color.WHITE,Color.BLACK,Color.GREEN); |
doNothing(); |
double currentDirection=18D; double maxX = getBattleFieldWidth?()-currentDirection; double maxY = getBattleFieldHeight?()-currentDirection; double futureX, futureY; currentDirection=45; while(true){ double time = getTime(); double ahead = currentDirection*(Math.sin(time/17D)-Math.cos(time/23D)); setAhead(ahead); execute(); futureX = ahead*Math.sin(getHeadingRadians())+getX(); futureY = ahead*Math.cos(getHeadingRadians())+getY(); if (futureX < 18D || futureY < 18D || futureX > maxX || futureY > maxY){ currentDirection = -currentDirection; } scan(); execute(); } |
setTurnRightRadians?(normalRelativeAngle(Math.PI/2-e.getBearingRadians?())); |
headDelta.append( (char)(int)(e.getHeadingRadians()-lastHeading) ); velocity.append( (char)(int)(e.getVelocity()) ); lastHeading=e.getHeadingRadians(); if(headDelta.length()>10 && getGunHeat()/getGunCoolingRate?()<5){ double bulletPower=3; String currentH=headDelta.toString().substring(headDelta.length()-7); String currentV=velocity.toString().substring(velocity.length()-7); |
headDelta += (char)(int)(e.getHeading()-lastHeading); velocity += (char)(int)(e.getVelocity()); lastHeading=e.getHeading(); if(headDelta.length()>50 && getGunHeat()/getGunCoolingRate?()<4){ double bulletPower=2.5; String currentH=headDelta.substring(headDelta.length()-7); String currentV=velocity.substring(velocity.length()-7); |
for(int i=0;i+7<=headDelta.length();i++){ if(headDelta.toString().substring(i,i+7).equals(currentH) && velocity.toString().substring(i,i+7).equals(currentV)){ |
double diff=Double.POSITIVE_INFINITY; for(int i=0;i+7<=headDelta.length()-14;i++){ double thisDiff=0; if(headDelta.substring(i,i+7).equals(currentH) && velocity.substring(i,i+7).equals(currentV)){ |
for(int j=0;j<currentH.length();j++){ thisDiff+=Math.pow(((double)(int)currentH.charAt(j))-((double)(int)headDelta.substring(i,i+7).charAt(j)),2); thisDiff+=Math.pow(((double)(int)currentV.charAt(j))-((double)(int)velocity.substring(i,i+7).charAt(j)),2); } if(thisDiff<diff && thisDiff/3<1){ startIndex=i+7; diff=thisDiff; } |
double bT=0; |
eH+=((double)(int)headDelta.toString().charAt(index)); double dX=Math.sin(eH) * ((double)(int)velocity.toString().charAt(index)); double dY=Math.cos(eH) * ((double)(int)velocity.toString().charAt(index)); |
eH+=((double)(int)headDelta.charAt(index)); double dX=Math.sin(Math.toRadians(eH)) * ((double)(int)velocity.charAt(index)); double dY=Math.cos(Math.toRadians(eH)) * ((double)(int)velocity.charAt(index)); |
out.println(":)"); |
bulletPower=(20-(distance(myX,myY,eX,eY)/bT))/3; |
bD+=20-(3*bulletPower); |
bD+=Rules.getBulletSpeed?(bulletPower); bT++; |
if(getGunHeat()==0d){ setFire(3); } |
setTurnRadarRightRadians(normalRelativeAngle(e.getBearingRadians?()+myHeading-getRadarHeadingRadians?())*2); scan(); execute(); |
double radarAmt=normalRelativeAngle( getHeadingRadians() + e.getBearingRadians?() - getRadarHeadingRadians?()); radarAmt += (radarAmt < 0.0 ? Math.atan( -18 / e.getDistance()) : Math.atan( 18 / e.getDistance())); setTurnRadarRightRadians(radarAmt); |
return ((angle + 15.7079633) % 6.2831853) - Math.PI; |
return robocode.util.Utils.normalRelativeAngle(angle); |
|
The onPaint and out.println(":)"); are for debugging. --Starrynte |
The onPaint and out.println(":)"); are for debugging. I need them, because it is not workingfor some reason i don't know! (i think it has something to do with the finding of the start index)--Starrynte |