home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- From: fleurant@hri.com (P.Fleurant)
- Subject: v37i086: magiccube - a cube simulator for X11/Motif, Patch02
- Message-ID: <1993May25.192859.971@sparky.imd.sterling.com>
- X-Md4-Signature: 413b92c233ceb75f1456d2afa9ef49ad
- Keywords: magiccube-patch02
- Sender: kent@sparky.imd.sterling.com (Kent Landfield)
- Reply-To: fleurant@hri.com
- Organization: Horizon Research, Inc.
- Date: Tue, 25 May 1993 19:28:59 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: fleurant@hri.com (P.Fleurant)
- Posting-number: Volume 37, Issue 86
- Archive-name: magiccube/patch02
- Environment: X11, Motif
- Patch-To: magiccube: Volume 37, Issue 38-42
-
- These patches are for the SOLVING ALGORITHM (Solve button).
-
- Thanx to C. at i.b.m. who pointed out failures in the solving algorithm.
- The solver failed "Pons Asinorum". To init the cube to "Pons Asinorum",
- set the colors of all the center-edges to the colors of the opposing faces.
-
- The following shar contains patches for layer2.c, layer3.c, layer3twirl.c, layer3flip.c,
- and patchlevel.h
-
- After sh'ing this file, execute the following in the cube directory.
- patch < patch3
-
- Then rebuild:
- make
-
-
- --
- P.Fleurant Horizon Research, Inc.
- fleurant@hri.com Waltham, MA
- ------------------////////////////////////////////-------------------------
- #!/bin/sh
- # This is a shell archive (produced by shar 3.50)
- # To extract the files from this archive, save it to a file, remove
- # everything above the "!/bin/sh" line above, and type "sh file_name".
- #
- # made 05/24/1993 15:31 UTC by fleurant@sparc15
- # Source directory /home/gamera/U1/fleurant/x/cube
- #
- # existing files will NOT be overwritten unless -c is specified
- #
- # This shar contains:
- # length mode name
- # ------ ---------- ------------------------------------------
- # 330 -rw-r--r-- MANIFEST-patch
- # 2275 -rw-r--r-- README-patch
- # 9496 -rw-r--r-- patch3
- #
- # ============= MANIFEST-patch ==============
- if test -f 'MANIFEST-patch' -a X"$1" != X"-c"; then
- echo 'x - skipping MANIFEST-patch (File already exists)'
- else
- echo 'x - extracting MANIFEST-patch (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'MANIFEST-patch' &&
- X File Name Archive # Description
- -----------------------------------------------------------
- X MANIFEST-patch -- The file you are actually reading.
- X README-patch
- X patch3 -- patch for layer2.c, layer3.c, layer3twirl.c, layer3flip.c, and patchlevel.h
- X
- X
- SHAR_EOF
- chmod 0644 MANIFEST-patch ||
- echo 'restore of MANIFEST-patch failed'
- Wc_c="`wc -c < 'MANIFEST-patch'`"
- test 330 -eq "$Wc_c" ||
- echo 'MANIFEST-patch: original size 330, current size' "$Wc_c"
- fi
- # ============= README-patch ==============
- if test -f 'README-patch' -a X"$1" != X"-c"; then
- echo 'x - skipping README-patch (File already exists)'
- else
- echo 'x - extracting README-patch (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'README-patch' &&
- PPPPPPPP A TTTTTTTTTTTT CCCCCCC H H
- P P A A T C H H
- P P A A T C H H
- PPPPPPP A A T C HHHHHHHH
- P A A T C H H
- P AAAAAAAAAAA T C H H
- P A A T CCCCCCC H H
- X
- M MM A GGGGGGGG IIIIIIII CCCCCCC
- M M M M A A G G I C
- M M M M A A G I C
- M M M M A A G GGGGGGG I C
- M M M M AAAAAAAAA G G I C
- M M M A A GGGGGGGG IIIIIIII CCCCCCC
- X
- X CCCCCCC U U BBBBBBB EEEEEEEE
- X C U U B B E
- X C U U B B E
- X C U U BBBBBBBB EEEEE
- X C U U B B E
- X CCCCCCC UUUUUUUU BBBBBBB EEEEEEEE
- X ///////// ////////////
- X ///////// using X11/Motif ////////////
- X ////////// V e r s i o n 1 . 0 ////////////
- X
- COPYRIGHT & DISCLAIMER STUFF:
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- X
- Copyright (C) 1993 by Pierre A. Fleurant
- X Horizon Research, Inc
- X Email: fleurant@hri.com
- X
- X
- ////////////The following references were used:///////////////////////
- X
- X "The X Window System Programming And Applications with Xt
- X OSF/MOTIF EDITION"
- X by Douglas A Young
- X Prentice-Hall, 1990.
- X ISBN 0-13-642786-3
- X
- X "Mastering Rubik's Cube"
- X by Don Taylor
- X An Owl Book; Holt, Rinehart and Winston, New York, 1980
- X ISBN 0-03-059941-5
- X
- //////////////////////////////////////////////////////////////////////
- PATCH INFO:
- X
- These patches are for the SOLVING ALGORITHM.
- Thanks to C. at i.b.m. for pointing out a failure.
- X
- X Execute the following in the cube directory.
- X patch < patch3
- X
- X Then rebuild:
- X make
- X
- //////////////////////////////////////////////////////////////////////
- X Please send comments to fleurant@hri.com
- X "Don't say the `R' word!"
- SHAR_EOF
- chmod 0644 README-patch ||
- echo 'restore of README-patch failed'
- Wc_c="`wc -c < 'README-patch'`"
- test 2275 -eq "$Wc_c" ||
- echo 'README-patch: original size 2275, current size' "$Wc_c"
- fi
- # ============= patch3 ==============
- if test -f 'patch3' -a X"$1" != X"-c"; then
- echo 'x - skipping patch3 (File already exists)'
- else
- echo 'x - extracting patch3 (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'patch3' &&
- *** patchlevel.h Mon May 24 09:54:40 1993
- --- patchlevel.h.02 Mon May 24 10:50:54 1993
- ***************
- *** 1,7 ****
- ! #define VERSION "1.0.0"
- ! #define DATE "10 May 1993"
- X
- X /*
- X * patch1 14 May 93 :Fix to seed_cube in cube.h; Bug became manifest in gcc
- X * patch2 14 May 93 :Fix to ldfile.c; Bug became manifest in gcc
- X */
- --- 1,10 ----
- ! #define VERSION "1.0.2"
- ! #define DATE "24 May 1993"
- X
- X /*
- X * patch1 14 May 93 :Fix to seed_cube in cube.h; Bug became manifest in gcc
- X * patch2 14 May 93 :Fix to ldfile.c; Bug became manifest in gcc
- + * patch3 24 May 93 :Patches for layer2.c, layer3.c, layer3twirl.c, and layer3flip.c.
- + * :Discovered when magicCube hung solving "Pons Asinorum"
- X */
- +
- *** layer2.c Fri May 21 11:26:32 1993
- --- layer2.c.02 Fri May 21 13:08:25 1993
- ***************
- *** 300,319 ****
- X * So a middle layer cube must be moved out to the bottom layer.
- X */
- X else {
- ! if(Front(5) == RIGHT &&
- ! Right(3) == FRONT){
- X F(1);D(2);L(1);D(1);L(-1);D(2);F(-1);
- X }
- ! else if(Right(5) == BACK &&
- ! Back(5) == RIGHT){
- X R(1);D(2);F(1);D(1);F(-1);D(2);R(-1);
- X }
- ! else if(Back(3) == LEFT &&
- ! Left(5) == BACK){
- X B(1);D(2);R(1);D(1);R(-1);D(2);B(-1);
- X }
- ! else if(Left(3) == FRONT &&
- ! Front(3) == LEFT){
- X L(1);D(2);B(1);D(1);B(-1);D(2);L(-1);
- X }
- X return(False);
- --- 300,319 ----
- X * So a middle layer cube must be moved out to the bottom layer.
- X */
- X else {
- ! if(Front(5) != FRONT ||
- ! Right(3) != RIGHT){
- X F(1);D(2);L(1);D(1);L(-1);D(2);F(-1);
- X }
- ! else if(Right(5) != RIGHT ||
- ! Back(5) != BACK){
- X R(1);D(2);F(1);D(1);F(-1);D(2);R(-1);
- X }
- ! else if(Back(3) != BACK ||
- ! Left(5) != LEFT){
- X B(1);D(2);R(1);D(1);R(-1);D(2);B(-1);
- X }
- ! else if(Left(3) != LEFT ||
- ! Front(3) != FRONT){
- X L(1);D(2);B(1);D(1);B(-1);D(2);L(-1);
- X }
- X return(False);
- *** layer3.c Tue Apr 13 11:16:09 1993
- --- layer3.c.02 Mon May 24 10:19:41 1993
- ***************
- *** 292,298 ****
- X /* A solution(3 to 5 to 7 to 3) */
- X B(2);D(1);R(-1);L(1);B(2);R(1);L(-1);D(1);B(2);
- X }
- ! else if(Right(7) == LEFT || Bottom(5) == LEFT){
- X /* bottom(5) belongs in bottom(3) */
- X /* B solution(5 to 3 to 7 to 5) */
- X B(2);D(-1);R(-1);L(1);B(2);R(1);L(-1);D(-1);B(2);
- --- 292,298 ----
- X /* A solution(3 to 5 to 7 to 3) */
- X B(2);D(1);R(-1);L(1);B(2);R(1);L(-1);D(1);B(2);
- X }
- ! else if(Right(7) == LEFT || Bottom(5) == LEFT){
- X /* bottom(5) belongs in bottom(3) */
- X /* B solution(5 to 3 to 7 to 5) */
- X B(2);D(-1);R(-1);L(1);B(2);R(1);L(-1);D(-1);B(2);
- ***************
- *** 305,321 ****
- X if(Back(7) == FRONT || Bottom(7) == FRONT){
- X /* bottom(7) belongs in bottom(1) */
- X /* A solution(7 to 1 to 5 to 7) */
- ! L(2);D(1);F(-1);B(1);L(2);F(1);B(-1);D(1);L(2);
- X }
- X else if(Front(7) == BACK || Bottom(1) == BACK){
- X /* bottom(1) belongs in bottom(7) */
- X /* B solution(1 to 7 to 5 to 1) */
- ! L(2);D(-1);F(-1);B(1);L(2);F(1);B(-1);D(-1);L(2);
- X }
- X else{ ; } /* all edges in proper place */
- X }
- X
- ! else if(Right(7) == RIGHT || Bottom(3) == RIGHT){
- X /* bottom(5) ok */
- X if(Front(7) == BACK || Bottom(1) == BACK){
- X /* bottom(1) belongs in bottom(7) */
- --- 305,321 ----
- X if(Back(7) == FRONT || Bottom(7) == FRONT){
- X /* bottom(7) belongs in bottom(1) */
- X /* A solution(7 to 1 to 5 to 7) */
- ! R(2);D(1);F(-1);B(1);R(2);F(1);B(-1);D(1);R(2);
- X }
- X else if(Front(7) == BACK || Bottom(1) == BACK){
- X /* bottom(1) belongs in bottom(7) */
- X /* B solution(1 to 7 to 5 to 1) */
- ! R(2);D(-1);F(-1);B(1);R(2);F(1);B(-1);D(-1);R(2);
- X }
- X else{ ; } /* all edges in proper place */
- X }
- X
- ! else if(Right(7) == RIGHT || Bottom(5) == RIGHT){
- X /* bottom(5) ok */
- X if(Front(7) == BACK || Bottom(1) == BACK){
- X /* bottom(1) belongs in bottom(7) */
- ***************
- *** 330,336 ****
- X else{ ; } /* all edges in proper place */
- X }
- X
- ! else if(Back(7) == BACK || Bottom(3) == BACK){
- X /* bottom(7) ok */
- X if(Right(7) == LEFT || Bottom(5) == LEFT){
- X /* bottom(5) belongs in bottom(3) */
- --- 330,336 ----
- X else{ ; } /* all edges in proper place */
- X }
- X
- ! else if(Back(7) == BACK || Bottom(7) == BACK){
- X /* bottom(7) ok */
- X if(Right(7) == LEFT || Bottom(5) == LEFT){
- X /* bottom(5) belongs in bottom(3) */
- ***************
- *** 352,363 ****
- X /* D solution(1 to 3; 3 to 1; 5 to 7; 7 to 5) */
- X F(1);L(1);D(1);L(-1);D(-1);F(2);R(-1);D(-1);R(1);D(1);F(1);
- X }
- ! else if(Front(7) == BACK || Bottom(7) == BACK){
- X /* bottom(1) belongs in bottom(7) */
- X /* C solution(1 to 7; 7 to 1; 3 to 5; 5 to 3) */
- X R(2);L(2);U(1);R(2);L(2);D(2);R(2);L(2);U(1);R(2);L(2);
- X }
- ! else if(Front(7) == RIGHT || Bottom(5) == RIGHT){
- X /* bottom(1) belongs in bottom(5) */
- X /* D solution(1 to 5; 5 to 1; 3 to 7; 7 to 3) */
- X R(1);F(1);D(1);F(-1);D(-1);R(2);B(-1);D(-1);B(1);D(1);R(1);
- --- 352,363 ----
- X /* D solution(1 to 3; 3 to 1; 5 to 7; 7 to 5) */
- X F(1);L(1);D(1);L(-1);D(-1);F(2);R(-1);D(-1);R(1);D(1);F(1);
- X }
- ! else if(Front(7) == BACK || Bottom(1) == BACK){
- X /* bottom(1) belongs in bottom(7) */
- X /* C solution(1 to 7; 7 to 1; 3 to 5; 5 to 3) */
- X R(2);L(2);U(1);R(2);L(2);D(2);R(2);L(2);U(1);R(2);L(2);
- X }
- ! else if(Front(7) == RIGHT || Bottom(1) == RIGHT){
- X /* bottom(1) belongs in bottom(5) */
- X /* D solution(1 to 5; 5 to 1; 3 to 7; 7 to 3) */
- X R(1);F(1);D(1);F(-1);D(-1);R(2);B(-1);D(-1);B(1);D(1);R(1);
- ***************
- *** 368,370 ****
- --- 368,371 ----
- X }
- X
- X }
- +
- *** layer3twirl.c Thu May 20 11:26:41 1993
- --- layer3twirl.c.02 Thu May 20 14:21:13 1993
- ***************
- *** 51,57 ****
- X Back(8) == BACK &&
- X Left(8) == LEFT)
- X return(True);
- !
- X /* Here if not ok */
- X /* Twirl corners */
- X /* 3 possibilities:
- --- 51,57 ----
- X Back(8) == BACK &&
- X Left(8) == LEFT)
- X return(True);
- !
- X /* Here if not ok */
- X /* Twirl corners */
- X /* 3 possibilities:
- ***************
- *** 62,68 ****
- X * The twirl algorithm twirls one corner clockwise, and another anti-clockwise.
- X * This is repeated until all 4 corners are correct.
- X */
- !
- X /* Find a corner that needs a clockwise twirl.
- X * (Note: all corners are in correct position.
- X * A corner needs a clockwise twirl if the front matches the top with
- --- 62,68 ----
- X * The twirl algorithm twirls one corner clockwise, and another anti-clockwise.
- X * This is repeated until all 4 corners are correct.
- X */
- !
- X /* Find a corner that needs a clockwise twirl.
- X * (Note: all corners are in correct position.
- X * A corner needs a clockwise twirl if the front matches the top with
- ***************
- *** 69,75 ****
- X * said cube oriented in a top right-hand position.
- X * A corner needs an anti-clockwise twirl if the right-hand face matches the top.)
- X */
- !
- X if(Front(6) == BOTTOM){
- X L(-1);U(1);L(1);F(1);U(1);F(-1);
- X /* Now search for cube that needs an anti-clockwise turn. */
- --- 69,75 ----
- X * said cube oriented in a top right-hand position.
- X * A corner needs an anti-clockwise twirl if the right-hand face matches the top.)
- X */
- !
- X if(Front(6) == BOTTOM){
- X L(-1);U(1);L(1);F(1);U(1);F(-1);
- X /* Now search for cube that needs an anti-clockwise turn. */
- ***************
- *** 83,89 ****
- X F(1);U(-1);F(-1);L(-1);U(-1);L(1);
- X D(2);
- X }
- ! else if(Front(8) == BOTTOM){
- X D(-1);
- X F(1);U(-1);F(-1);L(-1);U(-1);L(1);
- X D(1);
- --- 83,96 ----
- X F(1);U(-1);F(-1);L(-1);U(-1);L(1);
- X D(2);
- X }
- ! else {
- ! /* This is the default case.
- ! * Here Front(8) == BOTTOM or there
- ! * are no other cubes that need an anti-clockwise turn.
- ! * No other cubes that need an anti-clockwise turn means
- ! * that we are in case 3 and 3 cubes
- ! * need a clockwise turn.
- ! */
- X D(-1);
- X F(1);U(-1);F(-1);L(-1);U(-1);L(1);
- X D(1);
- ***************
- *** 101,107 ****
- X R(1);U(-1);R(-1);F(-1);U(-1);F(1);
- X D(2);
- X }
- ! else if(Right(8) == BOTTOM){
- X D(-1);
- X R(1);U(-1);R(-1);F(-1);U(-1);F(1);
- X D(1);
- --- 108,114 ----
- X R(1);U(-1);R(-1);F(-1);U(-1);F(1);
- X D(2);
- X }
- ! else {
- X D(-1);
- X R(1);U(-1);R(-1);F(-1);U(-1);F(1);
- X D(1);
- ***************
- *** 119,125 ****
- X B(1);U(-1);B(-1);R(-1);U(-1);R(1);
- X D(2);
- X }
- ! else if(Back(6) == BOTTOM){
- X D(-1);
- X B(1);U(-1);B(-1);R(-1);U(-1);R(1);
- X D(1);
- --- 126,132 ----
- X B(1);U(-1);B(-1);R(-1);U(-1);R(1);
- X D(2);
- X }
- ! else {
- X D(-1);
- X B(1);U(-1);B(-1);R(-1);U(-1);R(1);
- X D(1);
- ***************
- *** 137,143 ****
- X L(1);U(-1);L(-1);B(-1);U(-1);B(1);
- X D(2);
- X }
- ! else if(Left(6) == BOTTOM){
- X D(-1);
- X L(1);U(-1);L(-1);B(-1);U(-1);B(1);
- X D(1);
- --- 144,150 ----
- X L(1);U(-1);L(-1);B(-1);U(-1);B(1);
- X D(2);
- X }
- ! else {
- X D(-1);
- X L(1);U(-1);L(-1);B(-1);U(-1);B(1);
- X D(1);
- SHAR_EOF
- chmod 0644 patch3 ||
- echo 'restore of patch3 failed'
- Wc_c="`wc -c < 'patch3'`"
- test 9496 -eq "$Wc_c" ||
- echo 'patch3: original size 9496, current size' "$Wc_c"
- fi
- exit 0
-
- exit 0 # Just in case...
-