Group Abstract Group Abstract

Message Boards Message Boards

Rubiks Cubes and OOP in Mathematica

Posted 6 years ago
POSTED BY: b3m2a1 ​ 
4 Replies
Posted 6 years ago

If you look inside the things:

RubiksCubes`RubiksCube @ <|
    "Size" -> 4,
    "Origin" -> {0., 0., 0.},
    "Colors" -> {
       RGBColor[0.4, 0.4, 0.4],
       RGBColor[0.291989, 0.437977, 0.888609],
       RGBColor[0.800498, 0.201504, 0.192061],
       RGBColor[0.578462, 0.85539, 0.408855],
       RGBColor[0.658708, 0.492173, 0.842842],
       RGBColor[0.8913, 0.631904, 0.627399],
       RGBColor[0.546138, 0.844244, 0.892092]
    },
    "Cuboids" -> {
       {
         {
          RubiksCubes`Private`RubiksCuboid[
              <|
                 "Coordinates" -> {\[Ellipsis] " -> {1, 3, 5, 1, 1, 1},
              "Version" -> 1
          |>,
          RubiksCubes`Private`RubiksCuboid @ <|
              "Coordinates" -> {
                 {1.025, 1.025, 1.025},
                 {1.025, 1.025, 1.975},
                 {1.025, 1.975, 1.025},
                 {1.025, 1.975, 1.975},
                 {1.975, 1.025, 1.025},
                 {1.975, 1.025, 1.975},
                 {1.975, 1.975, 1.025},
                 {1.975, 1.975, 1.975}
              },
              "ColorIndices" -> {7, 3, 5, 1, 1, 1},
              "Version" -> 1
          |>
         }
       }
    },
    "Version" -> 1
|>

You see that in fact they're stored as just and Association of data, basically. Now, of course, Mathematica does treat every expression as an object that you can attach properties to and so if you use SetProperty on the thing to store its properties you won't actually recover those since I treat them as invisible state.

But in general, yes, these serialize very well.

POSTED BY: b3m2a1 ​ 

Can the objects be easily serialized?

POSTED BY: Vincent Virgilio

Is there a way of adding letter labels to each sticker on the cube so that they rotate together with the cube? I am trying to solve the following puzzle, and so far I don't really know how to approach it and want to visualize it. Here is the puzzle: Consider a Rubik's cube on which all stickers are white (no colors). A password (some combination of letters and numbers) is written on the stickers of such a Rubik's cube (one letter per sticker, the orientation of letters on every face is the same), and after that the cube is reshuffled. The task is to restore the password, i.e. solve the cube based not on the colors but on the orientation of stickers. In real life, some stickers will have a unique orientation (letters F, P, R, etc.) but some may have ambiguous orientation due to internal symmetries (letters N, S, T, etc.). I want to visualize that in Mathematica to play with this kind of puzzle. I am trying to get a feeling how many possible solutions exist and what the solution strategy could be.

POSTED BY: Dmytro Inosov

enter image description here - Congratulations! This post is now a Staff Pick as distinguished by a badge on your profile! Thank you, keep it coming, and consider contributing your work to the The Notebook Archive!

POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard