Showing posts with label nerdity. Show all posts
Showing posts with label nerdity. Show all posts

Thursday, January 14, 2010

100 Games Cupcake Game

The object is simple: how many games can you identify from their cupcake representations?




















Linking without comment... where was that on the list again?

Monday, December 7, 2009

Life

Well, Joe guessed correctly and first that the previously mentioned batch file is an implementation of Conway's Game of Life.














I wrote a slightly better implementation in C#, and it allows more than just 2 states, but it's not very sophisticated:



















While I was writing that version, however, I stumbled across a much more advanced implementation (in the same way that the B-2 is more advanced than a kite), called Golly.




















I highly recommend checking it out, but I should warn you that it might cause you to waste hours if not days staring at the blinkenlights.
Programming Contest

What does the following batch program do? Try to take a guess before running it yourself:


@echo off
setlocal enabledelayedexpansion

set NUMROWS=10
set NUMCOLS=10

REM // These start at 10 so they're always 2 digits
set nFirstRow=10
set /a nLastRow=nFirstRow+NUMROWS-1
set nFirstCol=10
set /a nLastCol=nFirstCol+NUMCOLS-1

REM // This is a capital oh, not zero
set ON=O
set OFF=.
set Var1=0
set Var3=1

:Initialize
REM // CELLrrcc
for /L %%I in (%nFirstRow%,1,%nLastRow%) do (
for /L %%J in (%nFirstCol%,1,%nLastCol%) do (
set CELL%%I%%J=%OFF%
)
)

if %1[==[ goto :Pattern5
goto :Pattern%1
:Pattern1
REM // What is it?
set CELL1110=%ON%
set CELL1111=%ON%
set CELL1112=%ON%
goto :Render
:Pattern2
REM // What is it?
set CELL1011=%ON%
set CELL1112=%ON%
set CELL1210=%ON%
set CELL1211=%ON%
set CELL1212=%ON%
goto :Render
:Pattern3
REM // What is it?
set CELL1314=%ON%
set CELL1315=%ON%
set CELL1413=%ON%
set CELL1414=%ON%
set CELL1514=%ON%
goto :Render
:Pattern4
REM // What is it?
set CELL1314=%ON%
set CELL1413=%ON%
set CELL1414=%ON%
set CELL1415=%ON%
set CELL1514=%ON%
goto :Render
:Pattern5
for /L %%I in (%nFirstRow%,1,%nLastRow%) do (
for /L %%J in (%nFirstCol%,1,%nLastCol%) do (
if !RANDOM! GTR 16383 set CELL%%I%%J=%ON%
)
)

:Render
cls
set Var2=0
for /L %%I in (%nFirstRow%,1,%nLastRow%) do (
set ROW=
for /L %%J in (%nFirstCol%,1,%nLastCol%) do (
set ROW=!ROW!!CELL%%I%%J!
if !CELL%%I%%J!==%ON% set /a Var2=Var2+1
)
echo !ROW!
)
echo P:%Var2% / G:%Var1%
if %Var2%==0 goto :EOF
if %Var3%==0 goto :EOF

:Advance
set Var2=0
set nRow=%nFirstRow%
set Var3=0
:AdvanceRow
set nCol=%nFirstCol%
if %nRow%==%nFirstRow% (
set nPrevRow=%nLastRow%
set /a nNextRow=%nRow% + 1
) else if %nRow%==%nLastRow% (
set /a nPrevRow=%nRow% - 1
set nNextRow=%nFirstRow%
) else (
set /a nPrevRow=%nRow% - 1
set /a nNextRow=%nRow% + 1
)
:AdvanceCol
if %nCol%==%nFirstCol% (
set nPrevCol=%nLastCol%
set /a nNextCol=%nCol% + 1
) else if %nCol%==%nLastCol% (
set /a nPrevCol=%nCol% - 1
set nNextCol=%nFirstCol%
) else (
set /a nPrevCol=%nCol% - 1
set /a nNextCol=%nCol% + 1
)
set nSum=0
if !CELL%nPrevRow%%nPrevCol%!==%ON% set /a nSum=nSum+1
if !CELL%nPrevRow%%nCol%!==%ON% set /a nSum=nSum+1
if !CELL%nPrevRow%%nNextCol%!==%ON% set /a nSum=nSum+1
if !CELL%nRow%%nPrevCol%!==%ON% set /a nSum=nSum+1
if !CELL%nRow%%nNextCol%!==%ON% set /a nSum=nSum+1
if !CELL%nNextRow%%nPrevCol%!==%ON% set /a nSum=nSum+1
if !CELL%nNextRow%%nCol%!==%ON% set /a nSum=nSum+1
if !CELL%nNextRow%%nNextCol%!==%ON% set /a nSum=nSum+1
set NEWCELL%nRow%%nCol%=!CELL%nRow%%nCol%!
if %nSum% GTR 3 (
set NEWCELL%nRow%%nCol%=%OFF%
) else if %nSum%==3 (
set NEWCELL%nRow%%nCol%=%ON%
) else if %nSum% LSS 2 (
set NEWCELL%nRow%%nCol%=%OFF%
)
if not !NEWCELL%nRow%%nCol%!==!CELL%nRow%%nCol%! set /a Var3=Var3+1

set /a nCol=%nCol% + 1
if not %nCol% GTR %nLastCol% goto :AdvanceCol
set /a nRow=%nRow% + 1
if not %nRow% GTR %nLastRow% goto :AdvanceRow

for /L %%I in (%nFirstRow%,1,%nlastRow%) do (
for /L %%J in (%nFirstCol%,1,%nLastCol%) do (
set CELL%%I%%J=!NEWCELL%%I%%J!
)
)
set /a Var1=Var1 + 1
goto :Render

Twenty imaginary gold doubloons to the pirate that first guesses correctly. I think I might have created the worst-performing implementation of this particular algorithm.

Friday, November 6, 2009

Browser Fight

Time for another holy flame war. For some reason I now have five web browsers installed. Naturally, I decided to run them all at the same time. How about a standards-compliance matchup? First up, the Acid2 Test:

















Surprisingly, Firefox is the only one that failed. Next, the newer Acid3 test (I need another monitor):












Only Opera reported a perfect 100/100 and matched the reference rendering. Chrome has a graphical artifact, although it reports no errors. Oddly, Firefox and SeaMonkey report different scores although they use the same rendering engine. Microsoft haters will love the FAIL on IE. Lastly, a memory usage comparison:


























Don't ask me why my mouse driver takes 20MB of memory. Chrome and IE each run two processes even when only displaying one page, so the browser with the lowest total memory footprint is Opera. I only just installed it last week, so I may actually try it out now to see how well it works.

Tuesday, October 6, 2009

Nerdvana Moment Of The Day

Copy this to a batch file and run it:

@echo off
setlocal enabledelayedexpansion

set Framefile=dosref.html
set TOCfile=TOC.html

echo ^<html^> >%Framefile%
echo ^<head^> >>%Framefile%
echo ^<title^>DOS Reference^</title^> >>%Framefile%
echo ^</head^> >>%Framefile%
echo ^<frameset cols="120,*"^> >>%Framefile%
echo ^<frame src="%TOCfile%"/^> >>%Framefile%
echo ^<frame name="showframe"/^> >>%Framefile%
echo ^</frameset^> >>%Framefile%
echo ^</html^> >>%Framefile%

echo ^<html^>^<head^> >%TOCfile%
echo ^<title^>Table of Contents^</title^> >>%TOCfile%
echo ^</head^>^<body^> >>%TOCfile%

for /f "usebackq skip=5 tokens=1" %%i in (`help ^|sort`) do (
if not exist %%i.txt (
help %%i > %%i.txt
if ERRORLEVEL 1 (
echo ^<a href="%%i.txt" target="showframe"^>%%i^</a^>^<br/^> >>%TOCfile%
) else (
del %%i.txt
)
)
)

echo ^</body^>^</html^> >>%TOCfile%
In case you're suspicious of running strange batch files you see on the internet (aka smart), what it does is create a frame-based DOS command html reference. Tested in Windows XP, Vista should work too.

Tuesday, March 3, 2009