diff --git a/Moose Development/Moose/Functional/Mantis.lua b/Moose Development/Moose/Functional/Mantis.lua index b6d711964..dcc46f293 100644 --- a/Moose Development/Moose/Functional/Mantis.lua +++ b/Moose Development/Moose/Functional/Mantis.lua @@ -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 diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 842c94df9..817f7cb77 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -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 +