selectBestPlaces: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "_{10,} " to "")
(Fix formula)
 
(54 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command


| arma2 |Game name=
|game1= arma2
|version1= 1.00


|1.00|Game version=
|game2= arma2oa
|version2= 1.50


|gr1= Mission Information |GROUP1=
|game3= tkoh
|version3= 1.00


| Find the places with the maximum value of ''expression'' in the given area. Places can be on water. Results are sorted by value. Search pattern is randomised every command execution. |DESCRIPTION=
|game4= arma3
|version4= 0.50


| [[selectBestPlaces]] [position, radius, expression, precision, sourcesCount] |SYNTAX=
|gr1= Mission Information


|p1= position: [[Object]], [[Position3D]] or [[Position2D]]|PARAMETER1=
|descr= Find the places with the maximum value of ''expression'' in the given area. Places can be on water. Results are sorted by value. Search pattern is randomised every command execution.


|p2= radius: [[Number]]|PARAMETER2=
|s1= [[selectBestPlaces]] [position, radius, expression, precision, sourcesCount]


|p3= expression: [[String]] - Arithmetic expression. Simple expression var names containing values from 0 to 1 depending on location (see also [[Ambient Parameters]]):
|p1= position: [[Object]], [[Position#Introduction|Position3D]] or [[Position#Introduction|Position2D]]
 
|p2= radius: [[Number]]
 
|p3= expression: [[String]] - arithmetic expression. [[Simple_Expression|Simple expression]] var names containing values from 0 to 1 depending on location (see also [[Ambient Parameters]]):
{{Columns|5|
* forest
* forest
* trees
* trees
Line 22: Line 31:
* houses
* houses
* sea
* sea
* coast
* night
* night
* rain
* rain
Line 27: Line 37:
* deadBody
* deadBody
* waterDepth
* waterDepth
* camDepth |PARAMETER3=
* camDepth
 
}}
|p4= precision: [[Number]]|PARAMETER4=


|p5= sourcesCount: [[Number]] - max results to return. '''maximum 50''' |PARAMETER5=
|p4= precision: [[Number]]


| [[Array]] - in Format <nowiki>[[position: </nowiki>[[Position2D]]<nowiki>, expressionResult: </nowiki>[[Number]]<nowiki>], ...]</nowiki> |RETURNVALUE=
|p5= sourcesCount: [[Number]] - max results to return. The maximum possible is the number of random samples, which is '''n = (2 * radius / precision)^2'''


|x1= <code>myPlaces = [[selectBestPlaces]] [<nowiki/>[[position]] [[player]], 50, "meadow + 2*hills", 1, 5];</code>|EXAMPLE1=
|r1= [[Array]] in format [<nowiki/>[position: [[Position#Introduction|Position2D]], expressionResult: [[Number]]], ...]


| [[getEnvSoundController]], [[getAllEnvSoundControllers]], [[findEmptyPosition]], [[isFlatEmpty]], [[Ambient Parameters]] |SEEALSO=
|x1= <sqf>myPlaces = selectBestPlaces [position player, 50, "meadow + 2*hills", 1, 5];</sqf>


| |MPBEHAVIOUR=
|seealso= [[getEnvSoundController]] [[getAllEnvSoundControllers]] [[findEmptyPosition]] [[isFlatEmpty]] [[Ambient Parameters]]
}}
}}


<h3 style='display:none'>Notes</h3>
{{Note
<dl class='command_description'>
|user= Rübe
<!-- Note Section BEGIN -->
|timestamp= 20100717183900
<dd class="notedate">
|text= see http://forums.bistudio.com/showthread.php?t=93897 for some more information (though neither official, nor complete).
<dd class="notedate">Posted on Jul 17, 2010 - 18:39
The most important information is the list of useable keywords for the expression which is: '''forest, trees, meadow, hills, houses, sea, night, rain, windy''' and '''deadBody'''.
<dt class="note">[[User:Rübe|Rübe]]
The keyword will be replaced by the actual value at the given sample position and thus the expression gets evaluated.
<dd class="note">see http://forums.bistudio.com/showthread.php?t=93897 for some more information (though neither official, nor complete). The most important information is the list of useable keywords for the expression which is: '''forest, trees, meadow, hills, houses, sea, night, rain, windy''' and '''deadBody'''. The keyword will be replaced by the actual value at the given sample position and thus the expression gets evaluated. For example the following expression (which returns high values in forest) ''"forest + trees - meadow - houses - (10 * sea)"'' might be transformed to ''0 + 0.1 - 0.7 - 0 - (10 * 0)'' which is - with it is result of -0.6 - not in the forest, though there are some tree(s) around. You get the idea.<br>
For example the following expression (which returns high values in forest) ''"forest + trees - meadow - houses - (10 * sea)"'' might be transformed to ''0 + 0.1 - 0.7 - 0 - (10 * 0)'' which is - with it is result of -0.6 - not in the forest, though there are some tree(s) around. You get the idea.<br>
Also note that you may aswell check such an expression value at a single position by passing a low radius and a sourceCount of 1, which is often just as useful as retrieving multiple (and already sorted) positions.<br>
Also note that you may aswell check such an expression value at a single position by passing a low radius and a sourceCount of 1, which is often just as useful as retrieving multiple (and already sorted) positions.<br>
Also do not underestimate the keywords ''night'', ''rain'' or ''windy'', for if you couple them with the other keywords, you can easily get a highly dynamic system at a very low cost. (this, btw., is how animals "choose" where and when to spawn)
Also do not underestimate the keywords ''night'', ''rain'' or ''windy'', for if you couple them with the other keywords, you can easily get a highly dynamic system at a very low cost.
(this, btw., is how animals "choose" where and when to spawn)
}}


<dd class="notedate">Posted on Apr 3, 2014 - 16:10
{{Note
<dt class="note">[[User:ffur2007slx2_5|ffur2007slx2_5]]
|user= ffur2007slx2_5
<dd class="note">
|timestamp= 20140403161000
In ArmA3 ver 1.14 Two new expressions are available: '''waterDepth'''(0-1) and '''camDepth'''(0-1), along with three simple operators: '''interpolate''', '''randomGen''' and '''factor''' that can be used together with expressions. E.g.
|text= In {{arma3}} ver 1.14 Two new expressions are available: '''waterDepth'''(0-1) and '''camDepth'''(0-1), along with three simple operators: '''interpolate''', '''randomGen''' and '''factor''' that can be used together with expressions. E.g.
<code>
<sqf>
p = selectBestPlaces [
p = selectBestPlaces [
  position player,
position player,
  500,
500,
  "(2 * (waterDepth interpolate [1,16,0,1]) * ((0.1+houses factor [0.1,0.8]) * (randomGen 1 + houses)))",
"(2 * (waterDepth interpolate [1,16,0,1]) * ((0.1+houses factor [0.1,0.8]) * (randomGen 1 + houses)))",
  1,
1,
  1];
1
</code>
];
</sqf>
'''A'''lgorithm randomGen:
'''A'''lgorithm randomGen:
<code>
<code style="display: block">randomGen A(number): randomly generate a float number from 0 - A</code>
randomGen A(number): randomly generate a float number from 0 - A
</code>
'''A'''lgorithm factor:
'''A'''lgorithm factor:
<code>
<code style="display: block">A(number) factor [p,q] =  
A(number) factor [p,q] =  
p< A <q: [(A -p)/(q-p)]
p< A <q: [(A -p)/(q-p)]
</code>
</code>
'''A'''lgorithm interpolate:
'''A'''lgorithm interpolate:
<code>
<code style="display: block">A(number) interpolate [p,q,r,s] =  
A(number) interpolate [p,q,r,s] =  
A <=p:r
A <=p:r
A >=q:s
A >=q:s
p< A <q: [(A -p)/(q-p)]*(s-r) +r
p< A <q: [(A -p)/(q-p)]*(s-r) +r
</code>
</code>
<!-- Note Section END -->
}}
</dl>


<h3 style='display:none'>Bottom Section</h3>
{{Note
 
|user= Killzone_Kid
{{GameCategory|arma2|Scripting Commands}}
|timestamp= 20150615132700
{{GameCategory|arma3|Scripting Commands}}
|text= ''precision'' seems to have range 0 - 100. At very low values the command is extremely slow. 100 makes it quite fast. It looks like ''precision'' is some kind of grid search size.
{{GameCategory|tkoh|Scripting Commands}}
Large chunks make the search faster but less accurate. <br><br>
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
Resulting array is [] if ''sourcesCount'' is 0 or '' expression'' is "". In all other cases it seems that result is array of arrays of the set max count.
The sole indication of successful search is ''expressionResult'' value when it is > 0.
}}


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Tankbuster
<dd class="notedate">Posted on June 15, 2015 - 13:27 (UTC)</dd>
|timestamp= 20170604205100
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
|text= Results are sorted by value, that is, the result of the expression.
<dd class="note">
''precision'' seems to have range 0 - 100. At very low values the command is extremely slow. 100 makes it quite fast. It looks like ''precision'' is some kind of grid search size. Large chunks make the search faster but less accurate. <br><br>
Resulting array is [] if ''sourcesCount'' is 0 or '' expression'' is "". In all other cases it seems that result is array of arrays of the set max count. The sole indication of successful search is ''expressionResult'' value when it is > 0.
</dd>
 
<dd class="notedate">Posted on June 4, 2017 - 20:51 (UTC)</dd>
<dt class="note">[[User:Tankbuster|Tankbuster]]</dt>
<dd class="note">
Results are sorted by value, that is, the result of the expression.
They are sorted in descending order, so in the case of waterdepth, the deepest water will be found at the locations at the start of the returned array and the shallowest water will be found at the locations at the end.
They are sorted in descending order, so in the case of waterdepth, the deepest water will be found at the locations at the start of the returned array and the shallowest water will be found at the locations at the end.
</dd>
}}
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 08:52, 5 December 2023

Hover & click on the images for description

Description

Description:
Find the places with the maximum value of expression in the given area. Places can be on water. Results are sorted by value. Search pattern is randomised every command execution.
Groups:
Mission Information

Syntax

Syntax:
selectBestPlaces [position, radius, expression, precision, sourcesCount]
Parameters:
position: Object, Position3D or Position2D
radius: Number
expression: String - arithmetic expression. Simple expression var names containing values from 0 to 1 depending on location (see also Ambient Parameters):
  • forest
  • trees
  • meadow
  • hills
  • houses
  • sea
  • coast
  • night
  • rain
  • windy
  • deadBody
  • waterDepth
  • camDepth
precision: Number
sourcesCount: Number - max results to return. The maximum possible is the number of random samples, which is n = (2 * radius / precision)^2
Return Value:
Array in format [[position: Position2D, expressionResult: Number], ...]

Examples

Example 1:
myPlaces = selectBestPlaces [position player, 50, "meadow + 2*hills", 1, 5];

Additional Information

See also:
getEnvSoundController getAllEnvSoundControllers findEmptyPosition isFlatEmpty Ambient Parameters

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Rübe - c
Posted on Jul 17, 2010 - 18:39 (UTC)
see http://forums.bistudio.com/showthread.php?t=93897 for some more information (though neither official, nor complete). The most important information is the list of useable keywords for the expression which is: forest, trees, meadow, hills, houses, sea, night, rain, windy and deadBody. The keyword will be replaced by the actual value at the given sample position and thus the expression gets evaluated. For example the following expression (which returns high values in forest) "forest + trees - meadow - houses - (10 * sea)" might be transformed to 0 + 0.1 - 0.7 - 0 - (10 * 0) which is - with it is result of -0.6 - not in the forest, though there are some tree(s) around. You get the idea.
Also note that you may aswell check such an expression value at a single position by passing a low radius and a sourceCount of 1, which is often just as useful as retrieving multiple (and already sorted) positions.
Also do not underestimate the keywords night, rain or windy, for if you couple them with the other keywords, you can easily get a highly dynamic system at a very low cost. (this, btw., is how animals "choose" where and when to spawn)
ffur2007slx2_5 - c
Posted on Apr 03, 2014 - 16:10 (UTC)
In Arma 3 ver 1.14 Two new expressions are available: waterDepth(0-1) and camDepth(0-1), along with three simple operators: interpolate, randomGen and factor that can be used together with expressions. E.g.
p = selectBestPlaces [ position player, 500, "(2 * (waterDepth interpolate [1,16,0,1]) * ((0.1+houses factor [0.1,0.8]) * (randomGen 1 + houses)))", 1, 1 ];
Algorithm randomGen: randomGen A(number): randomly generate a float number from 0 - A Algorithm factor: A(number) factor [p,q] = p< A <q: [(A -p)/(q-p)] Algorithm interpolate: A(number) interpolate [p,q,r,s] = A <=p:r A >=q:s p< A <q: [(A -p)/(q-p)]*(s-r) +r
Killzone_Kid - c
Posted on Jun 15, 2015 - 13:27 (UTC)
precision seems to have range 0 - 100. At very low values the command is extremely slow. 100 makes it quite fast. It looks like precision is some kind of grid search size. Large chunks make the search faster but less accurate.

Resulting array is [] if sourcesCount is 0 or expression is "". In all other cases it seems that result is array of arrays of the set max count. The sole indication of successful search is expressionResult value when it is > 0.
Tankbuster - c
Posted on Jun 04, 2017 - 20:51 (UTC)
Results are sorted by value, that is, the result of the expression. They are sorted in descending order, so in the case of waterdepth, the deepest water will be found at the locations at the start of the returned array and the shallowest water will be found at the locations at the end.