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

16 Jul
Trying to figure out what happened in the Avenatti case it's completely bananas and I have questions (thread)
The story is that Avenatti approached Nike threatening a lawsuit over them having violated NCAA rules that college athletes must be treated like slaves, and offered a settlement including him personally getting paid $20 million (or so) to \
run an internal investigation at Nike making sure that they continued to treat college athletes like slaves moving forwards. Clearly he personally really, really cares strongly that college athletes continue to be treated like slaves.
Read 13 tweets
13 Jul
And now for an explanation of how some classification algorithms work and an honest question (thread)
For classifying data like was used in the Netflix prize you have a big problem: There are lots of people and lots of movies, and the number of overlapping movie ratings different people gave is very small
In data science parlance the data is sparse and high dimensional. This makes it not very useful for guessing if a particular person would like a particular movie.
Read 25 tweets
13 Jun
Apparently there's some kind of panic about Chia going on in China. It isn't even clear what claims are being made, but here are some points to reiterate (thread)
The network doesn't just trust how much space your local machine claims it has. It's trivial to fool your local farmer into thinking it has lots of space. That doesn't mean it will fool the network.
The new faster plotter isn't a threat to the network's security, it just makes plotting faster and more convenient, which is a good thing. The network is secured by space, not plotting speed
Read 7 tweets
11 Jun
People are asking/speculating about the new Chia plotter. It's better but the details are complicated (thread)
What it does is make better use of available cores for multithreading. This results in a big headline speedup on SSD in terms of the minimum number of seconds to finish a whole plot
But it isn't nearly as big an improvement to overall rate of plotting if you compare to running multiple plots on multiple drives at once. It also probably makes almost no difference writing to HD because that was nearly I/O bound already
Read 14 tweets
3 Jun
There's a subtle point about pool/farmer 'difficulty' which I misunderstood the question on in the video this morning so I'll try to explain now (thread)
On the actual running network there's what's called 'work difficulty' which determines a quality threshold above which a proof of space successfully qualifies for making a block
There's a subtlety here about timelords and the rate they're running at which don't matter for this explanation. But know there are timelords and they do important stuff which you rarely have to worry about
Read 13 tweets
27 May
And now I present what passes for intellectual commentary about coin issuance (thread) medium.com/@nic__carter/i…
The message is 'Premines are unethical. I have this great idea that you can give yourself a leg up on mining by keeping the PoW algorithm secret beforehand and making your own ASICs in advance'
Because laundering the money at great expense totally changes everything. This being twitter I should clarify that that was sarcasm. It just wastes a bunch of money and makes a burning need to dump to recoup some of that investment
Read 14 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

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

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(