* designed to participate in David Alves' SpinBotChallenge |
* designed to participate in the Pez' SpinBotChallenge * http://robowiki.net/cgi-bin/robowiki?SpinBotChallenge |
turnRight(angle_180(bearing - getHeading() + 90 - direction/20)); |
turnRight(angle_180(bearing - getHeading() + 90)); adjustForWall?(); |
timetohit = getTime() + enemyDist/11 - 20; |
timetohit = getTime() + enemyDist/11 - 14; |
public void adjustForWall?() { double tX, tY, dX, dY; double newHeading; double sign; dX = direction * Math.sin(rad(getHeading())); dY = direction * Math.cos(rad(getHeading())); tX = getX() + dX; tY = getY() + dY; if (tX>=20 && tX<=getBattleFieldWidth?()-20 && tY>=20 && tY<=getBattleFieldHeight?()-20) return; if (tX < 20) { tX = 20; if (dY<0) sign = -1; else sign = 1; dX = 20-getX(); dY = sign * Math.sqrt(direction*direction - dX*dX); } if (tX > getBattleFieldWidth?()-20) { tX = getBattleFieldWidth?()-20; if (dY<0) sign = -1; else sign = 1; dX = getBattleFieldWidth?()-20-getX(); dY = sign * Math.sqrt(direction*direction - dX*dX); } if (tY < 20) { tY = 20; if (dX<0) sign = -1; else sign = 1; dY = 20-getY(); dX = sign * Math.sqrt(direction*direction - dY*dY); } if (tY > getBattleFieldHeight?()-20) { tY = getBattleFieldHeight?()-20; if (dX<0) sign = -1; else sign = 1; dY = getBattleFieldHeight?()-20-getY(); dX = sign * Math.sqrt(direction*direction - dY*dY); } double turn = deg(Math.atan2(dX, dY)) - getHeading(); if (direction<0) turn += 180; turnRight(angle_180(turn)); } |
turnGunRight?(angle_180(bearing - getGunHeading?())); |
if (Math.abs(bearing - getGunHeading?()) < 20) turnGunRight?(angle_180(bearing - getGunHeading?())); |
// AdvancedRobots?, remeber?) and that the gun needs time (probably one tick |
// AdvancedRobots?, remember?) and that the gun needs time (probably one tick |
if (!(getGunHeat()<1)) return; |
while (!(getGunHeat()<1)) { found = false; radar(); } timetohit = getTime() + enemyDist/11 - 20; |
found = false; |
</pre> |
</pre> |