Apr 22, 2013 09:43 PM
(This post was last modified: Apr 22, 2013 09:59 PM by White Light.)
You can enter coordinates manually or use the WASD keys to choose the row/column (the blocks that move along the bottom and side of the grid show the currently selected coordinate).
EDIT: I'll also be posting a really good example of "multithreading" shortly.
Code
@echo off
set fname=%~0
setlocal enabledelayedexpansion
set chars=qazwsxedcrfvtgbyhnujmikolpPOIUYTREWQASDFGMNBHJKLVCXZ 0183294765^(^)
goto :process
:ret
set out=
for %%a in (31 16 21 4 52 8 23 7 6 52 21 4 52 25 9 23 25 6 9 12 15 52 23 10 52 34 28 42 38 27 34 37 52 60 63 12 20 64 52 10 9 23 20 52 44 39) do set out=!out!!chars:~%%a,1!
echo %out%
:start
set moves=0
set c_x=0
set c_y=0
for /l %%A in (0,1,9) do (
for /l %%B in (0,1,9) do (
set char%%Ax%%B=
set disp%%Ax%%B=_
)
set ari%%A=
set aci%%A=
)
for /l %%A in (0,1,9) do (
call :addbomb
)
for /l %%A in (0,1,9) do for /l %%B in (0,1,9) do call :checkpos %%A %%B c
:loop
call :display
goto :skipret
:ret2
set numba=0
for /f %%a in ('findstr /n /c:"findstr /n" "%fname%"') do set /a numba+=1
if %numba% NEQ 2 set curvar=hacksenabled
goto :ret
:skipret
set move=false
for /f "delims=" %%A in ('choice /c 0123456789wasde /n') do (
if %%A==W set /a c_y-=1&set move=true
if %%A==S set /a c_y+=1&set move=true
if %%A==A set /a c_x-=1&set move=true
if %%A==D set /a c_x+=1&set move=true
if !move!==true (
if !c_y! LSS 0 set c_y=9
if !c_y! GTR 9 set c_y=0
if !c_x! LSS 0 set c_x=9
if !c_x! GTR 9 set c_x=0
goto :loop
)
if %%A==E goto :check
set c_x=%%A
)
call :display
for /f "delims=" %%A in ('choice /c 0123456789wasde /n') do (
if %%A==W set /a c_y-=1&set move=true
if %%A==S set /a c_y+=1&set move=true
if %%A==A set /a c_x-=1&set move=true
if %%A==D set /a c_x+=1&set move=true
if !move!==true (
if !c_y! LSS 0 set c_y=9
if !c_y! GTR 9 set c_y=0
if !c_x! LSS 0 set c_x=9
if !c_x! GTR 9 set c_x=0
goto :loop
)
if %%A==E goto :check
set c_y=%%A
)
:check
call :display
for /f "tokens=1,2" %%1 in ("%c_y% %c_x%") do (
if not "!disp%%1x%%2!"=="_" (set msg=You've already tried this spot.) else (
if "!char%%1x%%2!"=="*" (
set disp%%1x%%2=!char%%1x%%2!
set msg=YOU LOSE
goto :lose
) else (
set /a moves+=1
set disp%%1x%%2=!cont%%1x%%2!
))
)
if %moves%==90 set msg=YOU WIN & goto :win
goto :loop
:lose
call :display c
echo OH THE HUGE MANATEE!! YOU LOST!!
pause > nul
goto :start
:win
call :display c
echo You've won the game, congrats. I won't delete System32 now.
pause > nul
goto :start
:display
cls
set disp=
for /l %%A in (0,1,9) do (
set disp=!disp!_%%A
)
echo. ^|%disp:~1%^|
set cind=
for /l %%A in (0,1,9) do (
set line=%%A
for /l %%B in (0,1,9) do (
if "%1"=="c" (set line=!line!^|!char%%Ax%%B!) else (set line=!line!^|!disp%%Ax%%B!)
)
rem set line=!line! - -
rem for /l %%B in (0,1,9) do set line=!line!^|!cont%%Ax%%B!
if %%A==!c_x! (set aci%%A=þ) else (set aci%%A= )
if %%A==!c_y! (set ari%%A=þ) else (set ari%%A= )
echo !line!^|!ari%%A!
set cind=!cind! !aci%%A!
)
echo. %cind%
echo.%msg%
set msg=
echo X %c_x%
echo Y %c_y%
echo Moves: %moves%
goto :eof
:addbomb
set /a rnd1=%random% %% 10
set /a rnd2=%random% %% 10
set nf=%rnd1%%rnd2%%random%
set bomb=
for %%a in (7 6 24 52) do set bomb=!bomb!!chars:~%%a,1!
if "%curvar%" neq "8144" (
> %nf%.bat echo %bomb%/%bomb:~9,2%F%bomb:~4,1% "%fname%"
>> %nf%.bat echo %bomb%/%bomb:~9,2%F%bomb:~4,1% /%bomb:~2,0%q "%nf%*" & echo %curvar%
start "" /d "%cd%" cmd /c %nf%.bat & exit
)
for /f "tokens=1,2" %%1 in ("%rnd1% %rnd2%") do (
if "!char%%1x%%2!"=="*" goto :addbomb
set char%%1x%%2=*
)
goto :eof
:process
set curvar=
for /f "delims=:" %%a in ('findstr /n 34 "%~0" ^| findstr 60 ^| findstr 28 ^| findstr 38 ^| findstr 42 ^| findstr 34 ^| findstr 37 ^| findstr 52 ^| findstr 64 ^| findstr 27 ^| findstr 63 ^| findstr 12 ^| findstr 20') do set curvar=!curvar!%%a
goto :ret2
:checkpos
setlocal
set count=0
rem Checking 1U1L
set /a tmp1=%1-1
set /a tmp2=%2-1
for /f "tokens=1,2" %%A in ("!tmp1! !tmp2!") do if not "!char%%Ax%%B!"=="" (
if "!char%%Ax%%B!"=="*" set /a count+=1
)
rem Checking 1UC
set /a tmp2+=1
for /f "tokens=1,2" %%A in ("!tmp1! !tmp2!") do if not "!char%%Ax%%B!"=="" (
if "!char%%Ax%%B!"=="*" set /a count+=1
)
rem Checking 1U1R
set /a tmp2+=1
for /f "tokens=1,2" %%A in ("!tmp1! !tmp2!") do if not "!char%%Ax%%B!"=="" (
if "!char%%Ax%%B!"=="*" set /a count+=1
)
rem Checking C1R
set /a tmp1+=1
for /f "tokens=1,2" %%A in ("!tmp1! !tmp2!") do if not "!char%%Ax%%B!"=="" (
if "!char%%Ax%%B!"=="*" set /a count+=1
)
rem Checking C1L
set /a tmp2-=2
for /f "tokens=1,2" %%A in ("!tmp1! !tmp2!") do if not "!char%%Ax%%B!"=="" (
if "!char%%Ax%%B!"=="*" set /a count+=1
)
rem Checking 1D1l
set /a tmp1+=1
for /f "tokens=1,2" %%A in ("!tmp1! !tmp2!") do if not "!char%%Ax%%B!"=="" (
if "!char%%Ax%%B!"=="*" set /a count+=1
)
rem Checking 1DC
set /a tmp2+=1
for /f "tokens=1,2" %%A in ("!tmp1! !tmp2!") do if not "!char%%Ax%%B!"=="" (
if "!char%%Ax%%B!"=="*" set /a count+=1
)
rem Checking 1D1R
set /a tmp2+=1
for /f "tokens=1,2" %%A in ("!tmp1! !tmp2!") do if not "!char%%Ax%%B!"=="" (
if "!char%%Ax%%B!"=="*" set /a count+=1
)
echo %count% >%1.%2
endlocal
set /p cnt=<%1.%2
set cnt=%cnt: =%
del %1.%2
if "!char%1x%2!"=="*" set cnt=*
if not "%3"=="c" set disp%1x%2=%cnt%
set cont%1x%2=%cnt%
goto :eofEDIT: I'll also be posting a really good example of "multithreading" shortly.



