Best Virtual Rubik's Cube, program, script, scripting
WWW.ROSSPROGRAMMPRODUCT.COM
Russian

All documentations for the program
"Best Virtual Rubik's Cube"


About...

Manual

How to write scripts

How to solve?

How to write scripts for the Best Virtual Rubik's Cube program.

Related video (quick tutorial) see here:
http://www.youtube.com/watch?v=51iUyUJov90

Description of the Script Editor for the program
"Best Virtual Rubik's Cube."


Overview.

  • To run the Script Editor for Virtual Rubik's Cube, select Script from the Edit menu.
  • The Script Editor window contains two edit controls - multiline edit control on the top and single line edit control under it.
  • Scripts are written in the multiline edit control, single line edit control for error messages.
  • To execute the script click the «Run» button.
  • To open a saved script file, click «Load Script» button.
  • When you click the «Save» button dialog box with a proposal to save the script appeared (If the script was not loaded from a file). If the script was loaded from a file it will be overwrite.
  • If you click the «Save Script as» button dialog box with a proposal to save the script appeared.
  • Script file for the Best Virtual Rubik's Cube has an extension CRS and the icon .
  • Note, that *.CRS is ordinary text file, you can edit it with any text editor.
  • You can run saved scripts without having to load them into the Script Editor. To do it, from File menu select Open - Script for Rubik's Cube.
  • Click «Exit» button to close the Script Editor for Virtual Rubik's Cube.

Options.

  • "Script for current Rubik's Cube." If this option is selected, and if the dimension of the current Virtual Rubik's Cube coincides with the dimension specified in the script, the script will be executed for the current Cube.
    Otherwise, the program will generate a new Virtual Rubik's Cube and the script, thereby will be start "from scratch".
  • "Save current Rubik's Cube." If this option is selected, then every time you run the script, will appear a dialog box with a proposal to save the current Rubik's Cube.
  • "Minimize this window when run a script." The Script Editor will be minimized when you run the script and restored after execution the script.
  • "Enable rotations of the Rubik's Cube." During the execution of the script, the scene with a Rubik's Cube will rotate if this option is selected, and will remain fixed otherwise.

How to write scripts for the Best Virtual Rubik's Cube program. Full guide.


Really, writing scripts for Virtual Rubik's Cube is very simply and easy.

First of all in the Edit menu, select Options item. In the appeared dialog box, select "Enable axes XYZ" option. By clicking on the «OK» button close the dialog panel.

Then, run the Script Editor by selecting Script item from the Edit menu.

Now let's examine sample of script:

 5
(X1+1)
(X3+1)
(X5+1)
(Y1+1)
(Y3+1)
(Y5+1)
(Z1+1)
(Z3+1)
(Z5+1)
(X1+1)
(X3+1)
(X5+1)

Copy it and, via the clipboard, paste it into the multiline edit control of Script Editor. Execute the script by clicking the "Run" button. OK?

Let us consider the script in detail.

First of all, pay attention to the first line of the script. At the beginning of the script always must be some number, determining the dimension of the Virtual Rubik's Cube. In the example above, this number is five, and as you saw, the dimension Cube became 5x5x5.

Next, the script has a series of expressions in parentheses.

Each of them is the command that determines the rotation of the selected layer (or layers!) Virtual Rubik's Cube about the selected axis at a given angle.

For example, "X3" in command "(X3 + 1)" means that you want to turn the third layer about "X" axis, and "Y5" in the command "(Y5 + 1)" means a rotation the fifth layer about the axis "Y", etc.

Layers numbered in ascending order, starting with 1 in the positive direction of the axis.

If you have not understand in the text, then just look at the picture on the left, which all the layers of Cube are numbered.

For example, as seen from the picture, the axis "Y" comes from the below to the upwards and so the "Y1" is the lowest layer, and "Y5" - the very top.

Note: you can use both uppercase and lowercase letters, and, therefore, for example, the commands (Z5 +1) and (z5 +1) are equivalent.

At the end of each command is an expression that specifies the rotation angle of the selected layers:

"+1" here means rotation by +90 degrees, and "– 1" will turn the selected layer to -90 degrees.

Positive and negative rotations are determined as usual, accepted the agreement in mathematics: if the axis of rotation is aimed at the observer, counter-clockwise rotations is a positive, and clock-wise rotations is a negative.

The figure below shows the rotations at +90 degrees (left), at -90 degrees (right) and their designation in the scripts.



You can also with expressions of "+2" and "–2" set a 180 degree rotation. Of course, the "+" and "–" in these expressions do not matter (because the rotation by 180 degrees is the same as rotation -180 degrees), but must be present - this is hard rule!

So, for example, the following two scripts ultimately produce an entirely the same effect, although the layers in each of them rotate in opposite directions:

5
(X1+2)
(X3+2)
(X5+2)
(Y1+2)
(Y3+2)
(Y5+2)
(Z1+2)
(Z3+2)
(Z5+2)
5
(X1-2)
(X3-2)
(X5-2)
(Y1-2)
(Y3-2)
(Y5-2)
(Z1-2)
(Z3-2)
(Z5-2)

Other turns in the script can not be specified, so any script command must have in the end "1" or "2".

In all scripts above, each command determined the rotation of a single layer. However, you can turn several layers, if these layers are located directly next to each other.

Here is an example of this command:
(2X3+1)
Here the "X3 +1" as usually defines the rotation of the third layer about the "X" axis to +90°, and the positive number "2" at the beginning of the command means, that you want to rotate two layers additionally. These two layers arranged beyond the third layer - that is, the fourth and fifth layers. Thus, this command turns right three layers.

Command
(-2X3+1) also turn on the +90° right three layers, but since the number of at the beginning of the command is negative, they already will be located on the other side third layer - the first and second layers.

The picture below shows three examples of the implementation of three scripts:
5 (2 X 3 +1) (left), 5 (-2 Y 3 +1) (center) and 5 (-2 Z 4 +1) (right).

Two scripts below, the different at first glance, in fact, completely equivalent:

 5
(2X2+1)
(2Y2+1)
(2X2-1)
(2Y2-1)

 5
(-2X4+1)
(-2Y4+1)
(-2X4-1)
(-2Y4-1)

You can write a script, not only in the column, but in one or more lines, use any number of spaces both outside and inside parentheses, parentheses themselves can be arbitrary: round brackets - () or square brackets - [] or braces - {}.

Finally, you can include in the script any comments, such as your name and the date of writing, but comment can not be in the beginning of the script, and inside the parentheses and themselves can not contain brackets.

Here is a sample script with comments:

12           Defined cube 12x12x12
(3X5-1)   The rotation about the X axis of the 5th, 6th, 7th and 8th layers in the -90°
(3Y5-1)   The rotation about the Y axis of the 5th, 6th, 7th and 8th layers in the -90°
(3Z5-1)   The rotation about the Z axis of the 5th, 6th, 7th and 8th layers in the -90°
(3X5+2)  The rotation about the X axis of the 5th, 6th, 7th and 8th layers in the 180°
(3Y5+2)  The rotation about the Y axis of the 5th, 6th, 7th and 8th layers in the 180°
(3Z5+2)  The rotation about the Z axis of the 5th, 6th, 7th and 8th layers in the 180°
(3X5+1)  The rotation about the X axis of the 5th, 6th, 7th and 8th layers in the +90°
(3Y5+1)  The rotation about the Y axis of the 5th, 6th, 7th and 8th layers in the +90°
(3Z5+1)  The rotation about the Z axis of the 5th, 6th, 7th and 8th layers in the +90°

Copyright © 2012 ROSSPROGRAMMPRODUCT ®.

This script will be executed without any problem, because all that is not at the beginning of the script and is not enclosed in the parentheses the program just will skip.

Summary.


  1. At the beginning of the script always must be some number, determining the dimension of the Virtual Rubik's Cube.
  2. Each expression in parentheses is the command that determines the rotation of a selected number of layer (or layers) of a cube about a selected axis at a given angle.
  3. Parentheses can be anything: round brackets, square brackets or braces.
  4. Inside the parentheses is permissible to use only the following characters:
    • spaces;
    • numbers 0,1,2,3,4,5,6,7,8,9,0;
    • signs "+" è "–";
    • Letters of the alphabet "X", "x", "Y", "y", "Z", "z".
    Other characters are not allowed inside the parentheses.
  5. If a command has to turn to only one layer, then it must begin by one of the letters - "X", "x", "Y", "y", "Z", "z", defining the axis of rotation.
  6. After the letter is a number that specifies the number of rotated layer, herewith layers are numbered in ascending order, starting with 1 in the positive direction of the axis.
  7. At the end of each command is an expression that determines the angle of rotation:
    • "+1" specifies the turn by +90°;
    • "–1" specifies the turn by –90°;
    • "+2" and "–2" specifies the turn by 180°.
    Other expressions in the end of the are not allowed.
  8. It is possible to turn with one command of several layers, provided that these layers are located directly next to each other. The number that stands at the beginning of this command specifies the number of additional rotated layers. If this number is positive, it will be rotated additional layers, located on this side of the selected layer, which directed the axis of rotation, otherwise will be rotated layers, located on the another side.
  9. You can write a script in a column or in one or more lines, use any number of spaces both outside and inside the parentheses.
  10. Comments can not be in the beginning of the script, and inside the parentheses and can not contain parentheses themselves.

Examples of scripts for the
"Best Virtual Rubik's Cube."

You can find examples of interesting scripts here. Currently, there are scripts for a Rubik's Cube such dimension:

2x2x2
3x3x3
4x4x4
5x5x5
6x6x6
7x7x7
8x8x8
9x9x9
10x10x10
11x11x11
12x12x12


This article was translated from Russian into English with Google translator. Sorry for possible mistakes.




Copyright © 2012 ROSSPROGRAMMPRODUCT ®.


About...

Manual

How to write scripts

How to solve?