Game Of Life

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
T3RRY
Posts: 243
Joined: 06 May 2020 10:14

Re: Game Of Life

#16 Post by T3RRY » 08 Jun 2020 02:06

My method was estimation by comparing the time elapsed between generations using the following code within for loop iterations.

Code: Select all

@echo off
setlocal EnableDelayedExpansion
(For /F "Delims=" %%E in ('Where /R "%USERPROFILE%" cmdgfx_gdi.exe') Do CD "%%~dp$PATH:E") > Nul 2> Nul
cmdwiz showcursor 0
cmdwiz getdisplaydim w & set /a w=!errorlevel!/3+1
cmdwiz getdisplaydim h & set /a h=!errorlevel!/3+1
mode %w%,%h%
set /a density=10, col=12
if not defined _ set _=. & call %0 | cmdgfx_gdi.exe "fbox 0 0 db & block 0 0,0,%w%,%h% 0,0 -1 0 0 - random()*100/(101-%density%)" Sfc:0,0,%w%,%h%n
for /l %%a in () do (
	(Set /a Tk+=1 & Title %Time% !Tk! !Time!) & echo "cmdgfx: block 0 0,0,%w%,%h% 0,0 -1 0 0 - store(gtr(col(x-1,y-1),0)+gtr(col(x,y-1),0)+gtr(col(x+1,y-1),0)+gtr(col(x-1,y),0)+gtr(col(x+1,y),0)+gtr(col(x-1,y+1),0)+gtr(col(x,y+1),0)+gtr(col(x+1,y+1),0),0)+((1-(lss(s0,2)+gtr(s0,3)))*gtr(col(x,y),0)+eq(col(x,y)*10+s0,3))*(%col%+eq(s0,3)*3) & text e 0 0 [FRAMECOUNT] 2,2 6"
)
I was out by by 1 frame per second, However, that said, there's a discrepency between the generation count returned by cmdgfx_gdi compared to iterations of the For loop.

Fullscreen at 1360 * 768 pixels (Native resolution is 3840 * 2160, at which only approx 1/6th of the cmd window is occupied by cmdgfx_gdi's output)

https://drive.google.com/uc?export=down ... eZqb1btMPz

The frame differenceI mentioned was between the very first script you posted in this thread.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Game Of Life

#17 Post by misol101 » 08 Jun 2020 04:45

T3RRY wrote:
08 Jun 2020 02:06
Fullscreen at 1360 * 768 pixels (Native resolution is 3840 * 2160, at which only approx 1/6th of the cmd window is occupied by cmdgfx_gdi's output)
hmm, that’s a bit puzzling. 3840*2160 (8 million pixels) is admittedly a much larger screen than I ever tried cmdgfx with (max I tried is probably 1920*1080), but I don’t really see why cmdgfx would fail :| It might very well be failing, but it could also be ”cmdwiz getdisplaydim” failing.

Could you do me a favor and print the return values from ”cmdwiz getdisplaydim w” and ”h” when your resolution is 3840*2160? If it does return faulty values, what happens if you hardcode w=3840 and h=2160 in your script instead of calling getdisplaydim?

T3RRY
Posts: 243
Joined: 06 May 2020 10:14

Re: Game Of Life

#18 Post by T3RRY » 08 Jun 2020 06:27

Hmm... It's not just cmdwiz returning an incorrect value. wmic is also incorrect, however that is returning max res.

Code: Select all

C:\Users\tcdou\Desktop>setlocal EnableDelayedExpansion 
C:\Users\tcdou\Desktop>(For /F "Delims=" %E in ('Where /R "C:\Users\tcdou" cmdgfx_gdi.exe') Do CD "%~dp$PATH:E" ) 1>Nul 2>Nul 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>cmdwiz showcursor 0 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>cmdwiz getdisplaydim w   & set /a w=!errorlevel!/3+1 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>cmdwiz getdisplaydim h   & set /a h=!errorlevel!/3+1 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>For /F "delims=" %# in ('"wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution /format:value"') do (Set "%#" 1>nul ) 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>(Set "
" 1>nul ) 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>(Set "
" 1>nul ) 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>(Set "CurrentHorizontalResolution=4096
" 1>nul ) 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>(Set "CurrentVerticalResolution=2160
" 1>nul ) 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>(Set "
" 1>nul ) 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>(Set "
" 1>nul ) 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>(Set "
" 1>nul ) 
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>Set w 
w=427
windir=C:\Windows
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>Set h 
h=241
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>Set curr 
CurrentHorizontalResolution=4096
CurrentVerticalResolution=2160
C:\Users\tcdou\Desktop\batchTT\cmdgfx\games\shootem>Exit /b 
With the correct resolution hardcoded, it does display as expected.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Game Of Life

#19 Post by misol101 » 08 Jun 2020 07:46

Thanks. I'm willing to bet you have a scale setting (in your Windows Display settings) set to something larger than 100%. Apparently Cmwiz doesn't take this into account. I will add it to the list of Cmdwiz bugs to fix.

EDIT: now fixed in Cmdwiz 1.5
Last edited by misol101 on 11 Jun 2020 12:10, edited 1 time in total.

T3RRY
Posts: 243
Joined: 06 May 2020 10:14

Re: Game Of Life

#20 Post by T3RRY » 08 Jun 2020 08:19

Bet confirmed.

quickfix I'm using:

Code: Select all

Set SF=3
For /F "Tokens=3 Delims= " %%A in ('REG QUERY "HKCU\Control Panel\Desktop\WindowMetrics" /V AppliedDPI') Do Set/A SF-=%%A / 100 + 1
cmdwiz getdisplaydim w & set /a w=!Errorlevel!/(!SF!+1)
cmdwiz getdisplaydim h & set /a h=!Errorlevel!/(!SF!+1)
Accurate for scaling below 300%

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Game Of Life

#21 Post by misol101 » 08 Jul 2020 09:19

Just before this topic disappears off the page, I just want to point to: viewtopic.php?f=3&t=9662

The archive there includes a very fast GameOfLife implementation, running fullscreen with a pixel font. My assumption that I would get 100+ FPS for 1920x1080 for a native C implementation (ran through Cmdgfx) turned out to be correct; it landed around 130 FPS.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Game Of Life

#22 Post by misol101 » 12 Jul 2020 04:54

By the way, if you like Game of Life, check out 3d Cellular Automata, such as https://www.youtube.com/watch?v=dQJ5aEsP6Fs

It is basically just like Game Of Life, but extended to 3 dimensions (so 26 neighbours instead of 8 ), typically with a 3d cube representing each cell.

That level of processing (and even more so, rendering) is certainly not suitable for Batch (ok, prove me wrong!), and not for Cmdgfx either really (since it's entirely CPU based).

I made a purely GPU based (two levels multi-shader) solution in Unity, and managed to run at most 210x210x210 (that's over 9 million 3d objects!) cubes at ~33 FPS. After that both texture sampling and meshes started breaking down :D

Anyway, I digress, but the topic is interesting.

EDIT: Other 2d automata like "Brian's brain" (which I quite like) and "Seeds" would absolutely be doable in Batch though.

Post Reply