1
+ @ echo off & setlocal enableDelayedExpansion
2
+
3
+ call :set_font " lucida console" 2 nomax %1 || exit
4
+
5
+ call :macros
6
+ chcp 65001 > nul
7
+
8
+ set /a " wid = 250,hei = 150"
9
+ mode !wid! ,!hei!
10
+ set /a " rez = 6"
11
+ set /a " cols = 1 + wid / rez" , " rows = 1 + hei / rez - 1"
12
+
13
+ for /l %%i in (0,1,%cols% ) do for /l %%j in (0,1,%rows% ) do (
14
+ set /a " x = %%i * rez" , " y = %%j * rez"
15
+
16
+ REM set /a "1/(!random! %% 2)" && (
17
+ REM set "field[%%i ][%%j ]=0"
18
+ REM set "dots=!dots!%\e%[!y!;!x!H█"
19
+ REM ) || (
20
+ REM set "field[%%i ][%%j ]=1"
21
+ REM )
22
+ set /a " r = ! random! %% 100"
23
+ if !r! lss 50 (
24
+ set " field[%%i][%%j] = 1"
25
+ set " dots = !dots!%\e% [!y! ;!x! H█"
26
+ ) else (
27
+ set " field[%%i][%%j] = 0"
28
+ )
29
+ )2> nul
30
+
31
+ for /l %%i in (0,1,%cols% ) do (
32
+ for /l %%j in (0,1,%rows% ) do (
33
+ set /a " ti = %%i + 1,tj = %%j + 1"
34
+ set /a " a = field[%%i ][%%j ]" ,^
35
+ " b=field[!ti! ][%%j ]" ,^
36
+ " c=field[!ti! ][!tj! ]" ,^
37
+ " d=field[%%i ][!tj! ]" ,^
38
+ " state=a*8+b*4+c*2+d*1" ,^
39
+ " $a1=%%i * rez + rez / 2" , " $a2=%%j * rez" ,^
40
+ " $b1=%%i * rez + rez" , " $b2=%%j * rez + rez / 2" ,^
41
+ " $c1=%%i * rez + rez / 2" , " $c2=%%j * rez + rez" ,^
42
+ " $d1=%%i * rez" , " $d2=%%j * rez + rez / 2"
43
+
44
+ if !state! equ 1 ( %@line% !$c1! !$c2! !$d1! !$d2!
45
+ ) else if !state! equ 2 ( %@line% !$b1! !$b2! !$c1! !$c2!
46
+ ) else if !state! equ 3 ( %@line% !$b1! !$b2! !$d1! !$d2!
47
+ ) else if !state! equ 4 ( %@line% !$a1! !$a2! !$b1! !$b2!
48
+ ) else if !state! equ 5 ( %@line% !$a1! !$a2! !$d1! !$d2! & %@line% !$b1! !$b2! !$c1! !$c2!
49
+ ) else if !state! equ 6 ( %@line% !$a1! !$a2! !$c1! !$c2!
50
+ ) else if !state! equ 7 ( %@line% !$a1! !$a2! !$d1! !$d2!
51
+ ) else if !state! equ 8 ( %@line% !$a1! !$a2! !$d1! !$d2!
52
+ ) else if !state! equ 9 ( %@line% !$a1! !$a2! !$c1! !$c2!
53
+ ) else if !state! equ 10 ( %@line% !$a1! !$a2! !$b1! !$b2! & %@line% !$c1! !$c2! !$d1! !$d2!
54
+ ) else if !state! equ 11 ( %@line% !$a1! !$a2! !$b1! !$b2!
55
+ ) else if !state! equ 12 ( %@line% !$b1! !$b2! !$d1! !$d2!
56
+ ) else if !state! equ 13 ( %@line% !$b1! !$b2! !$c1! !$c2!
57
+ ) else if !state! equ 14 ( %@line% !$c1! !$c2! !$d1! !$d2!
58
+ )
59
+ )
60
+ )
61
+
62
+ < nul set /p " = !dots!"
63
+ pause > nul & exit
64
+
65
+
66
+ :macros
67
+ ( for /f %%a in ('echo prompt $E^ | cmd') do set " \e = %%a " ) & < nul set /p " = !\e![?25l"
68
+
69
+ (set \n=^^ ^
70
+ %= This creates an escaped Line Feed - DO NOT ALTER \n =%
71
+ )
72
+ set " sqrt = ( M=(N),j=M/(11264)+40, j=(M/j+j)>>1, j=(M/j+j)>>1, j=(M/j+j)>>1, j=(M/j+j)>>1, j=(M/j+j)>>1, j+=(M-j*j)>>31 )"
73
+
74
+ rem %@line% x0 y0 x1 y1 color < rtn> $line
75
+ set @line = for %% # in (1 2) do if %% #==2 ( for /f " tokens=1-4" %% 1 in (" ^!args^! " ) do (%\n%
76
+ set " $line = %\e% [48;5;15m" %\n%
77
+ set /a " $x0 = %%~ 1,$y0 = %%~ 2,$x1 = %%~ 3,$y1 = %%~ 4, dx = (((%%~ 3-%%~ 1)>> 31| 1)* (%%~ 3-%%~ 1)), dy = - (((%%~ 4-%%~ 2)>> 31| 1)* (%%~ 4-%%~ 2)), $dy = (((%%~ 4-%%~ 2)>> 31| 1)* (%%~ 4-%%~ 2))" , " err = dx+ dy" , " dist = ((((($dy- dx)>> 31)& 1)* dx)| ((~ ((($dy- dx)>> 31)& 1)& 1)* $dy))" %\n%
78
+ if ^^! $x0^^! lss ^^! $x1^^! ( set sx = 1 ) else ( set sx = -1 )%\n%
79
+ if ^^! $y0^^! lss ^^! $y1^^! ( set sy = 1 ) else ( set sy = -1 )%\n%
80
+ for /l %%i in (0,1,^^! dist^^! ) do (%\n%
81
+ set " $line = ^ !$line^!%\e% [^ !$y0^! ;^ !$x0^! H " %\n%
82
+ set /a " e2 = 2 * err" %\n%
83
+ if ^^! e2^^! geq ^^! dy^^! ( set /a " err += dy, $x0 += sx" )%\n%
84
+ if ^^! e2^^! leq ^^! dx^^! ( set /a " err += dx, $y0 += sy" )%\n%
85
+ )%\n%
86
+ set " $line = ^ !$line^!%\e% [0m" %\n%
87
+ ^ < nul set /p " = ^!$line^!" %\n%
88
+ )) else set args =
89
+ goto :eof
90
+
91
+ :Set_Font FontName FontSize max/nomax dummy
92
+ if " %4 " == " " (
93
+ for /f " tokens=1,2 delims=x" %%a in (" %~2 " ) do if " %%b " == " " (set /a " FontSize=%~2 *65536" ) else set /a " FontSize = %%a + %%b * 65536"
94
+ reg add " HKCU\Console\%~nx0 " /v FontSize /t reg_dword /d !FontSize! /f
95
+ reg add " HKCU\Console\%~nx0 " /v FaceName /t reg_sz /d " %~1 " /f
96
+ set " m = " & if /I " %~3 " == " max" set " m = /max"
97
+ start " %~nx0 " !m! " %ComSpec% " /c " %~f0 " _
98
+ exit /b 1
99
+ ) else ( > nul reg delete " HKCU\Console\%~nx0 " /f )
100
+ goto :eof
0 commit comments