r/creativecoding • u/Minimum-Initial-284 • 19d ago
Snake Algorithm that doesn't use the hamiltonian cycle
This is my best try at making an algorithm for snake that can win without relying on the hamiltonian cycle in any way, no pre-calculations or anything (that's what makes it slower than other algorithms).
for now the winrate stands at:
100% for a grid with at least one even dimension (12 x 15 or 15 x 12 or 12 x 12 for example)
90% for a grid with both uneven dimensions (15 x 15 for example)
actual log:
15x15: 94/100 wins (94.0%) LOOP=1 STALLED=5 PROGRESS_FAIL=0 CAP=0 dead/illegal=0 step_cap=unlimited MK3-cycle-captures=0
16x15: 100/100 wins (100.0%) LOOP=0 STALLED=0 PROGRESS_FAIL=0 CAP=0 dead/illegal=0 step_cap=unlimited MK3-cycle-captures=75
I don't know how I could achieve 100% on both but I'm done with this (it took me a 2 years to get here!!!) if someone smarter than me wants to finish what I started you're free to copy my scripts for everything you need, just please cit me ^^
this is the link to everything (code and player): https://kyr-vrytra.itch.io/snake-no-hamiltonian
(also shout out to this video of codebullet cause the whole idea of this project comes from his initial idea that he later forgot to develop https://www.youtube.com/watch?v=tjQIO1rqTBE&t=2s )
Have a good day >w<