JAVA fun of Battle City Series 7

Introduction
This part describes Robocode how to scan the enemy in order to better scanning results by changing their way of moving and ***.
Scanning strategies
The main objective of the scan strategy is better able to lock the other side, that is, let the enemy within our field of vision range, or use a more professional terms - radar lock.
In order to lock the target, we can put the radar scanning in the opposite direction. Because the radar rotation soon, radar and direction of the tank is not offset each other's direction, the robot is a certain size. So scan line sweep back and forth on the target to achieve a radar lock.
Code examples are as follows:
1.double RadarOffset = absolute angle enemy - direction of the radar  
2.setTurnRadarRightRadians (RadarOffset * 1.2); 
mobile strategy
displaceable manner there are many, can be set according to their way of moving the opponent, for example:
1 obviously regular exercise:
around the wall motion
2. very random movement:
official cases of crazy tanks.
3. There are active movement aimed at disturbing: the
first in an obvious regular exercise, etc. I was mistaken for the enemy after the kind of movement, immediately change to another law of motion, such as the movement of the enemy realize now after I was changed to the original kind, to confuse the enemy.
4. based on other rounds or movement taken by passive movement
of the case may lead to how to avoid the Robot ***, and how to set their own strategies aimed at (the next one to explain).
*** avoid:
Tanks very limited understanding of the surrounding environment. However, it can not see ×××. However, due to the other party launch ××× own energy will be reduced, by determining changes in each other's energy level, or can know whether the other party is transmitting ×××. (Usually in the heads-up mode)
Example:
1.public void onScannedRobot (ScannedRobotEvent E)   
2 {// previousEnergy before a recording energy.  
3. Double changeInEnergy = previousEnergy - e.getEnergy ();  
4. IF (changeInEnergy> 0 && changeInEnergy <= 3) // other energy change {  
5 // escape!  
6. the TurnLeft (90 - e.getBearing ()); // the steering direction side in the direction ×××    
7. setAhead ((e.getDistance ( ) / 4 + 25)); // advance to avoid ×××            
8. The}  
9. The previousEnergy e.getEnergy = ();  
10. The}  

Guess you like

Origin blog.51cto.com/14256902/2423596