logoalt Hacker News

Show HN: Watch a neural net learn to play Snake

98 pointsby c1byesterday at 3:35 PM22 commentsview on HN

In browser PPO training demo, made possible by tinygrad: TinyJit -> WebGPU kernels.

Requires WebGPU.


Comments

joshkatoday at 9:31 PM

A previous similar idea running as a Ratatui based TUI: https://github.com/bones-ai/rust-snake-ai-ratatui

jesuotoday at 9:11 PM

Poorly programmed, it doesn't learn from its mistakes, the games get stuck in a loop because the snake doesn't capture a piece but the piece remains and there's a gap, constantly moving the snake along the same path with negative scores in an infinite loop leaving an unaltered yin and yang ;) there's a repetitive pattern in these infinite games between the position of the gap and the piece

show 1 reply
simedwtoday at 3:58 PM

Cool project!

I noticed that if you go from training to watch and then back, the training temporarily drop significantly in score.

ziofilltoday at 9:07 PM

I noticed snake gets penalized for not getting to the apple early, is that what you really want? Snake is about how long it gets not about the balance between length and wall clock time

show 1 reply
snatstoday at 7:15 PM

did a pretty similar thing last month for the text rendering library last month.

trained and made a viz for the model and then made it displace text.

should probably do a proper write-up:https://x.com/i/status/2038367016969724259

ldoughtytoday at 5:21 PM

Really cool! But right as it was nearing 4,000, it seems to have corrupted itself and no longer got any scores above 0. Not sure if that's a code bug or a neural net issue.

avg500 -4.6 last 500 episodes

peak 3959.3 best window

roll/s 20.68 20-step avg

progress 4388 562749 episodes

show 4 replies
mavdol04today at 8:13 PM

That's cool, i did exactly the same few years ago

beardsciencestoday at 4:37 PM

My average eventually made it to about 3900, and then stagnated between 3600-3900. I'm curious if this is universal behavior or not. I'm up to about 5k steps.

nedumatoday at 4:06 PM

More details and implementation notes please?

LowLevelKerneltoday at 6:25 PM

Link to repo?

bozharktoday at 7:02 PM

Crashed

th1nhng0today at 5:08 PM

cool project

jmclnxtoday at 5:42 PM

> WebGPU not available in this browser

Looks like this is for Linux and Windows, on NetBSD I get this issue :(

show 2 replies
austinthetacotoday at 5:11 PM

my training on a 10x10 just randomly broke. i got to like 3600 then the graph went flat, the viewer on the left just showed it constantly restarting the game, and the scores in the negative. my average is now -10.