So i'm working on a "Minesweeper level generator" and this is the code to set the text to be displayed in positions. (□ is Clear, O is a bomb (working on the number indicators))
for %%v in (a1,a2,a3,a4,a5,a6,a7,a8,b1,b2,b3,b4,b5,b6,b7,b8,c1,c2,c3,c4,c5,c6,c7,c8,d1,d2,d3,d4,d5,d6,d7,d8,e1,e2,e3,e4,e5,e6,e7,e8,f1,f2,f3,f4,f5,f6,f7,f8,g1,g2,g3,g4,g5,g6,g7,g8,h1,h2,h3,h4,h5,h6,h7,h8) do (
if %bombs% gtr 0 (if %random% gtr 16383 (set e_a1=O && set /a "bombs-=1") else (set e_%%v=□))
)
or this:
for %%v in (a1,a2,a3,a4,a5,a6,a7,a8,b1,b2,b3,b4,b5,b6,b7,b8,c1,c2,c3,c4,c5,c6,c7,c8,d1,d2,d3,d4,d5,d6,d7,d8,e1,e2,e3,e4,e5,e6,e7,e8,f1,f2,f3,f4,f5,f6,f7,f8,g1,g2,g3,g4,g5,g6,g7,g8,h1,h2,h3,h4,h5,h6,h7,h8) do (
set _r=
set /a "_r=(%RANDOM%*6/32768)+1"
if %bombs% gtr 0 (if %_r% gtr 3 (set e_a1=O && set /a "bombs-=1") else (set e_%%v=□))
)
It should work fine, but when I tried this out in cmd, I found that all the assigned random numbers are the same each time.
Why does it do that and how can I fix it?