Source code / algorithm question - generation of mines level
From
Janis Papanagnou@21:1/5 to
All on Sat Oct 8 02:42:46 2022
Maybe a too specific question for this newsgroup? - Anyway, I try...
I've inspected the mines levels generation in the source code, here specifically function pass_one() in file mkmap.c, where the random
initialized level data is algorithmically manipulated (in sort of a
Conway's "Game of Life" manner); the random map data is sequentially
iterated and for each (x,y) element all adjacent neighbors are
counted to determine the new status of the actual (x,y) element.
The element test (get'ter) and the change (set'ter) functions work
both on the same levl[] array; that means that while iterating on
the array data is partly taken from the unchanged original random
elements and partly from elements already changed, so this results
in an asymmetric behavior of the algorithm. I wonder whether that
is intentional or an oversight. (Of course we can always say that
if the result looks fine we don't have to care. I'm curious anyway.)
Since there's no reference in the code where the algorithms stems
from it's hard to judge. Anyone out there (Pat?) who remembers these
details?
BTW, function pass_two() in the same file works - as I've expected
for pass_one() as well - on a temporary new_loc[].
PS: This part of the algorithm/code seems to be quite old; it can
be found in Slashem and NH-343 as well.
Janis
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)