[AMC#6] Clone Brute-Force (scratch3.0-vm)
- - - - MODIFIED FOR SCRATCH 3.0 VM - - - -
View in 3.0: https://llk.github.io/scratch-vm/#143734743
View better 2.0 version: https://scratch.mit.edu/projects/143719133/
Press the green flag to begin. The whole project (and likely your web browser) is going to lag lots while running.
Once you hear some clicking sounds, the project is checking whether or not a proper solution was found. When the clicking stops, a solution may have (hopefully) been found, which should be drawn to the map.
After the project is finished, if you had set "kill ended clones" to 0, then press D, you can look through each of the resulting paths (paths that go from 1 to the end). Only a couple will be solutions, but it's interesting to browse through anyways. (Navigate with the arrow keys and "index" slider.)
If the path doesn't get shown when it's done you might need to restart the project with "kill ended clones" set to 0; then press D and adjust the index to the very end.
This "algorithm" is really just a brute force that runs on clones. I went with clones because they make keeping track of "first-class" arrays /very/ easy. However, when you run the project, you'll see that there's often 300 clones at once, which is Scratch's limit.. thankfully the program *does* find the answer to this puzzle within the clone limit, but there's certainly no guarantee it'd work in other layouts.
It's certainly possible to do this with lists, and almost definitely better that way, but I'm not really sure how to manage first class lists on a single sprite well, and I liked the idea of using clones. Proofs of concept! :P
(This project would likely always work if the clone limit were higher (and people had faster computers).)