SetCoordinates randomizer

From Elite Wiki
Revision as of 23:34, 31 October 2007 by Eric Walch (talk | contribs) (Randimization with setCoordinates)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Oolites AI function setCoordinates: needs 4 parameters separated with a space, like: "setCoordinates: wpu 0 0 0.8" what means a point at 80% of the line witchSpaceEntryPoint to planet.

Giles added a possibility to randomize each of the coordinates separately. For this you must add a "rand:" in front of the coordinate without an additional space.

rand: is a function with a lot of limitations. It first turns the number into an integer. Then calculates that many random numbers as the value of the integer is large. It adds all the random numbers and divides the answer by the original integer. This gives as result a real value between 0 and the original integer value.

Because the way it is calculated you shouldn't use a metric coordinate system as for a value of 20000 he has to calculate 20000 random numbers. This slows things down. You also cant use negative numbers. You also can't use numbers smaller that 1 as it only uses integers. So use is limited but it still leaves some useful use.

e.g.:

 "setCoordinates: wpu 0 0 rand:1"

This will set a random coordinate anywhere on the line witchSpaceEntryPoint to planet.

or

 "setCoordinates: pwr 0 0 rand:6"

This will set a point between 0 and 6 planet radii on the witchSpaceEntryPoint to planet line.

or

 "setCoordinates: pwr rand:1 rand:1 rand:6"

This will set a point between 0 and 6 planet radii whit a deviation of maximal 1 planet radii on the witchSpaceEntryPoint to planet line.

Return to: OXP_howto_AI