Difference between revisions of "SetCoordinates randomizer"
Eric Walch (talk | contribs) (Randimization with setCoordinates) |
Eric Walch (talk | contribs) 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 | + | 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.: | e.g.: | ||
Line 13: | Line 14: | ||
or | or | ||
− | "setCoordinates: pwr | + | "setCoordinates: pwr rand:1 rand:1 6" |
− | This will set a point | + | 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]] | Return to: [[OXP_howto_AI]] |
Revision as of 09: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