home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume37 / mgiccube / patch02 < prev    next >
Encoding:
Text File  |  1993-05-24  |  15.3 KB  |  468 lines

  1. Newsgroups: comp.sources.misc
  2. From: fleurant@hri.com (P.Fleurant)
  3. Subject: v37i086:  magiccube - a cube simulator for X11/Motif, Patch02
  4. Message-ID: <1993May25.192859.971@sparky.imd.sterling.com>
  5. X-Md4-Signature: 413b92c233ceb75f1456d2afa9ef49ad
  6. Keywords: magiccube-patch02
  7. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  8. Reply-To: fleurant@hri.com
  9. Organization: Horizon Research, Inc.
  10. Date: Tue, 25 May 1993 19:28:59 GMT
  11. Approved: kent@sparky.imd.sterling.com
  12.  
  13. Submitted-by: fleurant@hri.com (P.Fleurant)
  14. Posting-number: Volume 37, Issue 86
  15. Archive-name: magiccube/patch02
  16. Environment: X11, Motif
  17. Patch-To: magiccube: Volume 37, Issue 38-42
  18.  
  19. These patches are for the SOLVING ALGORITHM (Solve button).
  20.           
  21. Thanx to C. at i.b.m. who pointed out failures in the solving algorithm. 
  22. The solver failed "Pons Asinorum".  To init the cube to "Pons Asinorum",
  23. set the colors of all the center-edges to the colors of the opposing faces.
  24.  
  25. The following shar contains patches for layer2.c, layer3.c, layer3twirl.c, layer3flip.c,
  26. and patchlevel.h
  27.  
  28. After sh'ing this file, execute the following in the cube directory.
  29.           patch < patch3
  30.  
  31. Then rebuild:
  32.           make 
  33.  
  34.  
  35. -- 
  36. P.Fleurant                                          Horizon Research, Inc.
  37. fleurant@hri.com                                    Waltham, MA 
  38. ------------------////////////////////////////////-------------------------
  39. #!/bin/sh
  40. # This is a shell archive (produced by shar 3.50)
  41. # To extract the files from this archive, save it to a file, remove
  42. # everything above the "!/bin/sh" line above, and type "sh file_name".
  43. #
  44. # made 05/24/1993 15:31 UTC by fleurant@sparc15
  45. # Source directory /home/gamera/U1/fleurant/x/cube
  46. #
  47. # existing files will NOT be overwritten unless -c is specified
  48. #
  49. # This shar contains:
  50. # length  mode       name
  51. # ------ ---------- ------------------------------------------
  52. #    330 -rw-r--r-- MANIFEST-patch
  53. #   2275 -rw-r--r-- README-patch
  54. #   9496 -rw-r--r-- patch3
  55. #
  56. # ============= MANIFEST-patch ==============
  57. if test -f 'MANIFEST-patch' -a X"$1" != X"-c"; then
  58.     echo 'x - skipping MANIFEST-patch (File already exists)'
  59. else
  60. echo 'x - extracting MANIFEST-patch (Text)'
  61. sed 's/^X//' << 'SHAR_EOF' > 'MANIFEST-patch' &&
  62. X   File Name        Archive #    Description
  63. -----------------------------------------------------------
  64. X   MANIFEST-patch                    -- The file you are actually reading.
  65. X   README-patch                         
  66. X   patch3                            -- patch for layer2.c, layer3.c, layer3twirl.c, layer3flip.c, and patchlevel.h
  67. X
  68. X
  69. SHAR_EOF
  70. chmod 0644 MANIFEST-patch ||
  71. echo 'restore of MANIFEST-patch failed'
  72. Wc_c="`wc -c < 'MANIFEST-patch'`"
  73. test 330 -eq "$Wc_c" ||
  74.     echo 'MANIFEST-patch: original size 330, current size' "$Wc_c"
  75. fi
  76. # ============= README-patch ==============
  77. if test -f 'README-patch' -a X"$1" != X"-c"; then
  78.     echo 'x - skipping README-patch (File already exists)'
  79. else
  80. echo 'x - extracting README-patch (Text)'
  81. sed 's/^X//' << 'SHAR_EOF' > 'README-patch' &&
  82. PPPPPPPP        A        TTTTTTTTTTTT      CCCCCCC    H      H
  83. P       P      A A            T           C           H      H
  84. P       P     A   A           T           C           H      H
  85. PPPPPPP      A     A          T           C           HHHHHHHH
  86. P           A       A         T           C           H      H
  87. P          AAAAAAAAAAA        T           C           H      H
  88. P         A           A       T            CCCCCCC    H      H
  89. X
  90. M          MM       A         GGGGGGGG    IIIIIIII   CCCCCCC  
  91. M M       M M      A A       G        G      I      C         
  92. M  M     M  M     A   A      G               I      C         
  93. M   M   M   M    A     A     G  GGGGGGG      I      C         
  94. M    M M    M   AAAAAAAAA    G        G      I      C         
  95. M     M     M  A         A    GGGGGGGG    IIIIIIII   CCCCCCC  
  96. X
  97. X          CCCCCCC   U        U  BBBBBBB    EEEEEEEE
  98. X         C          U        U  B      B   E
  99. X         C          U        U  B      B   E
  100. X         C          U        U  BBBBBBBB   EEEEE
  101. X         C          U        U  B      B   E
  102. X          CCCCCCC    UUUUUUUU   BBBBBBB    EEEEEEEE 
  103. X       /////////                          ////////////     
  104. X       /////////     using X11/Motif      ////////////     
  105. X       //////////  V e r s i o n   1 . 0  ////////////
  106. X
  107. COPYRIGHT & DISCLAIMER STUFF:
  108. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  109. X
  110. Copyright (C) 1993 by Pierre A. Fleurant
  111. X                      Horizon Research, Inc
  112. X                      Email: fleurant@hri.com
  113. X
  114. X
  115. ////////////The following references were used:///////////////////////
  116. X
  117. X   "The X Window System Programming And Applications with Xt
  118. X   OSF/MOTIF EDITION"
  119. X   by Douglas A Young 
  120. X   Prentice-Hall, 1990.
  121. X   ISBN 0-13-642786-3
  122. X
  123. X   "Mastering Rubik's Cube"
  124. X   by Don Taylor
  125. X   An Owl Book; Holt, Rinehart and Winston, New York, 1980
  126. X   ISBN 0-03-059941-5
  127. X
  128. //////////////////////////////////////////////////////////////////////
  129. PATCH INFO:
  130. X
  131. These patches are for the SOLVING ALGORITHM.
  132. Thanks to C. at i.b.m. for pointing out a failure.
  133. X
  134. X   Execute the following in the cube directory.
  135. X          patch < patch3
  136. X
  137. X   Then rebuild:
  138. X          make 
  139. X          
  140. //////////////////////////////////////////////////////////////////////
  141. X   Please send comments to fleurant@hri.com
  142. X   "Don't say the `R' word!"
  143. SHAR_EOF
  144. chmod 0644 README-patch ||
  145. echo 'restore of README-patch failed'
  146. Wc_c="`wc -c < 'README-patch'`"
  147. test 2275 -eq "$Wc_c" ||
  148.     echo 'README-patch: original size 2275, current size' "$Wc_c"
  149. fi
  150. # ============= patch3 ==============
  151. if test -f 'patch3' -a X"$1" != X"-c"; then
  152.     echo 'x - skipping patch3 (File already exists)'
  153. else
  154. echo 'x - extracting patch3 (Text)'
  155. sed 's/^X//' << 'SHAR_EOF' > 'patch3' &&
  156. *** patchlevel.h    Mon May 24 09:54:40 1993
  157. --- patchlevel.h.02    Mon May 24 10:50:54 1993
  158. ***************
  159. *** 1,7 ****
  160. ! #define VERSION    "1.0.0"
  161. ! #define DATE    "10 May 1993"
  162. X  
  163. X  /*
  164. X   *  patch1        14 May 93       :Fix to seed_cube in cube.h; Bug became manifest in gcc
  165. X   *  patch2        14 May 93       :Fix to ldfile.c;  Bug became manifest in gcc
  166. X   */
  167. --- 1,10 ----
  168. ! #define VERSION    "1.0.2"
  169. ! #define DATE    "24 May 1993"
  170. X  
  171. X  /*
  172. X   *  patch1        14 May 93       :Fix to seed_cube in cube.h; Bug became manifest in gcc
  173. X   *  patch2        14 May 93       :Fix to ldfile.c;  Bug became manifest in gcc
  174. +  *  patch3              24 May 93       :Patches for layer2.c, layer3.c, layer3twirl.c, and layer3flip.c.
  175. +  *                                      :Discovered when magicCube hung solving "Pons Asinorum"
  176. X   */
  177. *** layer2.c    Fri May 21 11:26:32 1993
  178. --- layer2.c.02    Fri May 21 13:08:25 1993
  179. ***************
  180. *** 300,319 ****
  181. X       * So a middle layer cube must be moved out to the bottom layer.
  182. X       */
  183. X    else {
  184. !     if(Front(5) == RIGHT &&
  185. !        Right(3) == FRONT){
  186. X        F(1);D(2);L(1);D(1);L(-1);D(2);F(-1);     
  187. X      }
  188. !     else if(Right(5) == BACK &&
  189. !         Back(5) == RIGHT){
  190. X        R(1);D(2);F(1);D(1);F(-1);D(2);R(-1); 
  191. X      }
  192. !     else if(Back(3) == LEFT &&
  193. !         Left(5) == BACK){
  194. X        B(1);D(2);R(1);D(1);R(-1);D(2);B(-1); 
  195. X      }
  196. !     else if(Left(3) == FRONT &&
  197. !         Front(3) == LEFT){
  198. X        L(1);D(2);B(1);D(1);B(-1);D(2);L(-1);
  199. X      }
  200. X      return(False);
  201. --- 300,319 ----
  202. X       * So a middle layer cube must be moved out to the bottom layer.
  203. X       */
  204. X    else {
  205. !     if(Front(5) != FRONT ||
  206. !        Right(3) != RIGHT){
  207. X        F(1);D(2);L(1);D(1);L(-1);D(2);F(-1);     
  208. X      }
  209. !     else if(Right(5) != RIGHT ||
  210. !         Back(5) != BACK){
  211. X        R(1);D(2);F(1);D(1);F(-1);D(2);R(-1); 
  212. X      }
  213. !     else if(Back(3) != BACK ||
  214. !         Left(5) != LEFT){
  215. X        B(1);D(2);R(1);D(1);R(-1);D(2);B(-1); 
  216. X      }
  217. !     else if(Left(3) != LEFT ||
  218. !         Front(3) != FRONT){
  219. X        L(1);D(2);B(1);D(1);B(-1);D(2);L(-1);
  220. X      }
  221. X      return(False);
  222. *** layer3.c    Tue Apr 13 11:16:09 1993
  223. --- layer3.c.02    Mon May 24 10:19:41 1993
  224. ***************
  225. *** 292,298 ****
  226. X        /* A solution(3 to 5 to 7 to 3) */
  227. X        B(2);D(1);R(-1);L(1);B(2);R(1);L(-1);D(1);B(2);
  228. X      }
  229. !     else if(Right(7) == LEFT || Bottom(5) == LEFT){
  230. X        /* bottom(5) belongs in bottom(3) */
  231. X        /* B solution(5 to 3 to 7 to 5) */
  232. X        B(2);D(-1);R(-1);L(1);B(2);R(1);L(-1);D(-1);B(2);
  233. --- 292,298 ----
  234. X        /* A solution(3 to 5 to 7 to 3) */
  235. X        B(2);D(1);R(-1);L(1);B(2);R(1);L(-1);D(1);B(2);
  236. X      }
  237. !      else if(Right(7) == LEFT || Bottom(5) == LEFT){
  238. X        /* bottom(5) belongs in bottom(3) */
  239. X        /* B solution(5 to 3 to 7 to 5) */
  240. X        B(2);D(-1);R(-1);L(1);B(2);R(1);L(-1);D(-1);B(2);
  241. ***************
  242. *** 305,321 ****
  243. X      if(Back(7) == FRONT || Bottom(7) == FRONT){
  244. X        /* bottom(7) belongs in bottom(1) */
  245. X        /* A solution(7 to 1 to 5 to 7) */
  246. !       L(2);D(1);F(-1);B(1);L(2);F(1);B(-1);D(1);L(2);
  247. X      }
  248. X      else if(Front(7) == BACK || Bottom(1) == BACK){
  249. X        /* bottom(1) belongs in bottom(7) */
  250. X        /* B solution(1 to 7 to 5 to 1) */
  251. !       L(2);D(-1);F(-1);B(1);L(2);F(1);B(-1);D(-1);L(2);
  252. X      }
  253. X      else{ ; } /* all edges in proper place */
  254. X    }
  255. X  
  256. !   else if(Right(7) == RIGHT || Bottom(3) == RIGHT){
  257. X      /* bottom(5) ok */
  258. X      if(Front(7) == BACK || Bottom(1) == BACK){
  259. X        /* bottom(1) belongs in bottom(7) */
  260. --- 305,321 ----
  261. X      if(Back(7) == FRONT || Bottom(7) == FRONT){
  262. X        /* bottom(7) belongs in bottom(1) */
  263. X        /* A solution(7 to 1 to 5 to 7) */
  264. !       R(2);D(1);F(-1);B(1);R(2);F(1);B(-1);D(1);R(2);
  265. X      }
  266. X      else if(Front(7) == BACK || Bottom(1) == BACK){
  267. X        /* bottom(1) belongs in bottom(7) */
  268. X        /* B solution(1 to 7 to 5 to 1) */
  269. !       R(2);D(-1);F(-1);B(1);R(2);F(1);B(-1);D(-1);R(2);
  270. X      }
  271. X      else{ ; } /* all edges in proper place */
  272. X    }
  273. X  
  274. !   else if(Right(7) == RIGHT || Bottom(5) == RIGHT){
  275. X      /* bottom(5) ok */
  276. X      if(Front(7) == BACK || Bottom(1) == BACK){
  277. X        /* bottom(1) belongs in bottom(7) */
  278. ***************
  279. *** 330,336 ****
  280. X      else{ ; } /* all edges in proper place */
  281. X    }
  282. X    
  283. !   else if(Back(7) == BACK || Bottom(3) == BACK){
  284. X      /* bottom(7) ok */
  285. X      if(Right(7) == LEFT || Bottom(5) == LEFT){
  286. X        /* bottom(5) belongs in bottom(3) */
  287. --- 330,336 ----
  288. X      else{ ; } /* all edges in proper place */
  289. X    }
  290. X    
  291. !   else if(Back(7) == BACK || Bottom(7) == BACK){
  292. X      /* bottom(7) ok */
  293. X      if(Right(7) == LEFT || Bottom(5) == LEFT){
  294. X        /* bottom(5) belongs in bottom(3) */
  295. ***************
  296. *** 352,363 ****
  297. X        /* D solution(1 to 3; 3 to 1; 5 to 7; 7 to 5) */
  298. X        F(1);L(1);D(1);L(-1);D(-1);F(2);R(-1);D(-1);R(1);D(1);F(1);
  299. X      }
  300. !     else if(Front(7) == BACK || Bottom(7) == BACK){
  301. X        /* bottom(1) belongs in bottom(7) */
  302. X        /* C solution(1 to 7; 7 to 1; 3 to 5; 5 to 3) */
  303. X        R(2);L(2);U(1);R(2);L(2);D(2);R(2);L(2);U(1);R(2);L(2);
  304. X      }
  305. !     else if(Front(7) == RIGHT || Bottom(5) == RIGHT){
  306. X        /* bottom(1) belongs in bottom(5) */
  307. X        /* D solution(1 to 5; 5 to 1; 3 to 7; 7 to 3) */
  308. X        R(1);F(1);D(1);F(-1);D(-1);R(2);B(-1);D(-1);B(1);D(1);R(1);
  309. --- 352,363 ----
  310. X        /* D solution(1 to 3; 3 to 1; 5 to 7; 7 to 5) */
  311. X        F(1);L(1);D(1);L(-1);D(-1);F(2);R(-1);D(-1);R(1);D(1);F(1);
  312. X      }
  313. !     else if(Front(7) == BACK || Bottom(1) == BACK){
  314. X        /* bottom(1) belongs in bottom(7) */
  315. X        /* C solution(1 to 7; 7 to 1; 3 to 5; 5 to 3) */
  316. X        R(2);L(2);U(1);R(2);L(2);D(2);R(2);L(2);U(1);R(2);L(2);
  317. X      }
  318. !     else if(Front(7) == RIGHT || Bottom(1) == RIGHT){
  319. X        /* bottom(1) belongs in bottom(5) */
  320. X        /* D solution(1 to 5; 5 to 1; 3 to 7; 7 to 3) */
  321. X        R(1);F(1);D(1);F(-1);D(-1);R(2);B(-1);D(-1);B(1);D(1);R(1);
  322. ***************
  323. *** 368,370 ****
  324. --- 368,371 ----
  325. X    }
  326. X  
  327. X  }
  328. *** layer3twirl.c    Thu May 20 11:26:41 1993
  329. --- layer3twirl.c.02    Thu May 20 14:21:13 1993
  330. ***************
  331. *** 51,57 ****
  332. X       Back(8)  == BACK  &&
  333. X       Left(8)  == LEFT)
  334. X      return(True);
  335. X    /* Here if not ok */
  336. X    /* Twirl corners */
  337. X    /* 3 possibilities:
  338. --- 51,57 ----
  339. X       Back(8)  == BACK  &&
  340. X       Left(8)  == LEFT)
  341. X      return(True);
  342. !   
  343. X    /* Here if not ok */
  344. X    /* Twirl corners */
  345. X    /* 3 possibilities:
  346. ***************
  347. *** 62,68 ****
  348. X     * The twirl algorithm twirls one corner clockwise, and another anti-clockwise.
  349. X     * This is repeated until all 4 corners are correct.
  350. X     */
  351. X    /* Find a corner that needs a clockwise twirl.
  352. X     * (Note: all corners are in correct position.
  353. X     * A corner needs a clockwise twirl if the front matches the top with
  354. --- 62,68 ----
  355. X     * The twirl algorithm twirls one corner clockwise, and another anti-clockwise.
  356. X     * This is repeated until all 4 corners are correct.
  357. X     */
  358. !   
  359. X    /* Find a corner that needs a clockwise twirl.
  360. X     * (Note: all corners are in correct position.
  361. X     * A corner needs a clockwise twirl if the front matches the top with
  362. ***************
  363. *** 69,75 ****
  364. X     * said cube oriented in a top right-hand position.
  365. X     * A corner needs an anti-clockwise twirl if the right-hand face matches the top.)
  366. X     */
  367. X    if(Front(6) == BOTTOM){
  368. X      L(-1);U(1);L(1);F(1);U(1);F(-1);
  369. X      /* Now search for cube that needs an anti-clockwise turn. */
  370. --- 69,75 ----
  371. X     * said cube oriented in a top right-hand position.
  372. X     * A corner needs an anti-clockwise twirl if the right-hand face matches the top.)
  373. X     */
  374. !   
  375. X    if(Front(6) == BOTTOM){
  376. X      L(-1);U(1);L(1);F(1);U(1);F(-1);
  377. X      /* Now search for cube that needs an anti-clockwise turn. */
  378. ***************
  379. *** 83,89 ****
  380. X        F(1);U(-1);F(-1);L(-1);U(-1);L(1);
  381. X        D(2);
  382. X      }
  383. !     else if(Front(8) == BOTTOM){
  384. X        D(-1);
  385. X        F(1);U(-1);F(-1);L(-1);U(-1);L(1);
  386. X        D(1);
  387. --- 83,96 ----
  388. X        F(1);U(-1);F(-1);L(-1);U(-1);L(1);
  389. X        D(2);
  390. X      }
  391. !     else { 
  392. !       /* This is the default case.
  393. !        * Here Front(8) == BOTTOM or there
  394. !        * are no other cubes that need an anti-clockwise turn.
  395. !        * No other cubes that need an anti-clockwise turn means 
  396. !        * that we are in case 3 and 3 cubes
  397. !        * need a clockwise turn.
  398. !        */
  399. X        D(-1);
  400. X        F(1);U(-1);F(-1);L(-1);U(-1);L(1);
  401. X        D(1);
  402. ***************
  403. *** 101,107 ****
  404. X        R(1);U(-1);R(-1);F(-1);U(-1);F(1);
  405. X        D(2);
  406. X      }
  407. !     else if(Right(8) == BOTTOM){
  408. X        D(-1);
  409. X        R(1);U(-1);R(-1);F(-1);U(-1);F(1);
  410. X        D(1);
  411. --- 108,114 ----
  412. X        R(1);U(-1);R(-1);F(-1);U(-1);F(1);
  413. X        D(2);
  414. X      }
  415. !     else {
  416. X        D(-1);
  417. X        R(1);U(-1);R(-1);F(-1);U(-1);F(1);
  418. X        D(1);
  419. ***************
  420. *** 119,125 ****
  421. X        B(1);U(-1);B(-1);R(-1);U(-1);R(1);
  422. X        D(2);
  423. X      }
  424. !     else if(Back(6) == BOTTOM){
  425. X        D(-1);
  426. X        B(1);U(-1);B(-1);R(-1);U(-1);R(1);
  427. X        D(1);
  428. --- 126,132 ----
  429. X        B(1);U(-1);B(-1);R(-1);U(-1);R(1);
  430. X        D(2);
  431. X      }
  432. !     else {
  433. X        D(-1);
  434. X        B(1);U(-1);B(-1);R(-1);U(-1);R(1);
  435. X        D(1);
  436. ***************
  437. *** 137,143 ****
  438. X        L(1);U(-1);L(-1);B(-1);U(-1);B(1);
  439. X        D(2);
  440. X      }
  441. !     else if(Left(6) == BOTTOM){
  442. X        D(-1);
  443. X        L(1);U(-1);L(-1);B(-1);U(-1);B(1);
  444. X        D(1);
  445. --- 144,150 ----
  446. X        L(1);U(-1);L(-1);B(-1);U(-1);B(1);
  447. X        D(2);
  448. X      }
  449. !     else {
  450. X        D(-1);
  451. X        L(1);U(-1);L(-1);B(-1);U(-1);B(1);
  452. X        D(1);
  453. SHAR_EOF
  454. chmod 0644 patch3 ||
  455. echo 'restore of patch3 failed'
  456. Wc_c="`wc -c < 'patch3'`"
  457. test 9496 -eq "$Wc_c" ||
  458.     echo 'patch3: original size 9496, current size' "$Wc_c"
  459. fi
  460. exit 0
  461.  
  462. exit 0 # Just in case...
  463.