Skip to content

Conversation

JoseALermaIII
Copy link
Owner

Summary

Finish Chapter 7 with a safe cracker implemented with a hill-climbing algorithm.

Description

Solve a lock combination by randomly changing a tumbler's values one by one and noting whether the safe had a response. If so, lock the tumbler at that value and continue randomly changing tumbler values.

Previously, a locked tumbler can still be changed, but the safe wouldn't respond, so the change would be discarded. This improves upon the algorithm by removing the locked tumbler from the pool of tumblers to randomly change. This small change improved algorithm times by around 66%!

Compared to breeding rats, this has fewer constants to deal with, so it is easily implemented in two functions.

Team Notifications

Me, myself, and I

@JoseALermaIII JoseALermaIII added the enhancement New feature or request label Oct 13, 2019
@JoseALermaIII JoseALermaIII self-assigned this Oct 13, 2019
@JoseALermaIII
Copy link
Owner Author

It's worth noting that this works well because we can test all possible outputs of the tumbler: integers 0 through 9. If the type of output were a large float, we might not be able to reach the correct answer if we were limiting the algorithm to a specific range or precision.

@JoseALermaIII JoseALermaIII merged commit c8a0df6 into master Oct 13, 2019
@JoseALermaIII JoseALermaIII deleted the safe-cracker branch October 13, 2019 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant