Difference between revisions of "New Years"
Line 6: | Line 6: | ||
OK, many place (but not my place) had enter 2009. 10 hours left (UTC), use it at your own risk! (I think I will write a last nano-bot of this year :)) This page is hard to find (if you don't look at Recent changes link :)). -- [[User:Nat|Nat]] 14:05, 31 December 2008 (UTC) | OK, many place (but not my place) had enter 2009. 10 hours left (UTC), use it at your own risk! (I think I will write a last nano-bot of this year :)) This page is hard to find (if you don't look at Recent changes link :)). -- [[User:Nat|Nat]] 14:05, 31 December 2008 (UTC) | ||
+ | |||
+ | Let's celebrated the last robot of this year: (please don't stole my position!, I know I can't post robot on 23:59:59) | ||
+ | <pre> | ||
+ | package nat.nano; | ||
+ | |||
+ | import robocode.AdvancedRobot; | ||
+ | import robocode.RobotDeathEvent; | ||
+ | import robocode.ScannedRobotEvent; | ||
+ | import robocode.util.Utils; | ||
+ | |||
+ | public class NewYear09 extends AdvancedRobot { | ||
+ | static double xForce; | ||
+ | static double yForce; | ||
+ | static String target; | ||
+ | |||
+ | public void run() { | ||
+ | setAdjustGunForRobotTurn(true); | ||
+ | turnRadarRightRadians(Double.POSITIVE_INFINITY); | ||
+ | } | ||
+ | |||
+ | public void onScannedRobot(ScannedRobotEvent e) { | ||
+ | double absoluteBearing, distance; | ||
+ | xForce = xForce | ||
+ | * .9 | ||
+ | - Math.sin((absoluteBearing = e.getBearingRadians() | ||
+ | + getHeadingRadians())) / (distance = e.getDistance()); | ||
+ | yForce = yForce * .9 - Math.cos(absoluteBearing) / distance; | ||
+ | setTurnRightRadians(Utils.normalRelativeAngle(Math.atan2(xForce + 1 | ||
+ | / getX() - 1 / (getBattleFieldWidth() - getX()), yForce + 1 | ||
+ | / getY() - 1 / (getBattleFieldHeight() - getY())) | ||
+ | - getHeadingRadians())); | ||
+ | setAhead(Double.POSITIVE_INFINITY); | ||
+ | setMaxVelocity(420 / getTurnRemaining()); | ||
+ | |||
+ | if ((target == null || target.equals(e.getName()) && getGunHeat() < 1)) { | ||
+ | target = e.getName(); | ||
+ | setTurnRadarLeftRadians(getRadarTurnRemaining()); | ||
+ | |||
+ | setTurnGunRightRadians(Utils.normalRelativeAngle(absoluteBearing | ||
+ | - getGunHeadingRadians() | ||
+ | + Math.asin(e.getVelocity() | ||
+ | * Math.sin(e.getHeadingRadians() - absoluteBearing) | ||
+ | / 12.5))); | ||
+ | |||
+ | if (setFireBullet(2.5D) != null) | ||
+ | target = null; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | public void onRobotDeath(RobotDeathEvent e) { | ||
+ | target = null; | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
+ | (RoboWiki is down so I can't enter RoboRumble) | ||
+ | |||
+ | This robot move [[Anti-Gravity Movement]] (the [[DustBunny]] One) and fire [[LinearTargeting]]. The enemy choosing is one from [[SwodniwMR]]. | ||
+ | |||
+ | --[[User:Nat|Nat]] 14:41, 31 December 2008 (UTC) |
Revision as of 15:41, 31 December 2008
I guess it's also time to start this page too :) http://www.timeanddate.com/counters/multicountdown.html has countdown to the New Year (In one place it's about 5 hours left :O, where i live is about 27 hours) Also, the Chronicle of 2008 --Starrynte 04:24, 31 December 2008 (UTC)
OK, many place (but not my place) had enter 2009. 10 hours left (UTC), use it at your own risk! (I think I will write a last nano-bot of this year :)) This page is hard to find (if you don't look at Recent changes link :)). -- Nat 14:05, 31 December 2008 (UTC)
Let's celebrated the last robot of this year: (please don't stole my position!, I know I can't post robot on 23:59:59)
package nat.nano; import robocode.AdvancedRobot; import robocode.RobotDeathEvent; import robocode.ScannedRobotEvent; import robocode.util.Utils; public class NewYear09 extends AdvancedRobot { static double xForce; static double yForce; static String target; public void run() { setAdjustGunForRobotTurn(true); turnRadarRightRadians(Double.POSITIVE_INFINITY); } public void onScannedRobot(ScannedRobotEvent e) { double absoluteBearing, distance; xForce = xForce * .9 - Math.sin((absoluteBearing = e.getBearingRadians() + getHeadingRadians())) / (distance = e.getDistance()); yForce = yForce * .9 - Math.cos(absoluteBearing) / distance; setTurnRightRadians(Utils.normalRelativeAngle(Math.atan2(xForce + 1 / getX() - 1 / (getBattleFieldWidth() - getX()), yForce + 1 / getY() - 1 / (getBattleFieldHeight() - getY())) - getHeadingRadians())); setAhead(Double.POSITIVE_INFINITY); setMaxVelocity(420 / getTurnRemaining()); if ((target == null || target.equals(e.getName()) && getGunHeat() < 1)) { target = e.getName(); setTurnRadarLeftRadians(getRadarTurnRemaining()); setTurnGunRightRadians(Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians() + Math.asin(e.getVelocity() * Math.sin(e.getHeadingRadians() - absoluteBearing) / 12.5))); if (setFireBullet(2.5D) != null) target = null; } } public void onRobotDeath(RobotDeathEvent e) { target = null; } }
(RoboWiki is down so I can't enter RoboRumble)
This robot move Anti-Gravity Movement (the DustBunny One) and fire LinearTargeting. The enemy choosing is one from SwodniwMR.
--Nat 14:41, 31 December 2008 (UTC)