Difference between revisions of "Random Movement"

From Robowiki
Jump to navigation Jump to search
(→‎Random Destinations: Fixed Another Marshmallow link)
m (Add notice)
 
Line 1: Line 1:
 +
{{cleanup}}
 +
 
A form of [[movement]] in which the direction to move is partly or entirely determined by a pseudorandom number generator (e.g. <code>Math.random()</code>). This is a method to make it harder for your opponent to predict the future position of the bot based on its previous behaviour.
 
A form of [[movement]] in which the direction to move is partly or entirely determined by a pseudorandom number generator (e.g. <code>Math.random()</code>). This is a method to make it harder for your opponent to predict the future position of the bot based on its previous behaviour.
  

Latest revision as of 03:41, 25 October 2017

This article may require cleanup to meet RoboWiki's quality standards.
Please improve this article if you can.

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.

Random Destinations

Completely random

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.

Versions 0.9.9.x of Marshmallow also kept book on what angles it had ended up in (using VirtualBullets) and favoured segments with lower frequencies.

Random Velocities

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.

See Also