(FORKED) Rubiks Cube solver for NxNxN cubes https://github.com/dwalton76/rubiks-cube-NxNxN-solver

TODO.txt 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. - 6x6x6 UD edge pairing bulid 70 tables and merge them
  2. - B-Trees...this will benefit all searches
  3. - TPR solver
  4. - how the hell does it work so fast?
  5. - ideas
  6. - before we start IDA we could see which EO edge mapping gives us the
  7. shortest edge heuristic and stick with that one. We would need to go
  8. back to the 0 line dummy table and
  9. LookupTableIDA444TsaiPhase2.experimental_ida_search_complete()
  10. Or we could build out a small lookup table (say 3 moves deep) for that
  11. one edge mapping.
  12. - xyzzy's 5x5x5 solver. It is a variation of the TPR solver so need to understand TPR first.
  13. - he does an EO (edge orientation) step. If all larger solvers that use 5x5x5 for edge
  14. pairing could also do EO then maybe we could toss the edge pairing code...there is a
  15. ton of it and it is hideous.
  16. - bidir IDA search
  17. - I need to understand how the TPR solver works before I spend time on bidir IDA
  18. - would allow us to find slighly shorter solutions than we do today
  19. - may potentially allow us tackle much larger IDA searches...TBD
  20. - first to try is staging all 5x5x5 centers via one phase
  21. - second to try is staging all 5x5x5 centers via one phase
  22. - combine phases 1 and 2 of tsai?
  23. - start from a solved cube and work your way back to the scrambled cube
  24. - requires us to build prune tables for each scrambled cube
  25. - for 4x4x4 staging centers we can do this in XYZ minutes in python
  26. - if we only build it out 4 steps deep we can do it in ~20s
  27. - so this would have to be done in C and even then it would still
  28. take some time. I think this is a strategy that could only be
  29. used in a fewest moves challenge given how long it will take to
  30. produce solutions.
  31. B-Tree notes
  32. ============
  33. - optimaly load the B-Trees
  34. - support for loading the first two levels in memory and finding the rest on disk
  35. - Once the two bullets above are done we should be able to find a key via
  36. a single seek(). We should also be able to only do one rstrip/split(',')
  37. call, it should only happen when 'if key in key_line' is True.
  38. Today we take ~14s where our time is in:
  39. 974730 0.533 0.000 0.533 0.000 {method 'seek' of '_io.BufferedReader' objects}
  40. 1431684 0.721 0.000 0.721 0.000 {method 'decode' of 'bytes' objects}
  41. 127280/3 0.733 0.000 17.547 5.849 LookupTable.py:675(ida_search)
  42. 779505 0.920 0.000 0.920 0.000 {method 'read' of '_io.BufferedReader' objects}
  43. 1307535 1.435 0.000 1.435 0.000 {method 'rstrip' of 'str' objects}
  44. 915393 1.451 0.000 1.451 0.000 {built-in method builtins.next}
  45. 1372371 2.557 0.000 2.557 0.000 {method 'split' of 'str' objects}
  46. 195231 3.299 0.000 11.243 0.000 __init__.py:67(disk_get)
  47. ncalls tottime percall cumtime percall filename:lineno(function)
  48. So we should end up with
  49. - seek() : should come down to 195231...should shave about 300ms
  50. - decode() : Will 'if key in key_line' work if it is not decoded to utf-8?
  51. If so we can avoid all of these calls....should shave 721ms.
  52. - read() : should come down to 195231...should shave about 600ms
  53. - rstrip() : can only call this 'if key in key_line' which should chop 99% of them..should shave 1435ms
  54. - next() : is called today to load the nodes line...we can avoid this if we know that we are already at the leaf node depth
  55. This should shave 1451ms
  56. - split() : can only call this 'if key in key_line' which should chop 99% of them..should shave 2557ms
  57. That is about ~7000ms we can shave...would get us from 14s down to 7s which would be awesome
  58. - Test this against slow 6x6x6 UD oblique:
  59. ./usr/bin/rubiks-cube-solver.py --cpu-max --state FBDDDFFUDRFBBLFLLURLDLLUFBLRFDUFLBLLFBFLRRBBFDRRDUBUFRBUBRDLUBFDRLBBRLRUFLBRBDUDFFFDBLUDBBLRDFUUDLBBBRRDRUDLBLDFRUDLLFFUUBFBUUFDLRUDUDBRRBBUFFDRRRDBULRRURULFDBRRULDDRUUULBLLFDFRRFDURFFLDUUBRUFDRFUBLDFULFBFDDUDLBLLRBL
  60. 2017-12-17 09:52:42,776 RubiksCube666.py INFO: UD inner x-centers staged, 5 steps in
  61. 2017-12-17 09:52:42,777 LookupTable.py INFO: 6x6x6-step25-UD-oblique-edge-pairing: IDA threshold range 7->99
  62. 2017-12-17 09:52:43,134 LookupTable.py INFO: 6x6x6-step25-UD-oblique-edge-pairing: IDA threshold 7, explored 2882 branches, took 356ms
  63. 2017-12-17 09:52:52,335 LookupTable.py INFO: 6x6x6-step25-UD-oblique-edge-pairing: IDA threshold 8, explored 86762 branches, took 0:00:09.201718
  64. 2017-12-17 09:52:55,953 LookupTable.py INFO: 6x6x6-step25-UD-oblique-edge-pairing: IDA found match 6 steps in, f_cost 10 (6 + 4)
  65. 2017-12-17 09:52:55,953 LookupTable.py INFO: 6x6x6-step25-UD-oblique-edge-pairing: IDA threshold 9, explored 37636 branches, took 0:00:03.617328 (0:00:13.176431 total)
  66. This search takes about 5 million seek() calls when using binary search...the seeks are the top bottleneck thus the need to move to B-Trees
  67. misc notes
  68. ==========
  69. - ida_search() needs to return all of the results at that theshold
  70. Test on this one, 5x5x5-step20-LR-centers-stage finds a solution 12 steps long but I know there is one
  71. that is 10 steps long (I found it via AStar)
  72. ./usr/bin/rubiks-cube-solver.py --state RFFFUDUDURBFULULFDBLRLDUFDBLUBBBDDURLRDRFRUDDBFUFLFURRLDFRRRUBFUUDUFLLBLBBULDDRRUFUUUBUDFFDRFLRBBLRFDLLUUBBRFRFRLLBFRLBRRFRBDLLDDFBLRDLFBBBLBLBDUUFDDD
  73. I have a partial patch for this (patches/ida_solutions_use_best.patch) but it needs some work.
  74. We need to pseudo combine multiple phases to get shorter solutions. For example
  75. we need to find multiple solutions for staging UD centers and then for each of those find multiple
  76. solutions for staging LR centers and keep the one that allows us to solve the 5x5x5 centers in the
  77. least number of steps. That is a lot of IDA searches though so this all has to happen after
  78. the bplustree work is done.