Live data from Hacker News

Show HN: URL Snake

github.com

21–30 of 36 posts

Re: Show HN: URL Snake

#22
Can't update the post now, but I've actually got it down to 713 bytes, which I'm pretty happy with! I could remove features/colors/styles at this point, but I think I'll leave it there for now.

If anyone's interested, I've tried to annotate a fair amount of the tricks I've used so far: https://github.com/lukebatchelor/url-snake/blob/main/golf/de...

let e=document.body,t="Space: start/reset. Arrows: Move#a{border:solid}{background:tan}",r=40,n=400,o,d=[[4,3]],s=d[0],c="#000",p=(e="red",t=n,a=0,l=a)=>{C[f="fillStyle"]=e,C.fillRect(ar,lr,t,t)},h=(e,t=n/2,a=t,l="center")=>{C[f]=c,C.textAlign=l,C.fillText(e,t,a)};e.innerHTML=t,C=a.getContext`2d`,a.height=a.width=n,C.font="30px f",e.onkeyup=({which:e})=>{36{if(o){let[e,t]=d[0],a=e+H%2,l=t+(H-1)%2,n=([e,t])=>e==a&&t==l;if(d.pop(),aS%10]),p`tan`,d.map(e=>p(c,r,...e)),p(i,r,...s),h(S,9,30,"left")}},n);

Re: Show HN: URL Snake

#23

Can't update the post now, but I've actually got it down to 713 bytes, which I'm pretty happy with! I could remove features/colors/styles at this point, but I think I'll leave it there for now. If anyone's interested, I've tried to annotate a fair amount of the tricks I've used so far: https://github.com/lukebatchelor/url-snake/blob/main/golf/de... let e=document.body,t="Space: start/reset. Arrows: Move #a{border:sol…

Golfed to 697 bytes using a self-extracting webp/html polyglot:

    data:text/html;base64,UklGRhgCAABXRUJQVlA4TAwCAAAvygIAAIU019bbNspSFKWR9hdFZaqtb3rvM84/Q4AZ8bMlhCEF6nODpdXLmTVE9J9A0qbBtj+FIQ4ItSvXD2Q5unN6D4zhrFElTYKWlecbTy1xFLz13m3bSfDTbSjX9eZVXiq7UW1Qa1Sv8pb3hl6dqcOd85r8pHWm1v3ocKfK+5V3a6snrGyf3xwDhuDxSQwWn8QxONA4nz+BrCigRT2PCygxPIvjOIQGBWHoSYfAaEFhDAaVxFeH9/MlhsvamNlgEhZI8D4aOP5RyUKNPJiRBwaWPVQoaOC+SUEhg8GwJMvkw0cCBZbwPmLa8VtTryyaRwq3tOOBGJTspxTV1pL/cvvzBzK8RxWtiN87O+AuUr0AFVVUrypGFW1rzRXaAd9ZxjCLm12wDIEiZ+9pv25QHLZVXVYT6gf37FlOl5eUP0lef0G6zl5MsvQUqetc1wmHyX+X+YIpzDCWPbTEX4d6G2VEja8O9VI4eTDEcwIujgdUSOMvFykY5LH4cp3IixQsiiMyia8IUV1eMqKZ1kuho8Y1QoLK4657mauuM8cEput01LoHElZKT7z2NnAYwwBZLSZiMR26KDAFRFGkC7CilZeXQs/H49lQYHadDJ+aiw9oaRt8UEzyIonhw2h2kcSFhGbByi5ARw+qEYSvGlGCHyRISmhEfQzRSqjEDF5CFkNoaMmh7HuwcnpyAjxjYW52YXMgaWQ9Yz48aW1nIG9ubG9hZD13aXRoKGMuZ2V0Q29udGV4dGAyZGApZm9yKHA9ZT0nJztkcmF3SW1hZ2UodGhpcyxwLS0sMCksdD1nZXRJbWFnZURhdGEoMCwwLDEsMSkuZGF0YVswXTspZSs9U3RyaW5nLmZyb21DaGFyQ29kZSh0KTtldmFsKGUpIHNyYz0jPg==
(954 bytes of encoded URL)

Based on the technique used here: https://gist.github.com/gasman/2560551

Edit: hm, at some point in my golfing I appear to have broken the apple placement randomisation logic... I'm too lazy to debug it right now (probably)

Re: Show HN: URL Snake

#24

And ChatGPT can tell that it's a game of Snake from the URL. https://www.tiktok.com/@y.i.t.z.i/video/7186055378977803521 "When decoded, the script appears to be a Snake game implemented using JavaScript and the HTML5 canvas element. The script creates an HTML page with a canvas element and adds event listeners for arrow keys and space bar to control the game."

Wow, that's actually impressive. Any idea how chat gpt would know that? Surely it's not making the request for it and surely it's not actually decoding any base64 right?

ChatGPT has probably seen plenty of half-baked excercise/homework snake implementations on Github to tell that this is another one of those.

(Yes, this is moving the goalposts and implying that true AI is just over the horizon...)

Re: Show HN: URL Snake

#26
Some interesting features of this snake game:

1. You can change directions multiple times within a tick, making the last direction to be effective.

2. You can change to any directions, including the opposite direction of your current movement, which usually results in :( as the snakes head bumps into its body...

3. Except when the snake has length 1 or 2, then it's OK, as the snake either does not have a body yet, or its body and head switch places at the next tick.

As a combination of 1 and 2, quickly turning around is a risky move.

Re: Show HN: URL Snake

#27

Nice! I made a 250-byte Snake game (265 as a URL) a few years ago after spending far too long code-golfing it: https://danielgjackson.github.io/tinyjs#snake ...and even a 224 byte version (240 as a URL), but with a few too many sacrifices.

You are on a completely different level. Wow. I am going to spend absolutely too long tomorrow trying to work out how on earth you've done that. Cheers!

Re: Show HN: URL Snake

#28
Hey I think you might like my Pong in a tweet then!

https://twitter.com/rafalpast/status/1316836397903474688?s=4...

Still waiting for VCs to invest in my Twitter as a CDN:

https://twitter.com/rafalpast/status/1316841669451558913?s=4...

The article from the tweet: https://laconic-mu.vercel.app/index.html?c=eJylWOuS27YV%2Fu%...

Re: Show HN: URL Snake

#29

Can't you just put the whole thing in a JavaScript URL without using base64? Eg JavaScript:alert(1) It would be shorter than 1464. I'm not at my computer right now to try it... Edit: It seems to work. Also, the original can be golfed some more.

[deleted]

Re: Show HN: URL Snake

#30

Can't update the post now, but I've actually got it down to 713 bytes, which I'm pretty happy with! I could remove features/colors/styles at this point, but I think I'll leave it there for now. If anyone's interested, I've tried to annotate a fair amount of the tricks I've used so far: https://github.com/lukebatchelor/url-snake/blob/main/golf/de... let e=document.body,t="Space: start/reset. Arrows: Move #a{border:sol…

But sometimes the new red element to eat is being placed on the snake. Easier to spot after level 25.
Post reply on HN