Difference between revisions of "SetCoordinates randomizer"

From Elite Wiki
(Randimization with setCoordinates)
 
m
Line 1: Line 1:
 
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.
 
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.  
+
Giles added a possibility to introduce randomize numbers in 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.
+
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 1.
  
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.
+
Calculating a random function this way will give a truly random value with a starting value of one. The more random values you add the more likely it becomes to get a value near the center of 0.5
 +
So use is limited to coordinate systems were you can work with results between 0 and 1 but it still leaves some useful use.
  
 
e.g.:  
 
e.g.:  
Line 13: Line 14:
  
 
or
 
or
   "setCoordinates: pwr 0 0 rand:6"
+
   "setCoordinates: pwr rand:1 rand:1 6"
  
This will set a point between 0 and 6 planet radii on the witchSpaceEntryPoint to planet line.
+
This will set a point at 6 planet radii from he planet whit a deviation of maximal 1 planet radii on the line: witchSpaceEntryPoint to planet.
 
 
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]]
 
Return to: [[OXP_howto_AI]]

Revision as of 10:08, 1 November 2007

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 introduce randomize numbers in 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 1.

Calculating a random function this way will give a truly random value with a starting value of one. The more random values you add the more likely it becomes to get a value near the center of 0.5 So use is limited to coordinate systems were you can work with results between 0 and 1 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 rand:1 rand:1 6"

This will set a point at 6 planet radii from he planet whit a deviation of maximal 1 planet radii on the line: witchSpaceEntryPoint to planet.

Return to: OXP_howto_AI