A form of movement in which the direction to move is partly or entirely determined by a pseudorandom number generator (e.g.
Math.random()). This is a method to make it harder for your opponent to predict the future position of the bot based on its previous behaviour.
- Completely random, ignoring everything.
- As a type of perpendicular movement, like RandomMovementBot.
- Picking random points in your EscapeArea, like Marshmallow.
Works in the following way:
* You calculate how long it would take for an enemy shot to hit you. * You pick some new random coordinates close enough to reach them in the given time frame. * You move to the new position.
Of course, you must have a clever strategy to select your new coordinates. A completely random movement means that at least 1/4 of times you move almost-straight to the enemy, and 1/4 you follow an almost-linear path, so you are easy to hit. Also, corners and preferred distance must be taken into account. Adding some criteria to filter the possible destinations and selecting a good one is the key for a good random movement.
Case Study : Marshmallow
The gunner must eventually always choose an angle for shooting and that this angle should be hard to predict if the target can manage to make it random. Marshmallow tries to figure out the EscapeArea it has available - you can't go past walls and travelling to straight towards or away from the gunner is seldom a good idea. Then Marshmallow chooses a random angle perpendicular to the enemy within this escape area. The escape area varies in size also with the power of the bullet fired so this is also taken into account.
When you start randomizing your velocity, you probably do it on a random interval, say once in 5 till 20 ticks and not randomize every single frame. Since your acceleration/deceleration are limited, and thus you end up not being so 'random' on average if you change it every tick. (E.g., if you "randomize" from velocity 8 to 0 for a single frame, you'll actually just decelerate to 6 for one frame and then randomize again.)
Also it seems wise to randomize from velocity 2 to 12 instead of 0 to 8. Everything higher than 8 will be cut off to 8, so a large part of the time you will travel at fullspeed.