function set_cubie($image, $face, $cols) {
$color = array(
imagecolorallocate($image, 155, 155, 155), // gray
imagecolorallocate($image, 255, 255, 0), // yellow // 0, 0, 188), // blue
imagecolorallocate($image, 255, 127, 0), // orange
imagecolorallocate($image, 0, 0, 188), // blue // 255, 255, 0), // yellow
imagecolorallocate($image, 255, 255, 255), // white
imagecolorallocate($image, 220, 0, 0), // red
imagecolorallocate($image, 0, 112, 0), // green
imagecolorallocate($image, 0, 0, 0)); // black
if ($face == 'U') {
$s1 = array(70,10, 50,20, 70,30, 90,20);
$s2 = array(90,20, 70,30, 90,40, 110,30);
$s3 = array(110,30, 90,40, 110,50, 130,40);
$s4 = array(50,20, 30,30, 50,40, 70,30);
$s5 = array(70,30, 50,40, 70,50, 90,40);
$s6 = array(90,40, 70,50, 90,60, 110,50);
$s7 = array(30,30, 10,40, 30,50, 50,40);
$s8 = array(50,40, 30,50, 50,60, 70,50);
$s9 = array(70,50, 50,60, 70,70, 90,60);
} elseif ($face == 'F') {
$s1 = array(10,40, 10,60, 30,70, 30,50);
$s2 = array(30,50, 30,70, 50,80, 50,60);
$s3 = array(50,60, 50,80, 70,90, 70,70);
$s4 = array(10,60, 10,80, 30,90, 30,70);
$s5 = array(30,70, 30,90, 50,100, 50,80);
$s6 = array(50,80, 50,100, 70,110, 70,90);
$s7 = array(10,80, 10,100, 30,110, 30,90);
$s8 = array(30,90, 30,110, 50,120, 50,100);
$s9 = array(50,100, 50,120, 70,130, 70,110);
} else {
$s1 = array(110,50, 110,70, 130,60, 130,40);
$s2 = array(110,70, 110,90, 130,80, 130,60);
$s3 = array(110, 90, 110,110, 130,100, 130,80);
$s4 = array( 90,60, 90,80, 110,70, 110,50);
$s5 = array( 90,80, 90,100, 110,90, 110,70);
$s6 = array( 90,100, 90,120, 110,110, 110,90);
$s7 = array( 70,70, 70,90, 90,80, 90,60);
$s8 = array( 70,90, 70,110, 90,100, 90,80);
$s9 = array( 70,110, 70,130, 90,120, 90,100);
}
imagefilledpolygon($image, $s1, 4, $color[substr($cols, 0, 1)]);
imagefilledpolygon($image, $s2, 4, $color[substr($cols, 1, 1)]);
imagefilledpolygon($image, $s3, 4, $color[substr($cols, 2, 1)]);
imagefilledpolygon($image, $s4, 4, $color[substr($cols, 3, 1)]);
imagefilledpolygon($image, $s5, 4, $color[substr($cols, 4, 1)]);
imagefilledpolygon($image, $s6, 4, $color[substr($cols, 5, 1)]);
imagefilledpolygon($image, $s7, 4, $color[substr($cols, 6, 1)]);
imagefilledpolygon($image, $s8, 4, $color[substr($cols, 7, 1)]);
imagefilledpolygon($image, $s9, 4, $color[substr($cols, 8, 1)]);
}
function set_tenkai($image, $face, $cols, $size) {
$color = array(
imagecolorallocate($image, 155, 155, 155), // gray
imagecolorallocate($image, 255, 255, 0), // yellow // 0, 0, 188), // blue
imagecolorallocate($image, 255, 127, 0), // orange
imagecolorallocate($image, 0, 0, 188), // blue // 255, 255, 0), // yellow
imagecolorallocate($image, 255, 255, 255), // white
imagecolorallocate($image, 220, 0, 0), // red
imagecolorallocate($image, 0, 112, 0), // green
imagecolorallocate($image, 0, 0, 0)); // black
$gray = imagecolorallocate($image, 155, 155, 155); // gray
$x11 = 10;
$x12 = $x11 + $size;
$x13 = $x12 + $size;
$x14 = $x13 + $size;
$x21 = $x14 + 2;
$x22 = $x21 + $size;
$x23 = $x22 + $size;
$x24 = $x23 + $size;
$x31 = $x24 + 2;
$x32 = $x31 + $size;
$x33 = $x32 + $size;
$x34 = $x33 + $size;
$x41 = $x34 + 2;
$x42 = $x41 + $size;
$x43 = $x42 + $size;
$x44 = $x43 + $size;
$y11 = 10;
$y12 = $y11 + $size;
$y13 = $y12 + $size;
$y14 = $y13 + $size;
$y21 = $y14 + 2;
$y22 = $y21 + $size;
$y23 = $y22 + $size;
$y24 = $y23 + $size;
$y31 = $y24 + 2;
$y32 = $y31 + $size;
$y33 = $y32 + $size;
$y34 = $y33 + $size;
if ($face == 'G') {
$base = array($x11,$y21, $x11,$y24, $x14,$y24, $x14,$y21);
imagefilledpolygon($image, $base, 4, $gray); // 多角形を描画します
$base = array($x21,$y11, $x21,$y14, $x24,$y14, $x24,$y11);
imagefilledpolygon($image, $base, 4, $gray); // 多角形を描画します
$base = array($x21,$y21, $x21,$y24, $x24,$y24, $x24,$y21);
imagefilledpolygon($image, $base, 4, $gray); // 多角形を描画します
$base = array($x21,$y31, $x21,$y34, $x24,$y34, $x24,$y31);
imagefilledpolygon($image, $base, 4, $gray); // 多角形を描画します
$base = array($x31,$y21, $x31,$y24, $x34,$y24, $x34,$y21);
imagefilledpolygon($image, $base, 4, $gray); // 多角形を描画します
$base = array($x41,$y21, $x41,$y24, $x44,$y24, $x44,$y21);
imagefilledpolygon($image, $base, 4, $gray); // 多角形を描画します
return;
}
if ($face == 'U') {
$x = $x21; $y = $y21;
} elseif ($face == 'F') {
$x = $x21; $y = $y31;
} elseif ($face == 'R') {
$x = $x31; $y = $y21;
} elseif ($face == 'L') {
$x = $x11; $y = $y21;
} elseif ($face == 'B') {
$x = $x21; $y = $y11;
} else {
$x = $x41; $y = $y21;
}
$xx = $x + $size; $xxx = $xx + $size; $xxxx = $xxx + $size;
$yy = $y + $size; $yyy = $yy + $size; $yyyy = $yyy + $size;
$s1 = array($x, $y, $x, $yy, $xx, $yy, $xx, $y);
$s2 = array($xx, $y, $xx, $yy, $xxx, $yy, $xxx, $y);
$s3 = array($xxx,$y, $xxx,$yy, $xxxx,$yy, $xxxx,$y);
$s4 = array($x, $yy, $x, $yyy, $xx, $yyy, $xx, $yy);
$s5 = array($xx, $yy, $xx, $yyy, $xxx, $yyy, $xxx, $yy);
$s6 = array($xxx,$yy, $xxx,$yyy, $xxxx,$yyy, $xxxx,$yy);
$s7 = array($x, $yyy, $x, $yyyy, $xx, $yyyy, $xx, $yyy);
$s8 = array($xx, $yyy, $xx, $yyyy, $xxx, $yyyy, $xxx, $yyy);
$s9 = array($xxx,$yyy, $xxx,$yyyy, $xxxx,$yyyy, $xxxx,$yyy);
imagefilledpolygon($image, $s1, 4, $color[substr($cols, 0, 1)]);
imagefilledpolygon($image, $s2, 4, $color[substr($cols, 1, 1)]);
imagefilledpolygon($image, $s3, 4, $color[substr($cols, 2, 1)]);
imagefilledpolygon($image, $s4, 4, $color[substr($cols, 3, 1)]);
imagefilledpolygon($image, $s5, 4, $color[substr($cols, 4, 1)]);
imagefilledpolygon($image, $s6, 4, $color[substr($cols, 5, 1)]);
imagefilledpolygon($image, $s7, 4, $color[substr($cols, 6, 1)]);
imagefilledpolygon($image, $s8, 4, $color[substr($cols, 7, 1)]);
imagefilledpolygon($image, $s9, 4, $color[substr($cols, 8, 1)]);
}
function cubie_line($image) {
$black = imagecolorallocate($image, 0, 0, 0); // black
imageline($image, 70, 10, 130, 40, $black);
imageline($image, 50, 20, 110, 50, $black);
imageline($image, 30, 30, 90, 60, $black);
imageline($image, 10, 40, 70, 70, $black);
imageline($image, 10, 60, 70, 90, $black);
imageline($image, 10, 80, 70, 110, $black);
imageline($image, 10, 100, 70, 130, $black);
imageline($image, 10, 40, 70, 10, $black);
imageline($image, 30, 50, 90, 20, $black);
imageline($image, 50, 60, 110, 30, $black);
imageline($image, 70, 70, 130, 40, $black);
imageline($image, 70, 90, 130, 60, $black);
imageline($image, 70, 110, 130, 80, $black);
imageline($image, 70, 130, 130, 100, $black);
imageline($image, 10, 40, 10, 100, $black);
imageline($image, 30, 50, 30, 110, $black);
imageline($image, 50, 60, 50, 120, $black);
imageline($image, 70, 70, 70, 130, $black);
imageline($image, 90, 60, 90, 120, $black);
imageline($image, 110, 50, 110, 110, $black);
imageline($image, 130, 40, 130, 100, $black);
}
function tenkai_line($image, $size) {
$black = imagecolorallocate($image, 0, 0, 0); // black
$x11 = 10;
$x12 = $x11 + $size;
$x13 = $x12 + $size;
$x14 = $x13 + $size;
$x21 = $x14 + 2;
$x22 = $x21 + $size;
$x23 = $x22 + $size;
$x24 = $x23 + $size;
$x31 = $x24 + 2;
$x32 = $x31 + $size;
$x33 = $x32 + $size;
$x34 = $x33 + $size;
$x41 = $x34 + 2;
$x42 = $x41 + $size;
$x43 = $x42 + $size;
$x44 = $x43 + $size;
$y11 = 10;
$y12 = $y11 + $size;
$y13 = $y12 + $size;
$y14 = $y13 + $size;
$y21 = $y14 + 2;
$y22 = $y21 + $size;
$y23 = $y22 + $size;
$y24 = $y23 + $size;
$y31 = $y24 + 2;
$y32 = $y31 + $size;
$y33 = $y32 + $size;
$y34 = $y33 + $size;
imageline($image, $x11, $y21, $x14, $y21, $black);
imageline($image, $x11, $y22, $x14, $y22, $black);
imageline($image, $x11, $y23, $x14, $y23, $black);
imageline($image, $x11, $y24, $x14, $y24, $black);
imageline($image, $x21, $y11, $x24, $y11, $black);
imageline($image, $x21, $y12, $x24, $y12, $black);
imageline($image, $x21, $y13, $x24, $y13, $black);
imageline($image, $x21, $y14, $x24, $y14, $black);
imageline($image, $x21, $y21, $x24, $y21, $black);
imageline($image, $x21, $y22, $x24, $y22, $black);
imageline($image, $x21, $y23, $x24, $y23, $black);
imageline($image, $x21, $y24, $x24, $y24, $black);
imageline($image, $x21, $y31, $x24, $y31, $black);
imageline($image, $x21, $y32, $x24, $y32, $black);
imageline($image, $x21, $y33, $x24, $y33, $black);
imageline($image, $x21, $y34, $x24, $y34, $black);
imageline($image, $x31, $y21, $x34, $y21, $black);
imageline($image, $x31, $y22, $x34, $y22, $black);
imageline($image, $x31, $y23, $x34, $y23, $black);
imageline($image, $x31, $y24, $x34, $y24, $black);
imageline($image, $x41, $y21, $x44, $y21, $black);
imageline($image, $x41, $y22, $x44, $y22, $black);
imageline($image, $x41, $y23, $x44, $y23, $black);
imageline($image, $x41, $y24, $x44, $y24, $black);
//-------------------------------------------------
imageline($image, $x11, $y21, $x11, $y24, $black);
imageline($image, $x12, $y21, $x12, $y24, $black);
imageline($image, $x13, $y21, $x13, $y24, $black);
imageline($image, $x14, $y21, $x14, $y24, $black);
imageline($image, $x21, $y11, $x21, $y14, $black);
imageline($image, $x22, $y11, $x22, $y14, $black);
imageline($image, $x23, $y11, $x23, $y14, $black);
imageline($image, $x24, $y11, $x24, $y14, $black);
imageline($image, $x21, $y21, $x21, $y24, $black);
imageline($image, $x22, $y21, $x22, $y24, $black);
imageline($image, $x23, $y21, $x23, $y24, $black);
imageline($image, $x24, $y21, $x24, $y24, $black);
imageline($image, $x21, $y31, $x21, $y34, $black);
imageline($image, $x22, $y31, $x22, $y34, $black);
imageline($image, $x23, $y31, $x23, $y34, $black);
imageline($image, $x24, $y31, $x24, $y34, $black);
imageline($image, $x31, $y21, $x31, $y24, $black);
imageline($image, $x32, $y21, $x32, $y24, $black);
imageline($image, $x33, $y21, $x33, $y24, $black);
imageline($image, $x34, $y21, $x34, $y24, $black);
imageline($image, $x41, $y21, $x41, $y24, $black);
imageline($image, $x42, $y21, $x42, $y24, $black);
imageline($image, $x43, $y21, $x43, $y24, $black);
imageline($image, $x44, $y21, $x44, $y24, $black);
}
function kansei_check($f1, $f2, $f3, $f4, $f5, $f6) {
$ret = 1;
$s = substr($f1, 0, 1);
for ($i = 0; $i < 9; $i++) {
if ($s != substr($f1, $i, 1)) $ret = 0;
if ($ret == 0) return $ret;
}
$s = substr($f2, 0, 1);
for ($i = 0; $i < 9; $i++) {
if ($s != substr($f2, $i, 1)) $ret = 0;
if ($ret == 0) return $ret;
}
$s = substr($f3, 0, 1);
for ($i = 0; $i < 9; $i++) {
if ($s != substr($f3, $i, 1)) $ret = 0;
if ($ret == 0) return $ret;
}
$s = substr($f4, 0, 1);
for ($i = 0; $i < 9; $i++) {
if ($s != substr($f4, $i, 1)) $ret = 0;
if ($ret == 0) return $ret;
}
$s = substr($f5, 0, 1);
for ($i = 0; $i < 9; $i++) {
if ($s != substr($f5, $i, 1)) $ret = 0;
if ($ret == 0) return $ret;
}
$s = substr($f6, 0, 1);
for ($i = 0; $i < 9; $i++) {
if ($s != substr($f6, $i, 1)) $ret = 0;
if ($ret == 0) return $ret;
}
return $ret;
}
function operation($op, $u, $f, $r, $l, $b, $d) {
$len = strlen($op);
for ($i = 0; $i < $len; $i++) {
$c = substr($op, $i, 1);
$c2 = ($i < $len-1) ? substr($op, $i+1, 1) : "";
if ($c == "'") continue;
if ($c == "2") continue;
if ($c == "Z") {
$now = substr($op, $i, 3);
$i += 2;
} elseif ($c == '(') {
$i++;
$c = substr($op, $i, 1);
$now = '(' . $c;
while ($c != ')') {
$i++;
$c = substr($op, $i, 1);
$now .= $c;
if ($i > $len) break;
}
} else {
$now = $c;
if ($c2 == "'") $now .= $c2;
if ($c2 == "2") $now .= $c2;
}
$ufrlbd = unit_operation($now, $u, $f, $r, $l, $b, $d);
$u = substr($ufrlbd, 0, 9);
$f = substr($ufrlbd, 9, 9);
$r = substr($ufrlbd, 18, 9);
$l = substr($ufrlbd, 27, 9);
$b = substr($ufrlbd, 36, 9);
$d = substr($ufrlbd, 45, 9);
}
return $u . $f . $r . $l . $b . $d;
}
function unit_operation($op, $u, $f, $r, $l, $b, $d) {
$nu = $u; $nf = $f; $nr = $r;
$nl = $l; $nb = $b; $nd = $d;
// echo "Now : " . $op . "
";
if ($op == 'F') {
$nf = substr($f, 6, 1) . substr($f, 3, 1) . substr($f, 0, 1) .
substr($f, 7, 1) . substr($f, 4, 1) . substr($f, 1, 1) .
substr($f, 8, 1) . substr($f, 5, 1) . substr($f, 2, 1);
$nu = substr($u, 0, 6) . substr($l, 6, 3);
$nr = substr($r, 0, 6) . substr($u, 6, 3);
$nd = substr($d, 0, 6) . substr($r, 6, 3);
$nl = substr($l, 0, 6) . substr($d, 6, 3);
} elseif ($op == "F'") {
$nf = substr($f, 2, 1) . substr($f, 5, 1) . substr($f, 8, 1) .
substr($f, 1, 1) . substr($f, 4, 1) . substr($f, 7, 1) .
substr($f, 0, 1) . substr($f, 3, 1) . substr($f, 6, 1);
$nu = substr($u, 0, 6) . substr($r, 6, 3);
$nr = substr($r, 0, 6) . substr($d, 6, 3);
$nd = substr($d, 0, 6) . substr($l, 6, 3);
$nl = substr($l, 0, 6) . substr($u, 6, 3);
} elseif ($op == "F2") {
$nf = substr($f, 8, 1) . substr($f, 7, 1) . substr($f, 6, 1) .
substr($f, 5, 1) . substr($f, 4, 1) . substr($f, 3, 1) .
substr($f, 2, 1) . substr($f, 1, 1) . substr($f, 0, 1);
$nu = substr($u, 0, 6) . substr($d, 6, 3);
$nr = substr($r, 0, 6) . substr($l, 6, 3);
$nd = substr($d, 0, 6) . substr($u, 6, 3);
$nl = substr($l, 0, 6) . substr($r, 6, 3);
} elseif ($op == "U") {
$nu = substr($u, 6, 1) . substr($u, 3, 1) . substr($u, 0, 1) .
substr($u, 7, 1) . substr($u, 4, 1) . substr($u, 1, 1) .
substr($u, 8, 1) . substr($u, 5, 1) . substr($u, 2, 1);
$nr = substr($b, 6, 1) . substr($r, 1, 2) .
substr($b, 7, 1) . substr($r, 4, 2) .
substr($b, 8, 1) . substr($r, 7, 2);
$nf = substr($r, 6, 1) . substr($r, 3, 1) . substr($r, 0, 1) .
substr($f, 3, 6);
$nl = substr($l, 0, 2) . substr($f, 0, 1) .
substr($l, 3, 2) . substr($f, 1, 1) .
substr($l, 6, 2) . substr($f, 2, 1);
$nb = substr($b, 0, 6) . substr($l, 8, 1) .
substr($l, 5, 1) . substr($l, 2, 1);
} elseif ($op == "U'") {
$nu = substr($u, 2, 1) . substr($u, 5, 1) . substr($u, 8, 1) .
substr($u, 1, 1) . substr($u, 4, 1) . substr($u, 7, 1) .
substr($u, 0, 1) . substr($u, 3, 1) . substr($u, 6, 1);
$nr = substr($f, 2, 1) . substr($r, 1, 2) .
substr($f, 1, 1) . substr($r, 4, 2) .
substr($f, 0, 1) . substr($r, 7, 2);
$nf = substr($l, 2, 1) . substr($l, 5, 1) . substr($l, 8, 1) .
substr($f, 3, 6);
$nl = substr($l, 0, 2) . substr($b, 8, 1) .
substr($l, 3, 2) . substr($b, 7, 1) .
substr($l, 6, 2) . substr($b, 6, 1);
$nb = substr($b, 0, 6) . substr($r, 0, 1) .
substr($r, 3, 1) . substr($r, 6, 1);
} elseif ($op == "U2") {
$nu = substr($u, 8, 1) . substr($u, 7, 1) . substr($u, 6, 1) .
substr($u, 5, 1) . substr($u, 4, 1) . substr($u, 3, 1) .
substr($u, 2, 1) . substr($u, 1, 1) . substr($u, 0, 1);
$nr = substr($l, 8, 1) . substr($r, 1, 2) .
substr($l, 5, 1) . substr($r, 4, 2) .
substr($l, 2, 1) . substr($r, 7, 2);
$nf = substr($b, 8, 1) . substr($b, 7, 1) . substr($b, 6, 1) .
substr($f, 3, 6);
$nl = substr($l, 0, 2) . substr($r, 6, 1) .
substr($l, 3, 2) . substr($r, 3, 1) .
substr($l, 6, 2) . substr($r, 0, 1);
$nb = substr($b, 0, 6) . substr($f, 2, 1) .
substr($f, 1, 1) . substr($f, 0, 1);
} elseif ($op == "R") {
$nr = substr($r, 6, 1) . substr($r, 3, 1) . substr($r, 0, 1) .
substr($r, 7, 1) . substr($r, 4, 1) . substr($r, 1, 1) .
substr($r, 8, 1) . substr($r, 5, 1) . substr($r, 2, 1);
$nu = substr($u, 0, 2) . substr($f, 2, 1) .
substr($u, 3, 2) . substr($f, 5, 1) .
substr($u, 6, 2) . substr($f, 8, 1);
$nf = substr($f, 0, 2) . substr($d, 6, 1) .
substr($f, 3, 2) . substr($d, 3, 1) .
substr($f, 6, 2) . substr($d, 0, 1);
$nd = substr($b, 8, 1) . substr($d, 1, 2) .
substr($b, 5, 1) . substr($d, 4, 2) .
substr($b, 2, 1) . substr($d, 7, 2);
$nb = substr($b, 0, 2) . substr($u, 2, 1) .
substr($b, 3, 2) . substr($u, 5, 1) .
substr($b, 6, 2) . substr($u, 8, 1);
} elseif ($op == "R'") {
$nr = substr($r, 2, 1) . substr($r, 5, 1) . substr($r, 8, 1) .
substr($r, 1, 1) . substr($r, 4, 1) . substr($r, 7, 1) .
substr($r, 0, 1) . substr($r, 3, 1) . substr($r, 6, 1);
$nu = substr($u, 0, 2) . substr($b, 2, 1) .
substr($u, 3, 2) . substr($b, 5, 1) .
substr($u, 6, 2) . substr($b, 8, 1);
$nf = substr($f, 0, 2) . substr($u, 2, 1) .
substr($f, 3, 2) . substr($u, 5, 1) .
substr($f, 6, 2) . substr($u, 8, 1);
$nd = substr($f, 8, 1) . substr($d, 1, 2) .
substr($f, 5, 1) . substr($d, 4, 2) .
substr($f, 2, 1) . substr($d, 7, 2);
$nb = substr($b, 0, 2) . substr($d, 6, 1) .
substr($b, 3, 2) . substr($d, 3, 1) .
substr($b, 6, 2) . substr($d, 0, 1);
} elseif ($op == "R2") {
$nr = substr($r, 8, 1) . substr($r, 7, 1) . substr($r, 6, 1) .
substr($r, 5, 1) . substr($r, 4, 1) . substr($r, 3, 1) .
substr($r, 2, 1) . substr($r, 1, 1) . substr($r, 0, 1);
$nu = substr($u, 0, 2) . substr($d, 6, 1) .
substr($u, 3, 2) . substr($d, 3, 1) .
substr($u, 6, 2) . substr($d, 0, 1);
$nf = substr($f, 0, 2) . substr($b, 2, 1) .
substr($f, 3, 2) . substr($b, 5, 1) .
substr($f, 6, 2) . substr($b, 8, 1);
$nd = substr($u, 8, 1) . substr($d, 1, 2) .
substr($u, 5, 1) . substr($d, 4, 2) .
substr($u, 2, 1) . substr($d, 7, 2);
$nb = substr($b, 0, 2) . substr($f, 2, 1) .
substr($b, 3, 2) . substr($f, 5, 1) .
substr($b, 6, 2) . substr($f, 8, 1);
} elseif ($op == "L") {
$nl = substr($l, 6, 1) . substr($l, 3, 1) . substr($l, 0, 1) .
substr($l, 7, 1) . substr($l, 4, 1) . substr($l, 1, 1) .
substr($l, 8, 1) . substr($l, 5, 1) . substr($l, 2, 1);
$nu = substr($b, 0, 1) . substr($u, 1, 2) .
substr($b, 3, 1) . substr($u, 4, 2) .
substr($b, 6, 1) . substr($u, 7, 2);
$nf = substr($u, 0, 1) . substr($f, 1, 2) .
substr($u, 3, 1) . substr($f, 4, 2) .
substr($u, 6, 1) . substr($f, 7, 2);
$nd = substr($d, 0, 2) . substr($f, 6, 1) .
substr($d, 3, 2) . substr($f, 3, 1) .
substr($d, 6, 2) . substr($f, 0, 1);
$nb = substr($d, 8, 1) . substr($b, 1, 2) .
substr($d, 5, 1) . substr($b, 4, 2) .
substr($d, 2, 1) . substr($b, 7, 2);
} elseif ($op == "L'") {
$nl = substr($l, 2, 1) . substr($l, 5, 1) . substr($l, 8, 1) .
substr($l, 1, 1) . substr($l, 4, 1) . substr($l, 7, 1) .
substr($l, 0, 1) . substr($l, 3, 1) . substr($l, 6, 1);
$nu = substr($f, 0, 1) . substr($u, 1, 2) .
substr($f, 3, 1) . substr($u, 4, 2) .
substr($f, 6, 1) . substr($u, 7, 2);
$nf = substr($d, 8, 1) . substr($f, 1, 2) .
substr($d, 5, 1) . substr($f, 4, 2) .
substr($d, 2, 1) . substr($f, 7, 2);
$nd = substr($d, 0, 2) . substr($b, 6, 1) .
substr($d, 3, 2) . substr($b, 3, 1) .
substr($d, 6, 2) . substr($b, 0, 1);
$nb = substr($u, 0, 1) . substr($b, 1, 2) .
substr($u, 3, 1) . substr($b, 4, 2) .
substr($u, 6, 1) . substr($b, 7, 2);
} elseif ($op == "L2") {
$nl = substr($l, 8, 1) . substr($l, 7, 1) . substr($l, 6, 1) .
substr($l, 5, 1) . substr($l, 4, 1) . substr($l, 3, 1) .
substr($l, 2, 1) . substr($l, 1, 1) . substr($l, 0, 1);
$nu = substr($d, 8, 1) . substr($u, 1, 2) .
substr($d, 5, 1) . substr($u, 4, 2) .
substr($d, 2, 1) . substr($u, 7, 2);
$nf = substr($b, 0, 1) . substr($f, 1, 2) .
substr($b, 3, 1) . substr($f, 4, 2) .
substr($b, 6, 1) . substr($f, 7, 2);
$nd = substr($d, 0, 2) . substr($u, 6, 1) .
substr($d, 3, 2) . substr($u, 3, 1) .
substr($d, 6, 2) . substr($u, 0, 1);
$nb = substr($f, 0, 1) . substr($b, 1, 2) .
substr($f, 3, 1) . substr($b, 4, 2) .
substr($f, 6, 1) . substr($b, 7, 2);
} elseif ($op == "B") {
$nb = substr($b, 6, 1) . substr($b, 3, 1) . substr($b, 0, 1) .
substr($b, 7, 1) . substr($b, 4, 1) . substr($b, 1, 1) .
substr($b, 8, 1) . substr($b, 5, 1) . substr($b, 2, 1);
$nu = substr($r, 0, 3) . substr($u, 3, 6);
$nr = substr($d, 0, 3) . substr($r, 3, 6);
$nd = substr($l, 0, 3) . substr($d, 3, 6);
$nl = substr($u, 0, 3) . substr($l, 3, 6);
} elseif ($op == "B'") {
$nb = substr($b, 2, 1) . substr($b, 5, 1) . substr($b, 8, 1) .
substr($b, 1, 1) . substr($b, 4, 1) . substr($b, 7, 1) .
substr($b, 0, 1) . substr($b, 3, 1) . substr($b, 6, 1);
$nu = substr($l, 0, 3) . substr($u, 3, 6);
$nr = substr($u, 0, 3) . substr($r, 3, 6);
$nd = substr($r, 0, 3) . substr($d, 3, 6);
$nl = substr($d, 0, 3) . substr($l, 3, 6);
} elseif ($op == "B2") {
$nb = substr($b, 8, 1) . substr($b, 7, 1) . substr($b, 6, 1) .
substr($b, 5, 1) . substr($b, 4, 1) . substr($b, 3, 1) .
substr($b, 2, 1) . substr($b, 1, 1) . substr($b, 0, 1);
$nu = substr($d, 0, 3) . substr($u, 3, 6);
$nr = substr($l, 0, 3) . substr($r, 3, 6);
$nd = substr($u, 0, 3) . substr($d, 3, 6);
$nl = substr($r, 0, 3) . substr($l, 3, 6);
} elseif ($op == "D") {
$nd = substr($d, 6, 1) . substr($d, 3, 1) . substr($d, 0, 1) .
substr($d, 7, 1) . substr($d, 4, 1) . substr($d, 1, 1) .
substr($d, 8, 1) . substr($d, 5, 1) . substr($d, 2, 1);
$nf = substr($f, 0, 6) . substr($l, 0, 1) .
substr($l, 3, 1) . substr($l, 6, 1);
$nr = substr($r, 0, 2) . substr($f, 8, 1) .
substr($r, 3, 2) . substr($f, 7, 1) .
substr($r, 6, 2) . substr($f, 6, 1);
$nb = substr($r, 2, 1) . substr($r, 5, 1) .
substr($r, 8, 1) . substr($b, 3, 6);
$nl = substr($b, 2, 1) . substr($l, 1, 2) .
substr($b, 1, 1) . substr($l, 4, 2) .
substr($b, 0, 1) . substr($l, 7, 2);
} elseif ($op == "D'") {
$nd = substr($d, 2, 1) . substr($d, 5, 1) . substr($d, 8, 1) .
substr($d, 1, 1) . substr($d, 4, 1) . substr($d, 7, 1) .
substr($d, 0, 1) . substr($d, 3, 1) . substr($d, 6, 1);
$nf = substr($f, 0, 6) . substr($r, 8, 1) . substr($r, 5, 1) . substr($r, 2, 1);
$nr = substr($r, 0, 2) . substr($b, 0, 1) .
substr($r, 3, 2) . substr($b, 1, 1) .
substr($r, 6, 2) . substr($b, 2, 1);
$nb = substr($l, 6, 1) . substr($l, 3, 1) .
substr($l, 0, 1) . substr($b, 3, 6);
$nl = substr($f, 6, 1) . substr($l, 1, 2) .
substr($f, 7, 1) . substr($l, 4, 2) .
substr($f, 8, 1) . substr($l, 7, 2);
} elseif ($op == "D2") {
$nd = substr($d, 8, 1) . substr($d, 7, 1) . substr($d, 6, 1) .
substr($d, 5, 1) . substr($d, 4, 1) . substr($d, 3, 1) .
substr($d, 2, 1) . substr($d, 1, 1) . substr($d, 0, 1);
$nf = substr($f, 0, 6) . substr($b, 2, 1) . substr($b, 1, 1) . substr($b, 0, 1);
$nr = substr($r, 0, 2) . substr($l, 6, 1) .
substr($r, 3, 2) . substr($l, 3, 1) .
substr($r, 6, 2) . substr($l, 0, 1);
$nb = substr($f, 8, 1) . substr($f, 7, 1) .
substr($f, 6, 1) . substr($b, 3, 6);
$nl = substr($r, 8, 1) . substr($l, 1, 2) .
substr($r, 5, 1) . substr($l, 4, 2) .
substr($r, 2, 1) . substr($l, 7, 2);
} elseif ($op == "S") {
$nu = substr($u, 0, 3) . substr($l, 3, 3) . substr($u, 6, 3);
$nr = substr($r, 0, 3) . substr($u, 3, 3) . substr($r, 6, 3);
$nd = substr($d, 0, 3) . substr($r, 3, 3) . substr($d, 6, 3);
$nl = substr($l, 0, 3) . substr($d, 3, 3) . substr($l, 6, 3);
} elseif ($op == "S'") {
$nu = substr($u, 0, 3) . substr($r, 3, 3) . substr($u, 6, 3);
$nr = substr($r, 0, 3) . substr($d, 3, 3) . substr($r, 6, 3);
$nd = substr($d, 0, 3) . substr($l, 3, 3) . substr($d, 6, 3);
$nl = substr($l, 0, 3) . substr($u, 3, 3) . substr($l, 6, 3);
} elseif ($op == "S2") {
$nu = substr($u, 0, 3) . substr($d, 3, 3) . substr($u, 6, 3);
$nr = substr($r, 0, 3) . substr($l, 3, 3) . substr($r, 6, 3);
$nd = substr($d, 0, 3) . substr($u, 3, 3) . substr($d, 6, 3);
$nl = substr($l, 0, 3) . substr($r, 3, 3) . substr($l, 6, 3);
} elseif ($op == "M") {
$nu = substr($u, 0, 1) . substr($b, 1, 1) . substr($u, 2, 2) .
substr($b, 4, 1) . substr($u, 5, 2) . substr($b, 7, 1) . substr($u, 8, 1);
$nf = substr($f, 0, 1) . substr($u, 1, 1) . substr($f, 2, 2) .
substr($u, 4, 1) . substr($f, 5, 2) . substr($u, 7, 1) . substr($f, 8, 1);
$nd = substr($d, 0, 1) . substr($f, 7, 1) . substr($d, 2, 2) .
substr($f, 4, 1) . substr($d, 5, 2) . substr($f, 1, 1) . substr($d, 8, 1);
$nb = substr($b, 0, 1) . substr($d, 7, 1) . substr($b, 2, 2) .
substr($d, 4, 1) . substr($b, 5, 2) . substr($d, 1, 1) . substr($b, 8, 1);
} elseif ($op == "M'") {
$nu = substr($u, 0, 1) . substr($f, 1, 1) . substr($u, 2, 2) .
substr($f, 4, 1) . substr($u, 5, 2) . substr($f, 7, 1) . substr($u, 8, 1);
$nf = substr($f, 0, 1) . substr($d, 7, 1) . substr($f, 2, 2) .
substr($d, 4, 1) . substr($f, 5, 2) . substr($d, 1, 1) . substr($f, 8, 1);
$nd = substr($d, 0, 1) . substr($b, 7, 1) . substr($d, 2, 2) .
substr($b, 4, 1) . substr($d, 5, 2) . substr($b, 1, 1) . substr($d, 8, 1);
$nb = substr($b, 0, 1) . substr($u, 1, 1) . substr($b, 2, 2) .
substr($u, 4, 1) . substr($b, 5, 2) . substr($u, 7, 1) . substr($b, 8, 1);
} elseif ($op == "M2") {
$nu = substr($u, 0, 1) . substr($d, 7, 1) . substr($u, 2, 2) .
substr($d, 4, 1) . substr($u, 5, 2) . substr($d, 1, 1) . substr($u, 8, 1);
$nf = substr($f, 0, 1) . substr($b, 1, 1) . substr($f, 2, 2) .
substr($b, 4, 1) . substr($f, 5, 2) . substr($b, 7, 1) . substr($f, 8, 1);
$nd = substr($d, 0, 1) . substr($u, 7, 1) . substr($d, 2, 2) .
substr($u, 4, 1) . substr($d, 5, 2) . substr($u, 1, 1) . substr($d, 8, 1);
$nb = substr($b, 0, 1) . substr($f, 1, 1) . substr($b, 2, 2) .
substr($f, 4, 1) . substr($b, 5, 2) . substr($f, 7, 1) . substr($b, 8, 1);
} elseif ($op == "E") {
$nf = substr($f, 0, 3) . substr($l, 1, 1) . substr($l, 4, 1) .
substr($l, 7, 1) . substr($f, 6, 3);
$nr = substr($r, 0, 1) . substr($f, 5, 1) . substr($r, 2, 2) .
substr($f, 4, 1) . substr($r, 5, 2) . substr($f, 3, 1) . substr($r, 8, 1);
$nb = substr($b, 0, 3) . substr($r, 1, 1) . substr($r, 4, 1) .
substr($r, 7, 1) . substr($b, 6, 3);
$nl = substr($l, 0, 1) . substr($b, 5, 1) . substr($l, 2, 2) .
substr($b, 4, 1) . substr($l, 5, 2) . substr($b, 3, 1) . substr($l, 8, 1);
} elseif ($op == "E'") {
$nf = substr($f, 0, 3) . substr($r, 7, 1) . substr($r, 4, 1) .
substr($r, 1, 1) . substr($f, 6, 3);
$nr = substr($r, 0, 1) . substr($b, 3, 1) . substr($r, 2, 2) .
substr($b, 4, 1) . substr($r, 5, 2) . substr($b, 5, 1) . substr($r, 8, 1);
$nb = substr($b, 0, 3) . substr($l, 7, 1) . substr($l, 4, 1) .
substr($l, 1, 1) . substr($b, 6, 3);
$nl = substr($l, 0, 1) . substr($f, 3, 1) . substr($l, 2, 2) .
substr($f, 4, 1) . substr($l, 5, 2) . substr($f, 5, 1) . substr($l, 8, 1);
} elseif ($op == "E2") {
$nf = substr($f, 0, 3) . substr($b, 5, 1) . substr($b, 4, 1) .
substr($b, 3, 1) . substr($f, 6, 3);
$nr = substr($r, 0, 1) . substr($l, 7, 1) . substr($r, 2, 2) .
substr($l, 4, 1) . substr($r, 5, 2) . substr($l, 1, 1) . substr($r, 8, 1);
$nb = substr($b, 0, 3) . substr($f, 5, 1) . substr($f, 4, 1) .
substr($f, 3, 1) . substr($b, 6, 3);
$nl = substr($l, 0, 1) . substr($r, 7, 1) . substr($l, 2, 2) .
substr($r, 4, 1) . substr($l, 5, 2) . substr($r, 1, 1) . substr($l, 8, 1);
} elseif (($op == "(u)") || ($op == "y")) {
$nu = substr($u, 6, 1) . substr($u, 3, 1) . substr($u, 0, 1) .
substr($u, 7, 1) . substr($u, 4, 1) . substr($u, 1, 1) .
substr($u, 8, 1) . substr($u, 5, 1) . substr($u, 2, 1);
$nf = substr($r, 6, 1) . substr($r, 3, 1) . substr($r, 0, 1) .
substr($r, 7, 1) . substr($r, 4, 1) . substr($r, 1, 1) .
substr($r, 8, 1) . substr($r, 5, 1) . substr($r, 2, 1);
$nr = substr($b, 6, 1) . substr($b, 3, 1) . substr($b, 0, 1) .
substr($b, 7, 1) . substr($b, 4, 1) . substr($b, 1, 1) .
substr($b, 8, 1) . substr($b, 5, 1) . substr($b, 2, 1);
$nb = substr($l, 6, 1) . substr($l, 3, 1) . substr($l, 0, 1) .
substr($l, 7, 1) . substr($l, 4, 1) . substr($l, 1, 1) .
substr($l, 8, 1) . substr($l, 5, 1) . substr($l, 2, 1);
$nl = substr($f, 6, 1) . substr($f, 3, 1) . substr($f, 0, 1) .
substr($f, 7, 1) . substr($f, 4, 1) . substr($f, 1, 1) .
substr($f, 8, 1) . substr($f, 5, 1) . substr($f, 2, 1);
$nd = substr($d, 2, 1) . substr($d, 5, 1) . substr($d, 8, 1) .
substr($d, 1, 1) . substr($d, 4, 1) . substr($d, 7, 1) .
substr($d, 0, 1) . substr($d, 3, 1) . substr($d, 6, 1);
} elseif (($op == "(u')") || ($op == "y'")) {
$nu = substr($u, 2, 1) . substr($u, 5, 1) . substr($u, 8, 1) .
substr($u, 1, 1) . substr($u, 4, 1) . substr($u, 7, 1) .
substr($u, 0, 1) . substr($u, 3, 1) . substr($u, 6, 1);
$nf = substr($l, 2, 1) . substr($l, 5, 1) . substr($l, 8, 1) .
substr($l, 1, 1) . substr($l, 4, 1) . substr($l, 7, 1) .
substr($l, 0, 1) . substr($l, 3, 1) . substr($l, 6, 1);
$nr = substr($f, 2, 1) . substr($f, 5, 1) . substr($f, 8, 1) .
substr($f, 1, 1) . substr($f, 4, 1) . substr($f, 7, 1) .
substr($f, 0, 1) . substr($f, 3, 1) . substr($f, 6, 1);
$nb = substr($r, 2, 1) . substr($r, 5, 1) . substr($r, 8, 1) .
substr($r, 1, 1) . substr($r, 4, 1) . substr($r, 7, 1) .
substr($r, 0, 1) . substr($r, 3, 1) . substr($r, 6, 1);
$nl = substr($b, 2, 1) . substr($b, 5, 1) . substr($b, 8, 1) .
substr($b, 1, 1) . substr($b, 4, 1) . substr($b, 7, 1) .
substr($b, 0, 1) . substr($b, 3, 1) . substr($b, 6, 1);
$nd = substr($d, 6, 1) . substr($d, 3, 1) . substr($d, 0, 1) .
substr($d, 7, 1) . substr($d, 4, 1) . substr($d, 1, 1) .
substr($d, 8, 1) . substr($d, 5, 1) . substr($d, 2, 1);
} elseif (($op == "(u2)") || ($op == "y2")) {
$nu = substr($u, 8, 1) . substr($u, 7, 1) . substr($u, 6, 1) .
substr($u, 5, 1) . substr($u, 4, 1) . substr($u, 3, 1) .
substr($u, 2, 1) . substr($u, 1, 1) . substr($u, 0, 1);
$nf = substr($b, 8, 1) . substr($b, 7, 1) . substr($b, 6, 1) .
substr($b, 5, 1) . substr($b, 4, 1) . substr($b, 3, 1) .
substr($b, 2, 1) . substr($b, 1, 1) . substr($b, 0, 1);
$nr = substr($l, 8, 1) . substr($l, 7, 1) . substr($l, 6, 1) .
substr($l, 5, 1) . substr($l, 4, 1) . substr($l, 3, 1) .
substr($l, 2, 1) . substr($l, 1, 1) . substr($l, 0, 1);
$nb = substr($f, 8, 1) . substr($f, 7, 1) . substr($f, 6, 1) .
substr($f, 5, 1) . substr($f, 4, 1) . substr($f, 3, 1) .
substr($f, 2, 1) . substr($f, 1, 1) . substr($f, 0, 1);
$nl = substr($r, 8, 1) . substr($r, 7, 1) . substr($r, 6, 1) .
substr($r, 5, 1) . substr($r, 4, 1) . substr($r, 3, 1) .
substr($r, 2, 1) . substr($r, 1, 1) . substr($r, 0, 1);
$nd = substr($d, 8, 1) . substr($d, 7, 1) . substr($d, 6, 1) .
substr($d, 5, 1) . substr($d, 4, 1) . substr($d, 3, 1) .
substr($d, 2, 1) . substr($d, 1, 1) . substr($d, 0, 1);
} elseif (($op == "(f)") || ($op == "z")) {
$nu = $l;
$nf = substr($f, 6, 1) . substr($f, 3, 1) . substr($f, 0, 1) .
substr($f, 7, 1) . substr($f, 4, 1) . substr($f, 1, 1) .
substr($f, 8, 1) . substr($f, 5, 1) . substr($f, 2, 1);
$nr = $u;
$nb = substr($b, 2, 1) . substr($b, 5, 1) . substr($b, 8, 1) .
substr($b, 1, 1) . substr($b, 4, 1) . substr($b, 7, 1) .
substr($b, 0, 1) . substr($b, 3, 1) . substr($b, 6, 1);
$nl = $d;
$nd = $r;
} elseif (($op == "(f')") || ($op == "z'")) {
$nu = $r;
$nf = substr($f, 2, 1) . substr($f, 5, 1) . substr($f, 8, 1) .
substr($f, 1, 1) . substr($f, 4, 1) . substr($f, 7, 1) .
substr($f, 0, 1) . substr($f, 3, 1) . substr($f, 6, 1);
$nr = $d;
$nb = substr($b, 6, 1) . substr($b, 3, 1) . substr($b, 0, 1) .
substr($b, 7, 1) . substr($b, 4, 1) . substr($b, 1, 1) .
substr($b, 8, 1) . substr($b, 5, 1) . substr($b, 2, 1);
$nl = $u;
$nd = $l;
} elseif (($op == "(f2)") || ($op == "z2")) {
$nu = $d;
$nf = substr($f, 8, 1) . substr($f, 7, 1) . substr($f, 6, 1) .
substr($f, 5, 1) . substr($f, 4, 1) . substr($f, 3, 1) .
substr($f, 2, 1) . substr($f, 1, 1) . substr($f, 0, 1);
$nr = $l;
$nb = substr($b, 8, 1) . substr($b, 7, 1) . substr($b, 6, 1) .
substr($b, 5, 1) . substr($b, 4, 1) . substr($b, 3, 1) .
substr($b, 2, 1) . substr($b, 1, 1) . substr($b, 0, 1);
$nl = $r;
$nd = $u;
} elseif (($op == "(r)") || ($op == "x")) {
$nu = $f;
$nf = substr($d, 8, 1) . substr($d, 7, 1) . substr($d, 6, 1) .
substr($d, 5, 1) . substr($d, 4, 1) . substr($d, 3, 1) .
substr($d, 2, 1) . substr($d, 1, 1) . substr($d, 0, 1);
$nr = substr($r, 6, 1) . substr($r, 3, 1) . substr($r, 0, 1) .
substr($r, 7, 1) . substr($r, 4, 1) . substr($r, 1, 1) .
substr($r, 8, 1) . substr($r, 5, 1) . substr($r, 2, 1);
$nb = $u;
$nl = substr($l, 2, 1) . substr($l, 5, 1) . substr($l, 8, 1) .
substr($l, 1, 1) . substr($l, 4, 1) . substr($l, 7, 1) .
substr($l, 0, 1) . substr($l, 3, 1) . substr($l, 6, 1);
$nd = substr($b, 8, 1) . substr($b, 7, 1) . substr($b, 6, 1) .
substr($b, 5, 1) . substr($b, 4, 1) . substr($b, 3, 1) .
substr($b, 2, 1) . substr($b, 1, 1) . substr($b, 0, 1);
} elseif (($op == "(r')") || ($op == "x'")) {
$nu = $b;
$nf = $u;
$nr = substr($r, 2, 1) . substr($r, 5, 1) . substr($r, 8, 1) .
substr($r, 1, 1) . substr($r, 4, 1) . substr($r, 7, 1) .
substr($r, 0, 1) . substr($r, 3, 1) . substr($r, 6, 1);
$nb = substr($d, 8, 1) . substr($d, 7, 1) . substr($d, 6, 1) .
substr($d, 5, 1) . substr($d, 4, 1) . substr($d, 3, 1) .
substr($d, 2, 1) . substr($d, 1, 1) . substr($d, 0, 1);
$nl = substr($l, 6, 1) . substr($l, 3, 1) . substr($l, 0, 1) .
substr($l, 7, 1) . substr($l, 4, 1) . substr($l, 1, 1) .
substr($l, 8, 1) . substr($l, 5, 1) . substr($l, 2, 1);
$nd = substr($f, 8, 1) . substr($f, 7, 1) . substr($f, 6, 1) .
substr($f, 5, 1) . substr($f, 4, 1) . substr($f, 3, 1) .
substr($f, 2, 1) . substr($f, 1, 1) . substr($f, 0, 1);
} elseif (($op == "(r2)") || ($op == "x2")) {
$nu = substr($d, 8, 1) . substr($d, 7, 1) . substr($d, 6, 1) .
substr($d, 5, 1) . substr($d, 4, 1) . substr($d, 3, 1) .
substr($d, 2, 1) . substr($d, 1, 1) . substr($d, 0, 1);
$nf = $b;
$nr = substr($r, 8, 1) . substr($r, 7, 1) . substr($r, 6, 1) .
substr($r, 5, 1) . substr($r, 4, 1) . substr($r, 3, 1) .
substr($r, 2, 1) . substr($r, 1, 1) . substr($r, 0, 1);
$nb = $f;
$nl = substr($l, 8, 1) . substr($l, 7, 1) . substr($l, 6, 1) .
substr($l, 5, 1) . substr($l, 4, 1) . substr($l, 3, 1) .
substr($l, 2, 1) . substr($l, 1, 1) . substr($l, 0, 1);
$nd = substr($u, 8, 1) . substr($u, 7, 1) . substr($u, 6, 1) .
substr($u, 5, 1) . substr($u, 4, 1) . substr($u, 3, 1) .
substr($u, 2, 1) . substr($u, 1, 1) . substr($u, 0, 1);
} elseif ($op == "Z01") { // PLL-01
$nu = substr($u, 0, 1) . substr($u, 7, 1) . substr($u, 2, 3) .
substr($u, 1, 1) . substr($u, 6, 1) . substr($u, 5, 1) . substr($u, 8, 1);
$nf = substr($f, 0, 1) . substr($r, 3, 1) . substr($f, 2, 7);
$nr = substr($r, 0, 3) . substr($b, 7, 1) . substr($r, 4, 5);
$nb = substr($b, 0, 7) . substr($f, 1, 1) . substr($b, 8, 1);
$nl = $l; $nd = $d;
} elseif ($op == "Z02") { // PLL-02
$nu = substr($u, 0, 1) . substr($u, 5, 1) . substr($u, 2, 3) .
substr($u, 7, 1) . substr($u, 6, 1) . substr($u, 1, 1) . substr($u, 8, 1);
$nf = substr($f, 0, 1) . substr($b, 7, 1) . substr($f, 2, 7);
$nr = substr($r, 0, 3) . substr($f, 1, 1) . substr($r, 4, 5);
$nb = substr($b, 0, 7) . substr($r, 3, 1) . substr($b, 8, 1);
$nl = $l; $nd = $d;
} elseif ($op == "Z03") { // PLL-03
$nu = substr($u, 0, 2) . substr($u, 6, 1) . substr($u, 3, 3) .
substr($u, 8, 1) . substr($u, 7, 1) . substr($u, 2, 1);
$nf = substr($r, 6, 1) . substr($f, 1, 1) . substr($r, 0, 1) . substr($f, 3, 6);
$nr = substr($l, 8, 1) . substr($r, 1, 5) . substr($b, 8, 1) . substr($r, 7, 2);
$nb = substr($b, 0, 8) . substr($f, 0, 1);
$nl = substr($l, 0, 8) . substr($f, 2, 1);
$nd = $d;
} elseif ($op == "Z04") { // PLL-04
$nu = substr($u, 0, 2) . substr($u, 8, 1) . substr($u, 3, 3) .
substr($u, 2, 1) . substr($u, 7, 1) . substr($u, 6, 1);
$nf = substr($b, 8, 1) . substr($f, 1, 1) . substr($l, 8, 1) . substr($f, 3, 6);
$nr = substr($f, 2, 1) . substr($r, 1, 5) . substr($f, 0, 1) . substr($r, 7, 2);
$nb = substr($b, 0, 8) . substr($r, 6, 1);
$nl = substr($l, 0, 8) . substr($r, 0, 1);
$nd = $d;
} elseif ($op == "Z05") { // Maneuver
$nu = substr($u, 0, 1) . substr($b, 7, 1) . substr($u, 2, 5) .
substr($f, 1, 1) . substr($u, 8, 1);
$nf = substr($f, 0, 1) . substr($u, 7, 1) . substr($f, 2, 7);
$nb = substr($b, 0, 7) . substr($u, 1, 1) . substr($b, 8, 1);
$nr = $r; $nl = $l; $nd = $d;
} elseif ($op == "Z06") { // F-R Maneuver
$nu = substr($u, 0, 5) . substr($r, 3, 1) . substr($u, 6, 1) .
substr($f, 1, 1) . substr($u, 8, 1);
$nf = substr($f, 0, 1) . substr($u, 7, 1) . substr($f, 2, 7);
$nr = substr($r, 0, 3) . substr($u, 5, 1) . substr($r, 4, 5);
$nb = $b; $nl = $l; $nd = $d;
} elseif ($op == "Z07") { // Double Maneuver
$nu = substr($u, 0, 1) . substr($b, 7, 1) . substr($u, 2, 1) .
substr($l, 5, 1) . substr($u, 4, 1) . substr($r, 3, 1) .
substr($u, 6, 1) . substr($f, 1, 1) . substr($u, 8, 1);
$nf = substr($f, 0, 1) . substr($u, 7, 1) . substr($f, 2, 7);
$nb = substr($b, 0, 7) . substr($u, 1, 1) . substr($b, 8, 1);
$nr = substr($r, 0, 3) . substr($u, 5, 1) . substr($r, 4, 5);
$nl = substr($l, 0, 5) . substr($u, 3, 1) . substr($l, 6, 3);
$nd = $d;
}
return $nu . $nf . $nr . $nl . $nb . $nd;
}
function scramble($mode) {
// echo "SCRAMBLE MODE : " . $mode . "
";
$m = strtoupper(substr($mode, 0, 3));
$n = substr($mode, 4);
if ($m == 'F2L') {
$ret = f2lscramble($n);
} elseif ($m == 'OLL') {
$ret = ollscramble($n);
} elseif ($m == 'PLL') {
$ret = pllscramble($n);
} elseif ($mode == 'NO') {
$ret = "";
} else {
$ret = scrambleauto($mode);
}
// echo "SCRAMBLE : " . $ret . "
";
return $ret;
}
function f2lscramble($n) {
$koho = array("Z01", "Z02", "Z03", "Z04", "Z05", "Z06", "Z07",
"(u)", "(u')", "(u2)");
$ret = "";
for ($i = 0; $i < 20; $i++) {
$ret .= $koho[rand(0, 9)];
if (rand(0, 1) == 1) $i++;
}
if (($n == '01') || ($n == '1') || ($n == 1)) {
$ret .= "F' U' F U";
} elseif (($n == '02') || ($n == '2') || ($n == 2)) {
$ret .= "R U R' U'";
} elseif (($n == '03') || ($n == '3') || ($n == 3)) {
$ret .= "R U' R'";
} elseif (($n == '04') || ($n == '4') || ($n == 4)) {
$ret .= "F' U F";
} elseif (($n == '05') || ($n == '5') || ($n == 5)) {
$ret .= "F' U' F U R U R' U'";
} elseif (($n == '06') || ($n == '6') || ($n == 6)) {
$ret .= "R U R' U' F' U' F U";
} elseif (($n == '07') || ($n == '7') || ($n == 7)) {
$ret .= "F' U' F U2 F' U F U'";
} elseif (($n == '08') || ($n == '8') || ($n == 8)) {
$ret .= "R U R' U2 R U' R' U";
} elseif (($n == '09') || ($n == '9') || ($n == 9)) {
$ret .= "R U' R' U F' U' F U'";
} elseif (($n == '10') || ($n == 10)) {
$ret .= "F' U F U' R U R' U";
} elseif (($n == '11') || ($n == 11)) {
$ret .= "F' U' F U2 F'U2FU'";
} elseif (($n == '12') || ($n == 12)) {
$ret .= "RUR'U2RU2R'U";
} elseif (($n == '13') || ($n == 13)) {
$ret .= "F'U'FUF'U2FU";
} elseif (($n == '14') || ($n == 14)) {
$ret .= "RUR'U'RU2R'U'";
} elseif (($n == '15') || ($n == 15)) {
$ret .= "RUR'U'RU'R'U2";
} elseif (($n == '16') || ($n == 16)) {
$ret .= "F'U'FUF'UFU2";
} elseif (($n == '17') || ($n == 17)) {
$ret .= "F'UFUF'U'FU'";
} elseif (($n == '18') || ($n == 18)) {
$ret .= "RU'R'U2F'U'F";
} elseif (($n == '19') || ($n == 19)) {
$ret .= "F'UFU'F'U2F";
} elseif (($n == '20') || ($n == 20)) {
$ret .= "RU2B'RBR'U'R'";
} elseif (($n == '21') || ($n == 21)) {
$ret .= "RU'R'UF'U2FU'";
} elseif (($n == '22') || ($n == 22)) {
$ret .= "RU'R'U'RUR'U";
} elseif (($n == '23') || ($n == 23)) {
$ret .= "F'UFU2RUR'";
} elseif (($n == '24') || ($n == 24)) {
$ret .= "RU'R'URU2R'";
} elseif (($n == '25') || ($n == 25)) {
$ret .= "F'U2LF'L'FUF";
} elseif (($n == '26') || ($n == 26)) {
$ret .= "F'UFU'RU2R'U";
} elseif (($n == '27') || ($n == 27)) {
$ret .= "R'FRF2U'F";
} elseif (($n == '28') || ($n == 28)) {
$ret .= "RU'R'F'U'FU'";
} elseif (($n == '29') || ($n == 29)) {
$ret .= "FR'F'R2UR'";
} elseif (($n == '30') || ($n == 30)) {
$ret .= "F'UFRUR'U";
} elseif (($n == '31') || ($n == 31)) {
$ret .= "F'UF'U2R'F2RU2F2";
} elseif (($n == '32') || ($n == 32)) {
$ret .= "R2U2R'U'RU'R'U2R'";
} elseif (($n == '33') || ($n == 33)) {
$ret .= "RU2RUR'URU2R2";
} elseif (($n == '34') || ($n == 34)) {
$ret .= "F2L'U'LUFU'F";
} elseif (($n == '35') || ($n == 35)) {
$ret .= "R2BUB'U'R'UR'";
} elseif (($n == '36') || ($n == 36)) {
$ret .= "F'U'FU2F'U'FU'";
} elseif (($n == '37') || ($n == 37)) {
$ret .= "RUR'U2RUR'U";
} elseif (($n == '38') || ($n == 38)) {
$ret .= "RU'R'UF'UFU'";
} elseif (($n == '39') || ($n == 39)) {
$ret .= "F'UFU'RU'R'U";
} elseif (($n == '40') || ($n == 40)) {
$ret .= "F2U2F2UF2UF2";
} elseif (($n == '41') || ($n == 41)) {
$ret .= "F'U2FRUR'";
} else {
$ret .= scrambleauto("auto");
}
return $ret;
}
function ollscramble($n) {
$koho = array("Z01", "Z02", "Z03", "Z04", "(u)", "(u')", "(u2)");
$ret = "";
for ($i = 0; $i < 15; $i++) {
$ret .= $koho[rand(0, 6)];
if (rand(0, 1) == 1) $i++;
}
if (($n == '01') || ($n == '1') || ($n == 1)) {
$ret .= "FR'F'RUR2B'R'BU'R'";
} elseif (($n == '02') || ($n == '2') || ($n == 2)) {
$ret .= "RUB'RBR2U'R'FRF'";
} elseif (($n == '03') || ($n == '3') || ($n == 3)) {
$ret .= "L'RB'LU2L'B'RB'R2L";
} elseif (($n == '04') || ($n == '4') || ($n == 4)) {
$ret .= "L'R2BR'BLU2L'BLR'";
} elseif (($n == '05') || ($n == '5') || ($n == 5)) {
$ret .= "L'B'RB'R'B2L";
} elseif (($n == '06') || ($n == '6') || ($n == 6)) {
$ret .= "RBL'BLB2R'";
} elseif (($n == '07') || ($n == '7') || ($n == 7)) {
$ret .= "RB2L'B'LB'R'";
} elseif (($n == '08') || ($n == '8') || ($n == 8)) {
$ret .= "L'B2RBR'BL";
} elseif (($n == '09') || ($n == '9') || ($n == 9)) {
$ret .= "FR'F'U'FRF'R'UR";
} elseif (($n == '10') || ($n == 10)) {
$ret .= "F'LFUF'L'FLU'L'";
} elseif (($n == '11') || ($n == 11)) {
$ret .= "L'RB'RB2R'BRB'R2L";
} elseif (($n == '12') || ($n == 12)) {
$ret .= "L'RBL'B2LBL'BR'L2";
} elseif (($n == '13') || ($n == 13)) {
$ret .= "F'U'FLF'L'ULFL'";
} elseif (($n == '14') || ($n == 14)) {
$ret .= "FUF'R'FRU'R'F'R";
} elseif (($n == '15') || ($n == 15)) {
$ret .= "RBR'ULU'L'RB'R'";
} elseif (($n == '16') || ($n == 16)) {
$ret .= "RBR'ULU'L'RB'R'";
} elseif (($n == '17') || ($n == 17)) {
$ret .= "BLUL'UB'U2B'RBR'";
} elseif (($n == '18') || ($n == 18)) {
$ret .= "LF'L'FU2FU'RU'R'F'";
} elseif (($n == '19') || ($n == 19)) {
$ret .= "R'F'U2F2URU'R'F'U2R";
} elseif (($n == '20') || ($n == 20)) {
$ret .= "SR'U'RURURU'R'S'";
} elseif (($n == '21') || ($n == 21)) {
$ret .= "RUR'URU'R'URU2R'";
} elseif (($n == '22') || ($n == 22)) {
$ret .= "R'U2R2UR2UR2U2R'";
} elseif (($n == '23') || ($n == 23)) {
$ret .= "R'U2R'D'RU2R'DR2";
} elseif (($n == '24') || ($n == 24)) {
$ret .= "B'R'F'RBR'FR";
} elseif (($n == '25') || ($n == 25)) {
$ret .= "R'F'RB'R'FRB";
} elseif (($n == '26') || ($n == 26)) {
$ret .= "RUR'URU2R'";
} elseif (($n == '27') || ($n == 27)) {
$ret .= "R'U'RU'R'U2R";
} elseif (($n == '28') || ($n == 28)) {
$ret .= "L'RB'R'LU2L'RB'R'L";
} elseif (($n == '29') || ($n == 29)) {
$ret .= "L'B2RBR2BLB'RB";
} elseif (($n == '30') || ($n == 30)) {
$ret .= "RB2L'B'L2B'R'BL'B'";
} elseif (($n == '31') || ($n == 31)) {
$ret .= "L'BLUL'U'B'UL";
} elseif (($n == '32') || ($n == 32)) {
$ret .= "RB'R'U'RUBU'R'";
} elseif (($n == '33') || ($n == 33)) {
$ret .= "FR'F'RURU'R'";
} elseif (($n == '34') || ($n == 34)) {
$ret .= "B'FRBR'F'U'R'UR";
} elseif (($n == '35') || ($n == 35)) {
$ret .= "RU2R'FR'FR2U2R'";
} elseif (($n == '36') || ($n == 36)) {
$ret .= "L'BLUL'U'B2UBL";
} elseif (($n == '37') || ($n == 37)) {
$ret .= "BUB'U'B'RBR'";
} elseif (($n == '38') || ($n == 38)) {
$ret .= "RB'R'U'RUB2U'B'R'";
} elseif (($n == '39') || ($n == 39)) {
$ret .= "LUF'U'L'ULFL'";
} elseif (($n == '40') || ($n == 40)) {
$ret .= "R'U'FURU'R'F'R";
} elseif (($n == '41') || ($n == 41)) {
$ret .= "RUBUB'U'R'U2RUR'";
} elseif (($n == '42') || ($n == 42)) {
$ret .= "L'U'B'U'BULU2L'U'L";
} elseif (($n == '43') || ($n == 43)) {
$ret .= "R'F'U'FUR";
} elseif (($n == '44') || ($n == 44)) {
$ret .= "RBUB'U'R'";
} elseif (($n == '45') || ($n == 45)) {
$ret .= "LUFU'F'L'";
} elseif (($n == '46') || ($n == 46)) {
$ret .= "R'U'FR'F'RUR";
} elseif (($n == '47') || ($n == 47)) {
$ret .= "R'U'F'UFU'F'UFR";
} elseif (($n == '48') || ($n == 48)) {
$ret .= "LUFU'F'UFU'F'L'";
} elseif (($n == '49') || ($n == 49)) {
$ret .= "L'BL2B'U2B'U2BL'";
} elseif (($n == '50') || ($n == 50)) {
$ret .= "RB'R2BU2BU2B'R";
} elseif (($n == '51') || ($n == 51)) {
$ret .= "R'F'U'FUF'U'FUR";
} elseif (($n == '52') || ($n == 52)) {
$ret .= "R'F'U'FU'RUR'UR";
} elseif (($n == '53') || ($n == 53)) {
$ret .= "L'B2RBR'B'RBR'BL";
} elseif (($n == '54') || ($n == 54)) {
$ret .= "RB2L'B'LBL'B'LB'R'";
} elseif (($n == '55') || ($n == 55)) {
$ret .= "B'RBU2R'U'RU'R2U2R";
} elseif (($n == '56') || ($n == 56)) {
$ret .= "F'RUBU'R'F2RB'R'F'";
} elseif (($n == '57') || ($n == 57)) {
$ret .= "FR'F'MFRF'M'";
} else {
$ret .= scrambleauto("auto");
}
return $ret;
}
function pllscramble($n) {
$koho = array("", "(u)", "(u')", "(u2)");
$ret = $koho[rand(0, 3)];
if (($n == '01') || ($n == '1') || ($n == 1)) {
$ret .= "R2U'S'U2SU'R2";
} elseif (($n == '02') || ($n == '2') || ($n == 2)) {
$ret .= "R2US'U2SUR2";
} elseif (($n == '03') || ($n == '3') || ($n == 3)) {
$ret .= "R2F2R'B'RF2R'BR'";
} elseif (($n == '04') || ($n == '4') || ($n == 4)) {
$ret .= "RB'RF2R'BRF2R2";
} elseif (($n == '05') || ($n == '5') || ($n == 5)) {
$ret .= "U'F2R'B'RBF'RF'B'RBR'";
} elseif (($n == '06') || ($n == '6') || ($n == 6)) {
$ret .= "B'F'U2BFLRU2L'R'";
} elseif (($n == '07') || ($n == '7') || ($n == 7)) {
$ret .= "BLFL'B'RLBR'F'RB'R'L'";
} elseif (($n == '08') || ($n == '8') || ($n == 8)) {
$ret .= "B2DL2U'L2B2D'R2UR2U'";
} elseif (($n == '09') || ($n == '9') || ($n == 9)) {
$ret .= "R'B'R'BRB2DBD'BURU'R";
} elseif (($n == '10') || ($n == 10)) {
$ret .= "R2B'RD2L'FLD2RFRBR'F'";
} elseif (($n == '11') || ($n == 11)) {
$ret .= "F2LFUF'U'F'UL'F'LU'L'F'";
} elseif (($n == '12') || ($n == 12)) {
$ret .= "F2R'F'U'FUFU'RFR'URF";
} elseif (($n == '13') || ($n == 13)) {
$ret .= "R2D'R'DR'B2LU'L'B2";
} elseif (($n == '14') || ($n == 14)) {
$ret .= "R2DRD'RF2L'ULF2";
} elseif (($n == '15') || ($n == 15)) {
$ret .= "F2U'L2D'L2ULDL'F2RU'R'";
} elseif (($n == '16') || ($n == 16)) {
$ret .= "R'L'U2RLU2BU'FU2B'UF'";
} elseif (($n == '17') || ($n == 17)) {
$ret .= "U2BU'FU2B'UF'R'L'U2RL";
} elseif (($n == '18') || ($n == 18)) {
$ret .= "U2B'UF'U2BU'FRLU2R'L'";
} elseif (($n == '19') || ($n == 19)) {
$ret .= "RLU2R'L'U2F'UB'U2FU'B";
} elseif (($n == '20') || ($n == 20)) {
$ret .= "UR'UL'U2RU'LR'UL'U2RU'L";
} elseif (($n == '21') || ($n == 21)) {
$ret .= "U'RU'LU2R'UL'RU'LU2R'UL'";
} else {
$ret .= scrambleauto("auto");
}
return $ret;
}
function scrambleauto($mode) {
// echo "Now Scramble...";
$scramble = "";
$men = "FURDBL";
$fmen = "URDL";
$umen = "FRLB";
$rmen = "FUBD";
$dir = "+-2";
$tesu = 0;
$randir = substr($dir, rand(0, 2), 1);
$last = substr($men, rand(0, 5), 1);
if ($randir == '-') $scramble .= "'";
if ($randir == '2') $scramble .= "2";
$scramble = $last . " ";
$tesu++;
if ($mode < 1) $auto = "auto";
$auto = ($mode == "auto") ? 1 : 0;
if ($auto == 1) $mode = 30;
for ($i = 1; $i < $mode; $i++) {
if (($last == "F") || ($last == "B")) $men = $fmen;
if (($last == "U") || ($last == "D")) $men = $umen;
if (($last == "R") || ($last == "L")) $men = $rmen;
$last = substr($men, rand(0, 3), 1);
$scramble .= $last;
$tesu++;
$randir = substr($dir, rand(0, 2), 1);
if ($randir == '-') $scramble .= "'";
if ($randir == '2') $scramble .= "2";
if (($i > 10) && ($auto)) {
$skip = rand(0, 1);
if ($skip) $i++;
}
$scramble .= " ";
}
// echo " (" . $tesu . ")
";
return $scramble . mukiscramble();
}
function mukiscramble() {
//$muki = array("", "(u)", "(u')" , "(u2)",
// "(r)", "(r)(u)", "(r)(u2)", "(r)(u')",
// "(f)", "(f)(u)", "(f)(u')", "(f)(u2)",
// "(f')", "(f')(u)", "(f')(u')", "(f')(u2)",
// "(r')", "(r')(u)", "(r')(u')", "(r')(u2)",
// "(r2)", "(r2)(u)", "(r2)(u')", "(r2)(u2)");
$muki = array("", "y ", "y' " , "y2 ",
"x ", "x y ", "x y2 ", "x y' )",
"z ", "z y ", "z y' ", "z y2 ",
"z' ", "z' y ", "z' y' ", "z' y2 ",
"x' ", "x' y ", "x' y' ", "x' y2 ",
"x2 ", "x2 y ", "x2 y' ", "x2 y2 ");
return $muki[rand(0, 23)];
}
function getparam($param, $default = "") {
$value = $default;
if ($_POST[$param]) $value = $_POST[$param];
if ($_GET[$param]) $value = $_GET[$param];
return safeStripSlashes(trim($value));
}
function safeStripSlashes($v) {
if (is_array($v)) {
return array_map('safeStripSlashes', $v);
} else {
if (get_magic_quotes_gpc()) {
$v = stripslashes($v);
}
return $v;
}
}
?>