https://github.com/javisoto/rubikswift
Rubik's cube API in Swift + a genetic solver algorithm
https://github.com/javisoto/rubikswift
genetic-algorithm rubiks-cube swift
Last synced: 3 months ago
JSON representation
Rubik's cube API in Swift + a genetic solver algorithm
- Host: GitHub
- URL: https://github.com/javisoto/rubikswift
- Owner: JaviSoto
- License: mit
- Created: 2016-10-28T22:47:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-31T22:34:57.000Z (over 8 years ago)
- Last Synced: 2025-03-18T08:53:29.818Z (3 months ago)
- Topics: genetic-algorithm, rubiks-cube, swift
- Language: Swift
- Homepage:
- Size: 64.5 KB
- Stars: 79
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RubikSwift
Rubik's cube API in Swift, and an implementation of a [Genetic algorithm](https://en.wikipedia.org/wiki/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](https://rubiks3x3.com/algorithm/?moves=RBuFBfdl12DlF2BUL5BuR404FbFd4051UfLfD2R24f3F2dlb41dfbul14f31L42U0BLU04fL5Ul10RburLub243b5L3uluR43u01fb0BFl1lr24R&initmove=fBLr41fDRdR4145u2Drf) 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.