Nekoninja1.3 original analysis
Author: iiley
Package myl.micro; import robocode. *; import java.awt.color; import java.awt.geom.point2d; / ** * Nekoninja - a ninja by martin y lepsoy at mlepsoy@yahoo.no * * 18.12.2002 - Version 1.30 -. codesize 745 * * Now even the gun is based on the, soon to be released, Predator 1.50 A pattern analyzer that actually works * Is extremely hard to hit constantly * Even SandBoxDT 1.61 and Duelist 0.1.6 will have a. hard time predicting where it will go next time * This copy readable, but codesize too big Download the released version from www.robocoderepository.com * * * 15.12.2002 -. Version 1.20 - codesize 618 * * Completely new robot, now only specializes in 1v1 combat * Aim is a random amount of calculated aim at a distance over 400 * No dodging anymore, movement based on Predator's successful movement * * * 09.11.2002 - Version 1.1 - codesize 542 * * New radar management: The radar spins while We are tracking the closest target * aim with average velocity * New Dodging, Better and LESS Predictable (I think) * Won't get slaughtered in Melee Like Before :) * * * 14.10.2002 - Version 1.0 - Codesize 534 * * Nekoninja Is A 1V1 Specialist * * / / ** * Nekoninjia is At present, the world is recognized as the best 1V1 microBot, of which all version is the best in all versions (the author all admits) * His feature is that the sports use random motion, shooting mode analysis * Because it is Microbot, affected by Codesize < The limitations of 750, so the code writes very streamlined (this is almost all MINI, Micro, Nano BOT's common feature) * So a lot of difficulties have been brought to the original code analysis, plus the analyter level is limited, analysis errors are here Improvisible, welcome to readers to criticize the correct. :) * Analysis Description: The authors of the author have retained, some basic, simple and easy-to-understand (such as setadjustradarforgunturn (TRUE); * setcolors (C, New Color (162, 244, 89)); this statement is not analyzed, mainly analyzed the author's design ideas.
---- * Analysis by: iiley * / public class NekoNinjaReadableVersion extends AdvancedRobot {static double nextMove; // the time before our next move final static int storedInfo = 800; // how many frames we store in our pattern analyzer //. not too large to get fresh details on target quickly, // but large enough to remember the opponents behavior a little while static double [] [] pattern = new double [storedInfo] [4]; // all stored info about our enemy public void run () {setAdjustRadarForGunTurn (true); setAdjustGunForRobotTurn (true); Color c = Color.darkGray.brighter (); setColors (c, c, new Color (162, 244, 89)); // new and better ninja colors :-P While (True) {Turnradarrightradians (Doubl e.POSITIVE_INFINITY); // turn radar to find a target}} public void onScannedRobot (ScannedRobotEvent e) {int time = (int) getTime ()% storedInfo; // store time to save codesize double targetBearing = getHeadingRadians () e .getBearingradians (); double our = getX (); // store own coordinates Double ure = get (); // - "- Double FirePower = Math.min (3, 30 * getnergy () / E.GetDistance ()) // PowerSaving When Far from target and low ready ///movement code / ** * Find a little as a sport point in the venue (this is not too close to the wall, and if you want to pass this, I The need to use the direction to meet the difference between the direction that is currently moving is too much *, it is to be>
Minimumanglediference, can also be too small in the direction of the enemy, to be> 2 * minimumanglediference, meaning
Minimumangledifference is a number of ourselves, because it is a test and a plug, why is it related to A, that is, why? The smaller it is, the smaller it? Because if you can't find the angle of the condition? Then, the restriction is due to the small number) * nextmove = E.GETDISTANCE () / (29 - 3 * firepower); if (nextmove- <= 0) means changing when the enemy's second bullet is coming Motion target point * / if (nextmove- <= 0) {// it's time to make our next move for (double a = 0; a <500; a ) {double testx = math.random () * getBattlefieldWidth () ; // Make Random Test Points Double Testy = Math.random () * getBattlefieldHeight (); // - "- Double disttttoall = Math.min (TestX, getBattlefieldWidth () - TestX) * Math.min (Testy, getBattlefieldHeight () - Testy); // Check The Product of the Distance To The Shortest Walls IF (Disttowall> 7600) {// Make Sure The Point Is With The Current Wall Tolerance (Which Is Always 7600 in This Bot Which Is Good for A 800 x 600 Battlefield) // Use Point if Angle To Point Is a certain amount from Angle To target Double Ourangletopoint = Getangle (OURX, Oury, TestX, Test Y); // angle to the testpoint double minimumAngleDifference = ((500 - a) / 500) * Math.PI / 6; // minimumAngleDifference is the smallest angle difference to accept if (Math.abs (angle_180 (targetBearing) - ourAngleToPoint )> 2 * minimumangledifference && math.abs (Angle_180 (GetHeadingradians ()) - OURANGLETOPOINT> minimumanglediference) {Double Turnangle =
angle_180 (getAngle (ourX, ourY, testX, testY) - getHeadingRadians ()); // calculate angle to turn to next point // decide which direction to go to reach our point as soon as possible double moveDirection = 1; // use Front if next check is false if (math.abs (turnangle)> math.pi / 2) {// if ny ies limited = - 1; // switch direction turnangle = math.acos (moveDirection); // and change turnangle acordingly} setTurnRightRadians (angle_180 (turnAngle)); // make turn setAhead (moveDirection * Point2D.Double.distance (ourX, ourY, testX, testY)); // move towards point break; }}} // make nextmove a little before a bullet Will R each you next time nextMove = e.getDistance () / (29 - 3 * firePower);. // use own firePower here to save space The enemy is likely to use about the same power as us since firepower often is based on own energy } SetMaxVelocity (GetTurnRemaining ()> 45? 0.001: 8); // adjust velocity when turning to make sharpers // end of movement // Pattern Analyzer / ** * Shooting Policy main ideas is a record of 800 lengths Straight line advancement shooting strategy's predictionangle * Each record point records from your bullets to the enemy (the bullet assumes that the energy is 3, the enemy assumes that it is not moving, although this is not accurate, but can you know how the enemy knows how you know the enemy? move? If you know you still calculate? ) * Predictionangle's accumulation * When you need shooting, look for a history (
All previous record nodes are completed, and the most similar record node with the current Predictionangle (the most similarity of Predictionangle is the most similar), then the enemy's subsequent exercise is in the history The movement situation is very similar (that is, historical reproduction). * Find a place to be reproduced, then use the average Predictionangle in that history as a shooting angle shooting * * This shot method is to find a similar situation in history, so if your exercise is regular He can find out how you will go next step, then, you are hit a chance. This is the reason why the author's exercise uses a random movement.
* / Int match = 0; pattern [time] [0] = E.GETDISTANCE () / (20 - 3 * firepower); // Store Time Before We will use this Angle Iur Analyzer Pattern [Time] [1] = E.GetVelocity () * math.sin (E.GetHeadingradians () - TargetBearing; // store linear prediction angle / ** * pattern [time] [1] = E.GetVelocity () * math.sin (E.GetHeadingradians) () - TARGETBEARING); * Sinusoidal Theorem E.GetVelocity () / Math.sin (PREDICLE) == MybulletVelocity / Math.Sin (E.GetHeadingradians () - TargetBearing; * So Pattern [Time] [1] == MybulletVelocity * Math.sin (PREDiction); * That is to say pattern [Time] [1] recorded the shooting angle of the line advancement and its own bullet speed * / pattern [Time] [2] = pattern [Time] [3 ] = 0; // reset value used to store = 0; a
// Increase counter,} // In history (all records) Find a record point with the current MyBulletVelocity * Math.sin (Prediction) value (this record point must be accumulated) Pattern [A] [0] <0) // Record the array below of this record to for (int a = 0; a