You now have an overview of hill climbing and simulated annealing. Next, you’ll see how to hill climb or descend a few different paper bags. Be forewarned, though, your turtles will get stuck in some of these. After that, you’ll hit the setup with a hammer to simulate annealing. From there, you’ll see how to use a temperature to model the energy of your system. This means you can probabilistically move the turtle to different spots. Ready for some hill climbing?
Your first recipe starts the turtle on the top-left edge of the bag. You’ll move him a step, and then stop when the next step would be up:
|||pos = bag.left()|
|||height = pos.y|
|||if pos.y > height:|