Building the Right Environment to Support AI, Machine Learning and Deep Learning
Last Updated: December 17, 2013
Originally Published: October 18th, 2010
The graphic part is ensured by the CCubes class and is helped in the classes CMatrix, CSide, CVertex and CVertexList. This gives an example of the functions to be performed to ensure a vision in prospect 3D or in flat unrolled. Rubik's cubic can be moved or deformed by using orders or of the mouse with a surprising fluidity. The Cube state running is stored in a table of 27 elements of the type t_Mask representative in a compacted way the relative position and the orientation of the 27 elementary cubies. Moreover, two 3*3 matrices, external with the CCubes class, lay down the general orientation of the Cube and the relative orientation of the part moving. At the end of a deformation, the table of the 27 elementary cubies is updated and the deformation matrix set to zero.
The application uses Comput(mask) function of the class CCubes to compute the view of the Cube in a move or a deformation. The mask gives the side of cubies as a deformation part.
After, at the end of the move, the application uses the Fixe(mask) function to update the internal data of the classe CCubes (the m_cube table).
It uses Comput2D() function to compute the Rubik's cube in a flat unrolled view
Main window with 3D prospect an flat unrolled view. The Dialog view is used to deformation or resolution of the Cube
To define the Cube display.
The general structure uses the MFC architecture. The Commands windows allows you to initialize the state of the Cube from the keyboard or from a flatbed scanner equipped with a TWAIN driver or finally to find an allowing solution of the cleaned up Cube. The report can be saved in a file in binary mode (simple copy the table of the elementary cubies) or ASCII (coding of colors facets) or in the form of 6 images of every face, stored in a file TIFF.
Scanner input Dialog view.
Keyboard input Dialog view.
The program also includes several function resolutions derived from free versions available on the Web, adapted and optimized to improve speed of resolution and to working in multiprocessor :
- XSolver(int slide) provides the resolution by steps as is done by hand.
- KSolve(const CCubes *pCubes, CEdit *pEdit, BYTE nbOfProcs) gives a quick solution, especially optimized if we give it time.
- Centers::ResolveCenters(DWORD centers, CCmdString &out) const gives a solution to restore order to the centers of faces.
- QSolve(const CString &cmd, CEdit *pEdit, BYTE numberOfProcessors) determines the shortest solution in terms of quarter turns of faces.
Example of ”Superflip” resolution by QSolve (PC with AMD Phenom(tm) II XA p55, 4 processors, 3.20GHz and 3.25Go of RAM).
This program enables communication and exchange of information with other programs and the Internet, thanks to the clipboard, drag & drop possibilities, input or output files and even allows to print a sheet with the displayed Rubik's Cube.
Formats of exchanges for encoding a Rubik's Cube is very different :
- in TIFF file (*.tif) the 6 images of each face of an Cube
- in ASCII file (*.txt) the table of 54 colors of facets (sides, colors format ie : L:OWGGORWGB F:YROGGOWRR...),
- in standard Singmaster format (*.sgm),
- in Maneuvre format (*.man) formula giving the following movements face necessary,
- in Images formats (*.bmp, *.jpg, *.gig, *.png) for image of the held flat of Rubik's Cube,
- in internal format (*.rbx), the copy of the internal m_cube table (one ascii char per cubie),
- the six used colors code (*.col) coded in hexa.
Finally, through the CGIF89a class that allows to write and read an animated GIF file, this program allows you to create a GIF file showing the preferred sequence of movements.
Example of an animation created, showing the famous Superflip which allows the same command sequence to achieve the figure and then solve it.
Of course, the program includes a dialogue window adapted to define the file name, all the parameters of the animation, the dimensions of the image and the command sequence expressed in the language of the Rubik's Cube.