Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Source code / algorithm question - generation of mines level

15 views
Skip to first unread message

Janis Papanagnou

unread,
Oct 7, 2022, 8:42:50 PM10/7/22
to
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
0 new messages