Help:Script Samples: Difference between revisions

Content deleted Content added
No edit summary
Line 147:
<pre>
&lt;syntaxhighlight lang="cpp"&gt;
double AttackerSuccessProbability(double q, int z)
(define-behavior (bounce
{
:start-when (or (bump?)
double p = 1.0 - q;
bounce-trigger? )
double lambda = z :abort-when* (bump-edge?q / p);
double sum = :onetime? t1.0;
int i, )k;
for (k = 0; k <= z; k++)
)
{
double poisson = exp(-lambda);
for (i = 1; i <= k; i++)
poisson *= lambda / i;
sum -= poisson * (1 - pow(q / p, z - k));
}
return sum;
}
&lt;/syntaxhighlight&gt;
</pre>
|
<syntaxhighlight lang="cpp">
double AttackerSuccessProbability(double q, int z)
(define-behavior (bounce
{
:start-when (or (bump?)
double p = 1.0 - q;
bounce-trigger? )
double lambda = z :abort-when* (bump-edge?q / p);
double sum = :onetime? t1.0;
int i, )k;
for (k = 0; k <= z; k++)
)
{
double poisson = exp(-lambda);
for (i = 1; i <= k; i++)
poisson *= lambda / i;
sum -= poisson * (1 - pow(q / p, z - k));
}
return sum;
}
</syntaxhighlight>
| Use for smaller text blocks, if it is not desired that pre extend to the full width of the page