Battle City Series 7- scanning policies and strategic analysis of mobile strategy

 

Foreword

This part describes how to Robocode enemy to scan in order to better scan results by changing their movement and attack.

Scanning Strategy

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 = enemy absolute angle - Radar direction

2. setTurnRadarRightRadians( RadarOffset * 1.2 );

Mobile Strategy

There are many ways to move, you can set your own moves according to the opponent, such as:

1. obvious regular exercise:

Movement around the walls

2. very random movement:

crazy case of tanks official.

3. There are active movement aimed at disturbing:

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, after the enemy to realize that there is a law of motion, I changed the original kind, to confuse enemy.

4. based on other rounds or movement taken by passive movement

This kind of situation can lead to Robot how to avoid attacks, and how to set their own strategies aimed at (the next one will explain).

To avoid attacks:

Tanks very limited understanding of the surrounding environment. However, it can not see the bullets. However, due to the other party a bullet fired their energy will be reduced by determining changes in each other's energy level, or can know whether the other side is firing bullets. (Typically singled mode)

Example:

1. public void onScannedRobot(ScannedRobotEvent e)

2. {// previousEnergy previous time recording energy

3. double changeInEnergy = previousEnergy - e.getEnergy();

4.  IF (changeInEnergy> 0 && changeInEnergy <=. 3) {// other energy change

5. // escape!

6. turnLeft (90 - e.getBearing ()); // the steering direction side in the direction of bullets

7. setAhead ((e.getDistance () / 4 + 25)); // advance to avoid the bullet

8. }

9. previousEnergy = e.getEnergy();

10. }

 

Well, this issue on here myself, I will not play games but have to write games Chen, together to learn JAVA now!

 

Guess you like

Origin www.cnblogs.com/qfchen/p/11245938.html