Bram Cohen🌱 Profile picture
Jul 15, 2021 13 tweets 4 min read Read on X
Writing computer programs to play snake is very interesting! Here's an overview, which I have many thoughts on including a straightforwardly implementable clear improvement (thread)
A much algorithm thing which works by dividing the board into 2x2 cells which makes calculation easier for reasons is here github.com/twanvl/snake/
The inefficiencies added by the limitation to cells are extremely small and not really worth discussing, there are vastly larger optimizations to be had for much less effort and risk.
When improving something step 1 is always debugging. Here's a situation in which it fails to fill out a region which appears to be an outright bug
Bugs aside and looking at strategy, hugging the walls matters A LOT. If you go directly for the apple you can cut the board in half forcing yourself to go around your whole length to get an apple in the future or even worse having to kill time filling a whole half
Here's a situation in which it goes straight for the apple which is a clear error. It would have had to spend very little time hugging the bottom which would have avoiding having to fill the bottom region immediately after
And here's another one with an even bigger region
In terms of things which it's overlooking it sometimes maneuvers to work around tail which will be gone by the time it matters. For example here it could hug the wall and by the time it gets to the apple the problematic part of the tail will be gone
And here's a similar situation
Handling these things properly in the general case seems to involve deep planning and is highly nontrivial, but I promised you a clear improvement so here it is:
Parts of the tail which you couldn't stomp on even if you headed towards them as the crow flies can be safely virtually trimmed and you can plan out as if they aren't there. This is simple to implement and leads to clearly better behavior in some situations
For example in this situation if it were trimming it would realize that hugging the wall on the left isn't a thing and hugging the right is clearly the way to go
And finally another thing which looks like a bug: Here it was hugging the wall, then decided to go straight for the apple, then realized that was stupid and decided to turn around and hug the wall again with nothing changing

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Bram Cohen🌱

Bram Cohen🌱 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @bramcohen

Dec 3, 2022
OpenAI's chatbot doesn't have much experience in the material world
Don't let OpenAI's chatbot take care of your pets
They seem to be updating it in real time so it gives better answers to specific questions than it did just a few hours ago but sometimes small variations can trip it up
Read 9 tweets
Dec 2, 2022
OpenAI chat has some trouble with the whole 'age' concept
Also doesn't understand even basic formulas
If you keep drilling in to its weasel wording eventually it gives away that it doesn't know what it's talking about
Read 8 tweets
Nov 21, 2022
Good morning everyone. Today's rant will be about analog audio and some truly maddening myths in that field (thread)
There's a persistent myth that as soon as any step in audio processing is digital the entire thing has been reduced to a lower digital quality and that's what you're stuck with. This is wrong.
The truth is that every step of processing, either analog or digital, reduces quality, and each specific process will have its own effects, but the limits of how little quality can be lost are much better when both the inputs and outputs are digital
Read 10 tweets
Nov 19, 2022
There's a myth in the general public that Know Your Customer programs are important for banking. This is incorrect (thread)
KYC has nothing to do with bank auditing and solvency. It is a relatively recent program which is solely for helping law enforcement. To that end it is extremely expensive and ineffective
The thing which really keeps bank together is federal reserve auditing and FDIC insurance. You know, the things which keep them from turning into FTX. KYC didn't start until 1970. It makes up a significant amount of all banking costs with no benefit to bank customers whatsoever
Read 9 tweets
Nov 13, 2022
Something which offends me about SBF is that he's a finance bro's notion of a charmingly autistic founder. He plays that role well because he's a finance bro himself (thread)
Here's the chart of SBF's corporate empire. Nobody sets up something like this without damn well knowing that they're up to something shady Image
Another obnoxious thing is his inability to tie his shoes supposedly being cute. An adult being incapable of tying their shoes is a red flag of someone who doesn't take pride in their work and can't be bothered to do much of anything for themselves
Read 10 tweets
Nov 12, 2022
Someone who has not made major charitable contributions, either through money or deeds, can't claim to be an 'effective altruist' any more than they can claim to be a philanthropist
Someone who's starting out their career and plans to do it can claim that they aspire to be an effective altruist some day, or even have direct plans for it, and if they haven't yet made lots of money that's a reasonable claim
If someone had a plan of making lots of money and using it for charity in the end but their investments never panned out I'm even happy to give them the benefit of the doubt that they would have been very generous
Read 10 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(