Skip to content

Rubik's cube API in Swift + a genetic solver algorithm

License

Notifications You must be signed in to change notification settings

JaviSoto/RubikSwift

Repository files navigation

RubikSwift

Rubik's cube API in Swift, and an implementation of a Genetic algorithm to attempt to solve a given scramble of a cube.

Genetic algorithm

The current implementation is very naive. It doesn't have any understanding of how to solve a cube. It essentially generates random sequences of moves, and calculates the "fitness" of each individual based on the number of pieces that are solved. The best ones are mutated by appending more random moves to the solution.

The best solution it's found is solving 16 pieces (out of the 20 in a cube) in 18 minutes. I tried running it for >10h but never got further than that. It's currently able to try ~18k solutions per second.

Instructions

  • Open Xcode project and run the RubikSwiftCLIBundle scheme.

TODO

This project was simply a weekend fun prototype. If you'd like to use the RubikSwift.framework in your application, I would be happy to add Carthage and/or CocoaPods support to it.

About

Rubik's cube API in Swift + a genetic solver algorithm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published