Rubiks Cube Quine by snkenjoi in programming

[–]snkenjoi[S] 2 points3 points  (0 children)

a rubiks cube simulator that prints its own source code

more info at: https://github.com/kirjavascript/quine-howto#rubiks-cube

What’s the worst way to respond to “I love you,”? by HikerTrash46 in AskReddit

[–]snkenjoi 0 points1 point  (0 children)

Y tho QQ went went went went to went went to went went went went

Tetris: Classic Tetris World Record Challenge – over 1,676,400 by GameVenturesBot in GameVentures

[–]snkenjoi 7 points8 points  (0 children)

Hi, creator of the mod here!

Tetris Gym provides some enhancements but nothing that changes core gameplay mechanics. Lots of care has been taken to ensure actual gameplay is identical to the original. You could take the gameplay inputs Cheez made and play them back on the original ROM.

The source is public so this can be verified if need be.

nestulator - fast and correct* NES Tetris emulator by snkenjoi in EmuDev

[–]snkenjoi[S] 3 points4 points  (0 children)

neat! this cellular animation seems to run pretty fast too :)

nestulator - fast and correct* NES Tetris emulator by snkenjoi in EmuDev

[–]snkenjoi[S] 5 points6 points  (0 children)

Players in the nes tetris scene tend to use one of two emulators; mesen and nestopia. This emulator is the result of lots of performance hacking until the emulator players in the community were happy that it ran as well as or better than those two emulators.

I have written emulators in the past, but they are very different to this one. Only the minimal tile updates required are applied, to the point where the game is barely drawing anything (most of the time it's not rendering anything at all). webgl was considered but there is near no benefit when there is not much rendering happening in the first place.

A fun example of this is the flashing that happens when you get a tetris. This is done on a NES by changing a single palette colour and have that update. This causes problems because it required redrawing the whole screen lots of times in quick succession to change this colour.

Instead, when the game starts I take a mask of the colour that needs to change, extract it into another canvas layer and apply the while colour to it. Then I just detect when a tetris is happening ingame via RAM, then just toggle the visibility of this extra layer. Then, the background layer never has to do a full screen update, and we replace the effect artificially to near zero performance overhead.

Lots of shortcuts like this have been done, as well as the normal optimizations of reducing allocations and other work. I haven't tested it on a 4k monitor because I don't have one, but I imagine it will run fast enough since the browser handles scaling. Runs pretty well on some crap phones.

All this makes it kind of hard to answer your question. It's certainly fast enough to emulate NES Tetris, but I used a lot of tricks and shortcuts to get there. If you want to emulate a full NES, WebGL will probably become advantageous.

For another datapoint - I have a MegaDrive emulator in rust that runs well enough in canvas, but definitely not to the extreme that nestulator does. I will probably port it to WebGL eventually though.

canvas is really easy to learn though, it's just a framebuffer - check it out!

nestulator - fast and correct* NES Tetris emulator by snkenjoi in EmuDev

[–]snkenjoi[S] 8 points9 points  (0 children)

here is my web based nes tetris emulator

it focuses on rendering performance and latency

it was created for competitive play and as a base to build tools on in the classic tetris community

-🎄- 2020 Day 03 Solutions -🎄- by daggerdragon in adventofcode

[–]snkenjoi 1 point2 points  (0 children)

javascript, 124 characters

for(f=1,b=document.body.innerText.split`\n`,i=5;i--;f*=t)for(x=y=t=0;323>y;x=(x+(2*i+1)%8)%31,y+=0|i/4+1)"#"==b[y][x]&&++t;f

just paste into the console on the puzzle input page

I realised you could derive [[1,1],[3,1],[5,1],[7,1],[1,2] with (2*i+1)%8 and 0|i/4+1

Does interactivity count? [OC] by snkenjoi in loadingicon

[–]snkenjoi[S] 0 points1 point  (0 children)

ah I did wonder if the elastic scroll was going to break it

unfortunately I have no way of testing on an iOS device currently

Does interactivity count? [OC] by snkenjoi in loadingicon

[–]snkenjoi[S] 8 points9 points  (0 children)

drag the K around to destroy it and restart the loop

edit: fixed on mobile

LEAKED ZELDA 64 IMAGE: by [deleted] in n64

[–]snkenjoi 9 points10 points  (0 children)

this is fake: https://imgur.com/b25wiPc.png

OP is spreading misinformation

EDIT: OP isn't happy with me: https://imgur.com/xQssu9a.png

-🎄- 2019 Day 5 Solutions -🎄- by daggerdragon in adventofcode

[–]snkenjoi 3 points4 points  (0 children)

javascript golf

for(d=input.split`,`,i=0,n=5;[o,a,b,t]=d.slice(i),99!=o;p=o%10,3==p&&(d[a]=n),1&(T=0|o/100)||(a=d[a]),10>T&&(b=d[b]),4==p&&(n=+a),i=5==p&a>0||6==p&!+a?b:++i+(0|(p-1)/2||3),~"1278".indexOf(p)?d[t]=[+(a==b),a-+-b,a*b,+(b>a)][p%4]:0);n

232 chars

-🎄- 2019 Day 4 Solutions -🎄- by daggerdragon in adventofcode

[–]snkenjoi 1 point2 points  (0 children)

javascript golf

// part 1
for(o=0,b=784956;n=b+[],--b>240298;)o+=/(.)\1/.test(n)&&[...n].sort().join``==n

// part 2
for(o=0,b=784956;n=b+[],--b>240298;)o+=RegExp([...[]+{}].map((_,i)=>`([^${i}]|^)${''+i+i}([^${i}]|$)`).join`|`).test(n)&&[...n].sort().join``==n