Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Applevangelist 2024-07-12 08:09:39 +02:00
commit 6e917049af
2 changed files with 24 additions and 1 deletions

View File

@ -22,7 +22,7 @@
-- @module Functional.Mantis
-- @image Functional.Mantis.jpg
--
-- Last Update: May 2024
-- Last Update: July 2024
-------------------------------------------------------------------------
--- **MANTIS** class, extends Core.Base#BASE
@ -59,6 +59,7 @@
-- @field #number ShoradTime Timer in seconds, how long #SHORAD will be active after a detection inside of the defense range
-- @field #number ShoradActDistance Distance of an attacker in meters from a Mantis SAM site, on which Shorad will be switched on. Useful to not give away Shorad sites too early. Default 15km. Should be smaller than checkradius.
-- @field #boolean checkforfriendlies If true, do not activate a SAM installation if a friendly aircraft is in firing range.
-- @field #table FilterZones Table of Core.Zone#ZONE Zones Consider SAM groups in this zone(s) only for this MANTIS instance, must be handed as #table of Zone objects.
-- @extends Core.Base#BASE

View File

@ -4049,3 +4049,25 @@ function UTILS.ReadCSV(filename)
return csvdata
end
--- Seed the LCG random number generator.
-- @param #number seed Seed value. Default is a random number using math.random()
function UTILS.LCGRandomSeed(seed)
UTILS.lcg = {
seed = seed or math.random(1, 2^32 - 1),
a = 1664525,
c = 1013904223,
m = 2^32
}
end
--- Return a pseudo-random number using the LCG algorithm.
-- @return #number Random number between 0 and 1.
function UTILS.LCGRandom()
if UTILS.lcg == nil then
UTILS.LCGRandomSeed()
end
UTILS.lcg.seed = (UTILS.lcg.a * UTILS.lcg.seed + UTILS.lcg.c) % UTILS.lcg.m
return UTILS.lcg.seed / UTILS.lcg.m
end