Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 137.66 KB | None | 0 0
  1. package application;
  2.  
  3. import java.awt.image.BufferedImage;
  4. import java.awt.image.DataBufferByte;
  5. import java.io.PrintWriter;
  6. import java.util.ArrayList;
  7. import java.util.Random;
  8. import java.util.concurrent.ScheduledExecutorService;
  9.  
  10. import org.opencv.core.Core;
  11. import org.opencv.core.Mat;
  12. import org.opencv.core.Scalar;
  13.  
  14. import com.fazecast.jSerialComm.SerialPort;
  15.  
  16. import application.Couleur.CouleurEnum;
  17. import javafx.application.Application;
  18. import javafx.event.ActionEvent;
  19. import javafx.event.EventHandler;
  20. import javafx.geometry.Insets;
  21. import javafx.geometry.Pos;
  22. import javafx.geometry.Rectangle2D;
  23. import javafx.scene.Scene;
  24. import javafx.scene.control.Button;
  25. import javafx.scene.control.TextArea;
  26. import javafx.scene.control.TextField;
  27. import javafx.scene.layout.GridPane;
  28. import javafx.scene.layout.HBox;
  29. import javafx.scene.layout.VBox;
  30. import javafx.stage.Screen;
  31. import javafx.stage.Stage;
  32.  
  33.  
  34. public class Main extends Application implements EventHandler<javafx.event.ActionEvent> {
  35.  
  36. static{
  37. System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  38. }
  39.  
  40. public static void main(String[] args) throws InterruptedException {
  41. launch(args);
  42.  
  43. }
  44.  
  45. /*
  46. * MELANGE CHELOU
  47. */
  48.  
  49. //R' B' R' U R' F D' R2 B L' D L D L F2 U2 L' B' U' L' U F' L F L' 282
  50. //R2 D2 F' L' D' F R' B2 D' B' R' F' L' U' F L B' L' B R F2 D2 L F' R2 411
  51.  
  52. /*
  53. *
  54. * VARIABLE POUR LA PARTIE RESOLUTION
  55. *
  56. */
  57.  
  58. PrintWriter pw = null;
  59.  
  60. CouleurEnum[][] FaceJaune = {{CouleurEnum.JAUNE, CouleurEnum.JAUNE, CouleurEnum.JAUNE},
  61. {CouleurEnum.JAUNE, CouleurEnum.JAUNE, CouleurEnum.JAUNE},
  62. {CouleurEnum.JAUNE, CouleurEnum.JAUNE, CouleurEnum.JAUNE}};
  63. CouleurEnum[][] FaceBleu = {{CouleurEnum.BLEU, CouleurEnum.BLEU, CouleurEnum.BLEU},
  64. {CouleurEnum.BLEU, CouleurEnum.BLEU,CouleurEnum.BLEU},
  65. {CouleurEnum.BLEU, CouleurEnum.BLEU, CouleurEnum.BLEU}};
  66. CouleurEnum[][] FaceRouge = {{CouleurEnum.ROUGE, CouleurEnum.ROUGE, CouleurEnum.ROUGE},
  67. {CouleurEnum.ROUGE, CouleurEnum.ROUGE, CouleurEnum.ROUGE},
  68. {CouleurEnum.ROUGE, CouleurEnum.ROUGE, CouleurEnum.ROUGE}};
  69. CouleurEnum[][] FaceVert = {{CouleurEnum.VERT, CouleurEnum.VERT, CouleurEnum.VERT},
  70. {CouleurEnum.VERT, CouleurEnum.VERT, CouleurEnum.VERT},
  71. {CouleurEnum.VERT, CouleurEnum.VERT, CouleurEnum.VERT}};
  72. CouleurEnum[][] FaceOrange = {{CouleurEnum.ORANGE, CouleurEnum.ORANGE, CouleurEnum.ORANGE},
  73. {CouleurEnum.ORANGE, CouleurEnum.ORANGE, CouleurEnum.ORANGE},
  74. {CouleurEnum.ORANGE, CouleurEnum.ORANGE, CouleurEnum.ORANGE}};
  75. CouleurEnum[][] FaceBlanc = {{CouleurEnum.BLANC, CouleurEnum.BLANC, CouleurEnum.BLANC},
  76. {CouleurEnum.BLANC, CouleurEnum.BLANC, CouleurEnum.BLANC},
  77. {CouleurEnum.BLANC, CouleurEnum.BLANC, CouleurEnum.BLANC}};
  78. CouleurEnum[][] TabRef = new CouleurEnum[3][3];
  79.  
  80. CouleurEnum[][] bufferJaune = new CouleurEnum[3][3];
  81. CouleurEnum[][] bufferBleu = new CouleurEnum[3][3];
  82. CouleurEnum[][] bufferRouge = new CouleurEnum[3][3];
  83. CouleurEnum[][] bufferVert = new CouleurEnum[3][3];
  84. CouleurEnum[][] bufferOrange = new CouleurEnum[3][3];
  85. CouleurEnum[][] bufferBlanc = new CouleurEnum[3][3];
  86.  
  87. boolean BooJVO = false;
  88. boolean BooJR = false;
  89.  
  90. /*
  91. * STRING/INT RESOLUTION
  92. */
  93.  
  94. ArrayList<String> string_solv = new ArrayList<String>();
  95. ArrayList<String> fin_string_solv = new ArrayList<String>();
  96. String optiMov = new String();
  97. String fin_optiMov = new String();
  98.  
  99. String Resolution = "";
  100. String arduinoResolution = "";
  101. String optiResolution = "";
  102. String reducResolution = "";
  103. String reducResolution1 = "";
  104. String reducResolution2 = "";
  105. int optiInt = 0;
  106. String cours = "";
  107. String final_cours = "";
  108. String melange_env = "";
  109.  
  110. /*
  111. * COIN
  112. */
  113.  
  114. String prochaineCouleur = "JAUNE";
  115. String prochaineCouleur2 = "VERT";
  116. String prochaineCouleur3 = "ORANGE";
  117.  
  118. int prochainX = 0;
  119. int prochainY = 0;
  120. int prochainX2 = 0;
  121. int prochainY2 = 2;
  122. int prochainX3 = 0;
  123. int prochainY3 = 0;
  124.  
  125. String[] Coin = {"JRV", "JBR", "JBO", "BOBl", "BRBl", "RVBl", "VOBl"};
  126. ArrayList<String> CoinOri = new ArrayList<String>();
  127.  
  128. /*
  129. * ARETE
  130. */
  131.  
  132. String prochaineCouleurA = "JAUNE";
  133. String prochaineCouleur2A = "ROUGE";
  134.  
  135. int prochainXA = 1;
  136. int prochainYA = 2;
  137. int prochainX2A = 0;
  138. int prochainY2A = 1;
  139.  
  140. String[] Arrete = {"JV","JB","JO","VO","RV","BR","BO","BBl","RBl","VBl","OBl"};
  141. ArrayList<String> ArreteOri = new ArrayList<String>();
  142.  
  143. /*
  144. * INT ??
  145. */
  146.  
  147. int i1 = 1;
  148. int i2 = 2;
  149. int i3 = 3;
  150. int paireimpaire = 0;
  151. int test = 0;
  152.  
  153. /*
  154. * DECLARATION DE COINS
  155. */
  156.  
  157. Coin JVO = new Coin();
  158. Coin JRV = new Coin();
  159. Coin JBR = new Coin();
  160. Coin JBO = new Coin();
  161. Coin BOBl = new Coin();
  162. Coin BRBl = new Coin();
  163. Coin RVBl = new Coin();
  164. Coin VOBl = new Coin();
  165.  
  166. /*
  167. * DECLARATION D'ARETES
  168. */
  169.  
  170. Arete JV = new Arete();
  171. Arete JR = new Arete();
  172. Arete JB = new Arete();
  173. Arete JO = new Arete();
  174. Arete VO = new Arete();
  175. Arete RV = new Arete();
  176. Arete BR = new Arete();
  177. Arete BO = new Arete();
  178. Arete BBl = new Arete();
  179. Arete RBl = new Arete();
  180. Arete VBl = new Arete();
  181. Arete OBl = new Arete();
  182.  
  183. /*
  184. * PLL
  185. */
  186. String PLLY = new String("FRU'R'U'RUR'F'RUR'U'R'FRF'");
  187. String PLLJS = new String("RUL'U2RU'R'U2LRU'R2");
  188. String PLLJ = new String("RU2R'U'RU2L'UR'U'L");
  189. String PLLJM = new String("RF2R'F'RF2L'FR'F'L");
  190. String PLLJMP = new String("RB2R'B'RB2L'BR'B'L");
  191. String PLLJP = new String("U'R'UL'U2RU'R'U2RL");
  192. String PLLJPM = new String("F'R'FL'F2RF'R'F2RL");
  193. String PLLJPMP = new String("B'R'BL'B2RB'R'B2RL");
  194. String PLLT = new String("RUR'U'R'FR2U'R'U'RUR'F'");
  195. String PLLTE = new String("BUB'U'B'RB2U'B'U'BUB'R'");
  196. String PLLTEP = new String("FUF'U'F'LF2U'F'U'FUF'L'");
  197. String PLLTE2 = new String("LUL'U'L'BL2U'L'U'LUL'B'");
  198. String PLLRP = new String("RUR'F'RU2R'U2R'FRURU2R'U'");
  199. String OLLM = new String("FB'RFB'DFB'L2F'BDF'BRF'BU2");
  200. String OLLMM2 = new String("BF'RBF'UBF'L2B'FUB'FRB'FD2");
  201. String OLLME2 = new String("BF'LBF'DBF'R2B'FDB'FLB'FU2");
  202.  
  203. /*
  204. * METHODES COINS
  205. */
  206.  
  207. String JRVJ = new String("R2" + PLLJS + "R2");
  208. String JRVR = new String("RD'R" + PLLY + "R'DR'");
  209. String JRVV = new String("R'" + PLLY + "R");
  210. String JBRJ = new String(PLLY);
  211. String JBRB = new String("R'" + PLLJS + "R");
  212. String JBRR = new String("F" + PLLJS + "F'");
  213. String JBOJ = new String("F2" + PLLJS + "F2");
  214. String JBOB = new String("FR'" + PLLJS + "RF'");
  215. String JBOO = new String("F" + PLLY + "F'");
  216. String BOBlB = new String("DF'" + PLLY + "FD'");
  217. String BOBlO = new String("DR" + PLLY + "R'D'");
  218. String BOBlBl = new String("D" + PLLJS + "D'");
  219. String BRBlB = new String("R" + PLLY + "R'");
  220. String BRBlR = new String("F'" + PLLY + "F");
  221. String BRBlBl = new String(PLLJS);
  222. String RVBlR = new String("D'R" + PLLY + "R'D");
  223. String RVBlV = new String("D'F'" + PLLY + "FD");
  224. String RVBlBl = new String("D'" + PLLJS + "D");
  225. String VOBlV = new String("D2R" + PLLY + "R'D2");
  226. String VOBlO = new String("D2F'" + PLLY + "FD2");
  227. String VOBlBl = new String("D2" + PLLJS + "D2");
  228.  
  229. /*
  230. * METHODES ARETES
  231. */
  232.  
  233. String JVJ = new String(PLLJP);
  234. String JVV = new String("RL'" + PLLJMP + "LR'");
  235. String JBJ = new String(PLLJ);
  236. String JBB = new String("LR'" + PLLJPM + "RL'");
  237. String JOJ = new String(PLLT);
  238. String JOO = new String("L2DLR'" + PLLJM + "RL'D'L2");
  239. String VOV = new String("L" + PLLT + "L'");
  240. String VOO = new String("UD'B'" + PLLTEP + "BDU'");
  241. String RVR = new String("UD'B" + PLLTEP + "B'DU'");
  242. String RVV = new String("U2D2R'" + PLLTE2 + "RD2U2");
  243. String BRB = new String("U2D2R" + PLLTE2 + "R'D2U2");
  244. String BRR = new String("U'DF'" + PLLTE + "FD'U");
  245. String BOB = new String("L'" + PLLT + "L");
  246. String BOO = new String("U'DF" + PLLTE + "F'D'U");
  247. String BBlB = new String("R'L" + PLLJM + "L'R");
  248. String BBlBl = new String("D'L2" + PLLT + "L2D");
  249. String RBlR = new String("D'R'L" + PLLJM + "L'RD");
  250. String RBlBl = new String("D2L2" + PLLT + "L2D2");
  251. String VBlV = new String("RL'" + PLLJPMP + "LR'");
  252. String VBlBl = new String("DL2" + PLLT + "L2D'");
  253. String OBlO = new String("DR'L" + PLLJM + "L'RD'");
  254. String OBlBl = new String("L2" + PLLT + "L2");
  255. String JVF = new String("R2L2U'L2" + OLLMM2 + "L2UL2R2");
  256. String JBF = new String("R2L2UL2" + OLLMM2 + "L2U'L2R2");
  257. String JOF = new String(OLLM);
  258. String VOF = new String("L" + OLLM + "L'");
  259. String RVF = new String("U2D2R'" + OLLME2 + "RD2U2");
  260. String BRF = new String("U2D2R" + OLLME2 + "R'D2U2");
  261. String BOF = new String("L'" + OLLM + "L");
  262. String BBlF = new String("D'L2" + OLLM + "L2D");
  263. String RBlF = new String("D2L2" + OLLM + "L2D2");
  264. String VBlF = new String("DL2" + OLLM + "L2D'");
  265. String OBlF = new String("L2" + OLLM + "L2");
  266.  
  267. /*
  268. * POSTIONS COINS
  269. */
  270.  
  271. String JRVJP = new String("02");
  272. String JRVRP = new String("02");
  273. String JRVVP = new String("00");
  274. String JBRJP = new String("22");
  275. String JBRBP = new String("02");
  276. String JBRRP = new String("00");
  277. String JBOJP = new String("20");
  278. String JBOBP = new String("00");
  279. String JBOOP = new String("02");
  280. String BOBlBP = new String("20");
  281. String BOBlOP = new String("22");
  282. String BOBlBlP = new String("00");
  283. String BRBlBP = new String("22");
  284. String BRBlRP = new String("20");
  285. String BRBlBlP = new String("02");
  286. String RVBlRP = new String("22");
  287. String RVBlVP = new String("20");
  288. String RVBlBlP = new String("22");
  289. String VOBlVP = new String("22");
  290. String VOBlOP = new String("20");
  291. String VOBlBlP = new String("20");
  292.  
  293. /*
  294. * POSITION ARETES
  295. */
  296. String JVJP = new String("01");
  297. String JVVP = new String("01");
  298. String JBJP = new String("21");
  299. String JBBP = new String("01");
  300. String JOJP = new String("10");
  301. String JOOP = new String("01");
  302. String VOVP = new String("12");
  303. String VOOP = new String("10");
  304. String RVRP = new String("12");
  305. String RVVP = new String("10");
  306. String BRBP = new String("12");
  307. String BRRP = new String("10");
  308. String BOBP = new String("10");
  309. String BOOP = new String("12");
  310. String BBlBP = new String("21");
  311. String BBlBlP = new String("01");
  312. String RBlRP = new String("21");
  313. String RBlBlP = new String("12");
  314. String VBlVP = new String("21");
  315. String VBlBlP = new String("21");
  316. String OBlOP = new String("21");
  317. String OBlBlP = new String("10");
  318.  
  319. /*
  320. * Creation d'un Random avec une seed changeante
  321. */
  322.  
  323. static Random rand = new Random(System.currentTimeMillis());
  324.  
  325. /*
  326. * Les faces du Rubik's Cube avec leur axe
  327. */
  328.  
  329. static String faces[] = { "RX", "LX", "UY", "DY", "FZ", "BZ" };
  330.  
  331.  
  332. /*
  333. *
  334. * VARIABLE POUR L'INTERFACE
  335. *
  336. */
  337.  
  338. /*
  339. * INT INTERFACE
  340. */
  341.  
  342. int detectColor = 0;
  343.  
  344. /*
  345. * DIIFERENCE DE COULEURS
  346. */
  347.  
  348. double difJaune;
  349. double difBleu;
  350. double difRouge;
  351. double difOrange;
  352. double difVert;
  353. int comptcouleur;
  354. int comptblanc;
  355.  
  356. /*
  357. * COORDONNES A CHECK POUR COULEUR
  358. */
  359.  
  360. int sticker1x = 167;
  361. int sticker1y = 87;
  362. int sticker2x = 317;
  363. int sticker2y = 87;
  364. int sticker3x = 467;
  365. int sticker3y = 87;
  366. int sticker4x = 167;
  367. int sticker4y = 237;
  368. int sticker5x = 317;
  369. int sticker5y = 237;
  370. int sticker6x = 467;
  371. int sticker6y = 237;
  372. int sticker7x = 167;
  373. int sticker7y = 387;
  374. int sticker8x = 317;
  375. int sticker8y = 387;
  376. int sticker9x = 467;
  377. int sticker9y = 387;
  378.  
  379. /*
  380. * STAGE
  381. */
  382.  
  383. Stage windows;
  384.  
  385. /*
  386. * SCALAR
  387. */
  388.  
  389. Scalar stick1 = null;
  390. Scalar stick2 = null;
  391. Scalar stick3 = null;
  392. Scalar stick4 = null;
  393. Scalar stick5 = null;
  394. Scalar stick6 = null;
  395. Scalar stick7 = null;
  396. Scalar stick8 = null;
  397. Scalar stick9 = null;
  398.  
  399. Scalar rouge = new Scalar(0, 0, 255);
  400. Scalar bleu = new Scalar(255, 0, 0);
  401. Scalar vert = new Scalar(0, 255, 0);
  402. Scalar jaune = new Scalar(0, 255, 255);
  403. Scalar orange = new Scalar(0, 124, 255);
  404. Scalar blanc = new Scalar(255, 255, 255);
  405.  
  406. Scalar determinateColor;
  407.  
  408. Scalar gris = new Scalar(156, 156, 156);
  409.  
  410. /*
  411. * BOUTON
  412. */
  413.  
  414. Button j1 = new Button("j00");
  415. Button j2 = new Button("j01");
  416. Button j3 = new Button("j02");
  417. Button j4 = new Button("j03");
  418. Button j5 = new Button("j04");
  419. Button j6 = new Button("j05");
  420. Button j7 = new Button("j06");
  421. Button j8 = new Button("j07");
  422. Button j9 = new Button("j08");
  423.  
  424. Button b1 = new Button("b10");
  425. Button b2 = new Button("b11");
  426. Button b3 = new Button("b12");
  427. Button b4 = new Button("b13");
  428. Button b5 = new Button("b14");
  429. Button b6 = new Button("b15");
  430. Button b7 = new Button("b16");
  431. Button b8 = new Button("b17");
  432. Button b9 = new Button("b18");
  433.  
  434. Button r1 = new Button("r20");
  435. Button r2 = new Button("r21");
  436. Button r3 = new Button("r22");
  437. Button r4 = new Button("r23");
  438. Button r5 = new Button("r24");
  439. Button r6 = new Button("r25");
  440. Button r7 = new Button("r26");
  441. Button r8 = new Button("r27");
  442. Button r9 = new Button("r28");
  443.  
  444. Button v1 = new Button("v30");
  445. Button v2 = new Button("v31");
  446. Button v3 = new Button("v32");
  447. Button v4 = new Button("v33");
  448. Button v5 = new Button("v34");
  449. Button v6 = new Button("v35");
  450. Button v7 = new Button("v36");
  451. Button v8 = new Button("v37");
  452. Button v9 = new Button("v38");
  453.  
  454. Button o1 = new Button("o40");
  455. Button o2 = new Button("o41");
  456. Button o3 = new Button("o42");
  457. Button o4 = new Button("o43");
  458. Button o5 = new Button("o44");
  459. Button o6 = new Button("o45");
  460. Button o7 = new Button("o46");
  461. Button o8 = new Button("o47");
  462. Button o9 = new Button("o48");
  463.  
  464. Button bl1 = new Button("l50");
  465. Button bl2 = new Button("l51");
  466. Button bl3 = new Button("l52");
  467. Button bl4 = new Button("l53");
  468. Button bl5 = new Button("l54");
  469. Button bl6 = new Button("l55");
  470. Button bl7 = new Button("l56");
  471. Button bl8 = new Button("l57");
  472. Button bl9 = new Button("l58");
  473.  
  474. Button button[][] = {{j1, j2, j3, j4, j5, j6, j7, j8, j9},
  475. {b1, b2, b3, b4, b5, b6, b7, b8, b9},
  476. {r1, r2, r3, r4, r5, r6, r7, r8, r9},
  477. {v1, v2, v3, v4, v5, v6, v7, v8, v9},
  478. {o1, o2, o3, o4, o5, o6, o7, o8, o9},
  479. {bl1, bl2, bl3, bl4, bl5, bl6, bl7, bl8, bl9}};
  480.  
  481. Button res = new Button("Resolution");
  482. Button mel = new Button("Melange");
  483. Button test_mo = new Button("Test Moteur");
  484. Button env_mel = new Button("Envoyer melange");
  485. Button reset = new Button("Reset");
  486.  
  487. Button paint_jaune = new Button(".");
  488. Button paint_bleu = new Button(".");
  489. Button paint_rouge = new Button(".");
  490. Button paint_vert = new Button(".");
  491. Button paint_orange = new Button(".");
  492. Button paint_blanc = new Button(".");
  493.  
  494.  
  495. /*
  496. * INT
  497. */
  498.  
  499. int ij1 = 0;
  500. int ij2 = 0;
  501. int ij3 = 0;
  502. int ij4 = 0;
  503. int ij5 = 1;
  504. int ij6 = 0;
  505. int ij7 = 0;
  506. int ij8 = 0;
  507. int ij9 = 0;
  508.  
  509. int ib1 = 0;
  510. int ib2 = 0;
  511. int ib3 = 0;
  512. int ib4 = 0;
  513. int ib5 = 1;
  514. int ib6 = 0;
  515. int ib7 = 0;
  516. int ib8 = 0;
  517. int ib9 = 0;
  518.  
  519. int ir1 = 0;
  520. int ir2 = 0;
  521. int ir3 = 0;
  522. int ir4 = 0;
  523. int ir5 = 1;
  524. int ir6 = 0;
  525. int ir7 = 0;
  526. int ir8 = 0;
  527. int ir9 = 0;
  528.  
  529. int iv1 = 0;
  530. int iv2 = 0;
  531. int iv3 = 0;
  532. int iv4 = 0;
  533. int iv5 = 1;
  534. int iv6 = 0;
  535. int iv7 = 0;
  536. int iv8 = 0;
  537. int iv9 = 0;
  538.  
  539. int io1 = 0;
  540. int io2 = 0;
  541. int io3 = 0;
  542. int io4 = 0;
  543. int io5 = 1;
  544. int io6 = 0;
  545. int io7 = 0;
  546. int io8 = 0;
  547. int io9 = 0;
  548.  
  549. int ibl1 = 0;
  550. int ibl2 = 0;
  551. int ibl3 = 0;
  552. int ibl4 = 0;
  553. int ibl5 = 1;
  554. int ibl6 = 0;
  555. int ibl7 = 0;
  556. int ibl8 = 0;
  557. int ibl9 = 0;
  558.  
  559. int intButton[][] = {{ij1, ij2, ij3, ij4, ij5, ij6, ij7, ij8, ij9},
  560. {ib1, ib2, ib3, ib4, ib5, ib6, ib7, ib8, ib9},
  561. {ir1, ir2, ir3, ir4, ir5, ir6, ir7, ir8, ir9},
  562. {iv1, iv2, iv3, iv4, iv5, iv6, iv7, iv8, iv9},
  563. {io1, io2, io3, io4, io5, io6, io7, io8, io9},
  564. {ibl1, ibl2, ibl3, ibl4, ibl5, ibl6, ibl7, ibl8, ibl9}};
  565.  
  566. int rep_jaune = 0;
  567. int rep_bleu = 0;
  568. int rep_rouge = 0;
  569. int rep_vert = 0;
  570. int rep_orange = 0;
  571. int rep_blanc = 0;
  572.  
  573. int icamera = 1;
  574.  
  575. ScheduledExecutorService timer;
  576.  
  577. /*
  578. * JAVAFX NODE
  579. */
  580.  
  581. GridPane grid_jaune = new GridPane();
  582. GridPane grid_bleu = new GridPane();
  583. GridPane grid_rouge = new GridPane();
  584. GridPane grid_vert = new GridPane();
  585. GridPane grid_orange = new GridPane();
  586. GridPane grid_blanc = new GridPane();
  587.  
  588. TextArea text = new TextArea();
  589. TextField text1 = new TextField();
  590. TextField text2 = new TextField();
  591.  
  592. HBox hbox = new HBox();
  593. HBox hbox1 = new HBox();
  594. HBox hbox2 = new HBox();
  595. VBox vbox = new VBox();
  596. VBox vbox2 = new VBox();
  597. VBox vbox3 = new VBox();
  598. VBox vbox4 = new VBox();
  599. VBox vbox5 = new VBox();
  600.  
  601. @Override
  602. public void start(Stage primaryStage) throws InterruptedException {
  603.  
  604. /*
  605. * MISE EN PLACE DE L'INTERFACE
  606. */
  607.  
  608. Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
  609. double x = visualBounds.getWidth();
  610. double y = visualBounds.getHeight();
  611.  
  612. double mulx = x / 1920;
  613. double muly = y / 1080;
  614.  
  615. windows = primaryStage;
  616. windows.setTitle("CubeSolver");
  617.  
  618. stick1 = gris;
  619. stick2 = gris;
  620. stick3 = gris;
  621. stick4 = gris;
  622. stick5 = gris;
  623. stick6 = gris;
  624. stick7 = gris;
  625. stick8 = gris;
  626. stick9 = gris;
  627.  
  628. //JAUNE
  629. for(int i_jaune = 0; i_jaune < 3; i_jaune++) {
  630. for(int y_jaune = 0; y_jaune < 3; y_jaune++) {
  631. GridPane.setConstraints(button[0][rep_jaune], y_jaune, i_jaune);
  632. grid_jaune.getChildren().add(button[0][rep_jaune]);
  633. button[0][rep_jaune].setId("bouton_null__");
  634. button[0][rep_jaune].setMinSize(40 * 0.9, 40 * 0.9);
  635. button[0][rep_jaune].setOnAction(this);
  636. rep_jaune++;
  637. }
  638. }
  639.  
  640. button[0][4].setId("bouton_jaune_");
  641.  
  642. //BLEU
  643. for(int i_bleu = 0; i_bleu < 3; i_bleu++) {
  644. for(int y_bleu = 0; y_bleu < 3; y_bleu++) {
  645. GridPane.setConstraints(button[1][rep_bleu], y_bleu, i_bleu);
  646. grid_bleu.getChildren().add(button[1][rep_bleu]);
  647. button[1][rep_bleu].setId("bouton_null__");
  648. button[1][rep_bleu].setMinSize(40 * 0.9, 40 * 0.9);
  649. button[1][rep_bleu].setOnAction(this);
  650. rep_bleu++;
  651. }
  652. }
  653.  
  654. button[1][4].setId("bouton_bleu__");
  655.  
  656. //ROUGE
  657. for(int i_rouge = 0; i_rouge < 3; i_rouge++) {
  658. for(int y_rouge = 0; y_rouge < 3; y_rouge++) {
  659. GridPane.setConstraints(button[2][rep_rouge], y_rouge, i_rouge);
  660. grid_rouge.getChildren().add(button[2][rep_rouge]);
  661. button[2][rep_rouge].setId("bouton_null__");
  662. button[2][rep_rouge].setMinSize(40 * 0.9, 40 * 0.9);
  663. button[2][rep_rouge].setOnAction(this);
  664. rep_rouge++;
  665. }
  666. }
  667.  
  668. button[2][4].setId("bouton_rouge_");
  669.  
  670. //VERT
  671. for(int i_vert = 0; i_vert < 3; i_vert++) {
  672. for(int y_vert = 0; y_vert < 3; y_vert++) {
  673. GridPane.setConstraints(button[3][rep_vert], y_vert, i_vert);
  674. grid_vert.getChildren().add(button[3][rep_vert]);
  675. button[3][rep_vert].setId("bouton_null__");
  676. button[3][rep_vert].setMinSize(40 * 0.9, 40 * 0.9);
  677. button[3][rep_vert].setOnAction(this);
  678. rep_vert++;
  679. }
  680. }
  681.  
  682. button[3][4].setId("bouton_vert__");
  683.  
  684. //ORANGE
  685. for(int i_orange = 0; i_orange < 3; i_orange++) {
  686. for(int y_orange = 0; y_orange < 3; y_orange++) {
  687. GridPane.setConstraints(button[4][rep_orange], y_orange, i_orange);
  688. grid_orange.getChildren().add(button[4][rep_orange]);
  689. button[4][rep_orange].setId("bouton_null__");
  690. button[4][rep_orange].setMinSize(40 * 0.9, 40 * 0.9);
  691. button[4][rep_orange].setOnAction(this);
  692. rep_orange++;
  693. }
  694. }
  695.  
  696. button[4][4].setId("bouton_orange");
  697.  
  698. //BLANC
  699. for(int i_blanc = 0; i_blanc < 3; i_blanc++) {
  700. for(int y_blanc = 0; y_blanc < 3; y_blanc++) {
  701. GridPane.setConstraints(button[5][rep_blanc], y_blanc, i_blanc);
  702. grid_blanc.getChildren().add(button[5][rep_blanc]);
  703. button[5][rep_blanc].setId("bouton_null__");
  704. button[5][rep_blanc].setMinSize(40 * 0.9, 40 * 0.9);
  705. button[5][rep_blanc].setOnAction(this);
  706. rep_blanc++;
  707. }
  708. }
  709.  
  710. button[5][4].setId("bouton_blanc_");
  711.  
  712. text.setPromptText("Résolution ...");
  713. text.setMinSize(640 * 0.9, 400 * 0.9);
  714. text.setWrapText(true);
  715. text.setEditable(false);
  716.  
  717. text1.setPromptText("Entrer un mélange");
  718. text1.setMinWidth(640 * 0.9);
  719. text1.setOnAction(this);
  720.  
  721. text2.setPromptText("Entrez un melange converti");
  722. text2.setMinWidth(640 * 0.9);
  723. text2.setOnAction(this);
  724.  
  725. env_mel.setId("bouton");
  726. env_mel.setMinSize(190 * 0.9, 50 * 0.9);
  727. env_mel.setOnAction(this);
  728.  
  729. reset.setId("bouton");
  730. reset.setMinSize(190 * 0.9, 50 * 0.9);
  731. reset.setOnAction(this);
  732.  
  733. res.setId("bouton");
  734. res.setMinSize(190 * 0.9, 50 * 0.9);
  735. res.setOnAction(this);
  736.  
  737. mel.setId("bouton");
  738. mel.setMinSize(190 * 0.9, 50 * 0.9);
  739. mel.setOnAction(this);
  740.  
  741. test_mo.setId("bouton");
  742. test_mo.setMinSize(190 * 0.9, 50 * 0.9);
  743. test_mo.setOnAction(this);
  744.  
  745. grid_jaune.setVgap(3 * 0.9);
  746. grid_jaune.setHgap(3 * 0.9);
  747.  
  748. grid_bleu.setVgap(3 * 0.9);
  749. grid_bleu.setHgap(3 * 0.9);
  750.  
  751. grid_rouge.setVgap(3 * 0.9);
  752. grid_rouge.setHgap(3 * 0.9);
  753.  
  754. grid_vert.setVgap(3 * 0.9);
  755. grid_vert.setHgap(3 * 0.9);
  756.  
  757. grid_orange.setVgap(3 * 0.9);
  758. grid_orange.setHgap(3 * 0.9);
  759.  
  760. grid_blanc.setVgap(3 * 0.9);
  761. grid_blanc.setHgap(3 * 0.9);
  762.  
  763. hbox2.setSpacing(30);
  764. hbox2.getChildren().addAll(paint_jaune, paint_bleu, paint_rouge, paint_vert, paint_orange, paint_blanc);
  765. hbox2.setAlignment(Pos.CENTER);
  766.  
  767. paint_jaune.setMinSize(40 * 0.9, 40 * 0.9);
  768. paint_jaune.setId("paint_jaune_");
  769.  
  770. paint_bleu.setMinSize(40 * 0.9, 40 * 0.9);
  771. paint_bleu.setId("paint_bleu__");
  772.  
  773. paint_rouge.setMinSize(40 * 0.9, 40 * 0.9);
  774. paint_rouge.setId("paint_rouge_");
  775.  
  776. paint_vert.setMinSize(40 * 0.9, 40 * 0.9);
  777. paint_vert.setId("paint_vert__");
  778.  
  779. paint_orange.setMinSize(40 * 0.9, 40 * 0.9);
  780. paint_orange.setId("paint_orange");
  781.  
  782. paint_blanc.setMinSize(40 * 0.9, 40 * 0.9);
  783. paint_blanc.setId("paint_blanc_");
  784.  
  785. hbox.setSpacing(10 * 0.9);
  786. hbox.setAlignment(Pos.CENTER);
  787.  
  788. vbox3.getChildren().addAll(res);
  789. vbox3.setSpacing(10 * 0.9);
  790.  
  791. vbox4.getChildren().addAll(mel, test_mo);
  792. vbox4.setSpacing(10 * 0.9);
  793.  
  794. vbox5.getChildren().addAll(env_mel, reset);
  795. vbox5.setSpacing(10 * 0.9);
  796.  
  797. hbox1.getChildren().addAll(vbox3, vbox4, vbox5);
  798. hbox1.setSpacing(10 * 0.9);
  799. hbox1.setAlignment(Pos.CENTER);
  800.  
  801. vbox2.setSpacing(10 * 0.9);
  802. vbox2.getChildren().addAll(text, text1, text2, hbox2, hbox1);
  803. vbox2.setSpacing(15);
  804.  
  805. vbox.setSpacing(10 * 0.9);
  806. vbox.getChildren().addAll(grid_jaune, grid_bleu, grid_rouge, grid_vert, grid_orange, grid_blanc);
  807.  
  808. //Thread.sleep(10);
  809.  
  810. //camera.read(frame);
  811. //imgView.setImage(SwingFXUtils.toFXImage(Mat2BufferedImage(frame), null));
  812.  
  813. hbox.getChildren().addAll(vbox2, vbox);
  814. hbox.setPadding(new Insets(50));
  815.  
  816. Scene scene = new Scene(hbox, 800 * 0.9, 960 * 0.9);
  817.  
  818. windows.setMaximized(false);
  819.  
  820. windows.setScene(scene);
  821.  
  822. scene.getStylesheets().add(Main.class.getResource("application.css").toExternalForm());
  823.  
  824. windows.show();
  825. }
  826.  
  827. @Override
  828. public void handle(ActionEvent e) {
  829.  
  830. if(!(e.getSource().equals(button[0][4]) ||
  831. e.getSource().equals(button[1][4]) ||
  832. e.getSource().equals(button[2][4]) ||
  833. e.getSource().equals(button[3][4]) ||
  834. e.getSource().equals(button[4][4]) ||
  835. e.getSource().equals(button[5][4]) ||
  836. e.getSource().equals(res) ||
  837. e.getSource().equals(mel) ||
  838. e.getSource().equals(test_mo) ||
  839. e.getSource().equals(text1) ||
  840. e.getSource().equals(env_mel) ||
  841. e.getSource().equals(reset))) {
  842.  
  843. char charFirstPos = e.getSource().toString().charAt(45);
  844. char charSecondPos = e.getSource().toString().charAt(46);
  845.  
  846. int firstPos = Character.getNumericValue(charFirstPos);
  847. int secondPos = Character.getNumericValue(charSecondPos);
  848.  
  849. intButton[firstPos][secondPos]++;
  850.  
  851. Button buffer = button[firstPos][secondPos];
  852. int ibuffer = intButton[firstPos][secondPos];
  853.  
  854. if(ibuffer == 1) {
  855. buffer.setId("bouton_jaune_");
  856. }
  857.  
  858. else if(ibuffer == 2) {
  859. buffer.setId("bouton_bleu__");
  860. }
  861.  
  862. else if(ibuffer == 3) {
  863. buffer.setId("bouton_rouge_");
  864. }
  865.  
  866. else if(ibuffer == 4) {
  867. buffer.setId("bouton_vert__");
  868. }
  869.  
  870. else if(ibuffer == 5) {
  871. buffer.setId("bouton_orange");
  872. }
  873.  
  874. else if(ibuffer == 6) {
  875. buffer.setId("bouton_blanc_");
  876. }
  877.  
  878. else if(ibuffer == 7) {
  879. intButton[firstPos][secondPos] = 1;
  880. buffer.setId("bouton_jaune_");
  881. }
  882. }
  883.  
  884. else if(e.getSource().equals(reset)) {
  885.  
  886. resetCube();
  887. }
  888.  
  889. else if(e.getSource().equals(text1)) {
  890.  
  891. String melange = text1.getText();
  892. System.out.println(melange);
  893.  
  894. melange_env = melange_env + convert1(melange);
  895.  
  896. text.appendText(melange + "\n");
  897.  
  898. text1.clear();
  899. applyScramble(melange);
  900. }
  901.  
  902. else if(e.getSource().equals(env_mel)) {
  903.  
  904. SerialPort[] computerPorts = SerialPort.getCommPorts();
  905.  
  906. SerialPort selectedPort = null;
  907.  
  908. for (SerialPort p : computerPorts) {
  909. if (p.getSystemPortName().equals("COM3")) {
  910. selectedPort = p;
  911. }
  912. }
  913.  
  914. if (selectedPort == null) {
  915. return;
  916. }
  917.  
  918. else if (selectedPort.openPort()) {
  919. System.out.println(selectedPort.getSystemPortName() + " s'est ouvert correctement");
  920. }
  921.  
  922. else {
  923. System.out.println(selectedPort.getSystemPortName() + " n'a pas réussi à s'ouvrir");
  924. return;
  925. }
  926.  
  927. pw = new PrintWriter(selectedPort.getOutputStream());
  928. try {
  929. Thread.sleep(3000);
  930. } catch (InterruptedException e2) {
  931. e2.printStackTrace();
  932. }
  933.  
  934. for(int i = 0; i < melange_env.length(); i++) {
  935.  
  936. pw.write(melange_env.charAt(i));
  937. pw.flush();
  938. try {
  939. Thread.sleep(1);
  940. } catch (InterruptedException e1) {
  941. e1.printStackTrace();
  942. }
  943.  
  944. }
  945. pw.write('/');
  946. pw.flush();
  947.  
  948.  
  949. selectedPort.closePort();
  950. }
  951.  
  952. /*
  953. * BOUTON CAMERA
  954. */
  955.  
  956. /*else if(e.getSource().equals(det)) {
  957.  
  958. detectColor = 1 - detectColor;
  959.  
  960. if(detectColor == 1) {
  961. det.setText("Eteindre detec");
  962. }
  963.  
  964. else {
  965. det.setText("Demarrer detec");
  966. }
  967.  
  968. }*/
  969.  
  970. else if(e.getSource().equals(mel)) {
  971.  
  972. resetTableau();
  973.  
  974. String melange = generateScramble3x3();
  975.  
  976. melange_env = convert1(melange);
  977.  
  978. text.appendText(melange + "\n");
  979.  
  980. applyScramble(melange);
  981. }
  982.  
  983. else if(e.getSource().equals(test_mo)) {
  984.  
  985. SerialPort[] computerPorts = SerialPort.getCommPorts();
  986.  
  987. SerialPort selectedPort = null;
  988.  
  989. for (SerialPort p : computerPorts) {
  990. if (p.getSystemPortName().equals("COM3")) {
  991. selectedPort = p;
  992. }
  993. }
  994.  
  995. if (selectedPort == null) {
  996. return;
  997. }
  998.  
  999. else if (selectedPort.openPort()) {
  1000. System.out.println(selectedPort.getSystemPortName() + " s'est ouvert correctement");
  1001. }
  1002.  
  1003. else {
  1004. System.out.println(selectedPort.getSystemPortName() + " n'a pas réussi à s'ouvrir");
  1005. return;
  1006. }
  1007.  
  1008. pw = new PrintWriter(selectedPort.getOutputStream());
  1009. try {
  1010. Thread.sleep(3000);
  1011. } catch (InterruptedException e2) {
  1012. e2.printStackTrace();
  1013. }
  1014.  
  1015. String string_test = new String("R/");
  1016.  
  1017. for(int test_int = 0; test_int < string_test.length(); test_int++) {
  1018.  
  1019. pw.write(string_test.charAt(test_int));
  1020. pw.flush();
  1021. try {
  1022. Thread.sleep(1);
  1023. } catch (InterruptedException e1) {
  1024. e1.printStackTrace();
  1025. }
  1026. }
  1027.  
  1028. selectedPort.closePort();
  1029.  
  1030. }
  1031.  
  1032. /*
  1033. * BOUTON RESOLUTION
  1034. */
  1035.  
  1036. else if(e.getSource().equals(res)){
  1037.  
  1038. int icubel = 0;
  1039. int icubeh = 0;
  1040.  
  1041. for(int face = 0; face < 6; face++) {
  1042.  
  1043. CouleurEnum[][] couleurBuffer = new CouleurEnum[3][3];
  1044.  
  1045. for(int cubel = 0; cubel < 3; cubel++) {
  1046. for(int cubeh = 0; cubeh < 3; cubeh++) {
  1047.  
  1048. if(button[icubel][icubeh].toString().charAt(17) == 'j' && button[icubel][icubeh].toString().charAt(18) == 'a') {
  1049.  
  1050. couleurBuffer[cubel][cubeh] = CouleurEnum.JAUNE;
  1051. }
  1052.  
  1053. else if(button[icubel][icubeh].toString().charAt(17) == 'b' && button[icubel][icubeh].toString().charAt(19) == 'e') {
  1054.  
  1055. couleurBuffer[cubel][cubeh] = CouleurEnum.BLEU;
  1056. }
  1057.  
  1058. else if(button[icubel][icubeh].toString().charAt(17) == 'r' && button[icubel][icubeh].toString().charAt(18) == 'o') {
  1059.  
  1060. couleurBuffer[cubel][cubeh] = CouleurEnum.ROUGE;
  1061. }
  1062.  
  1063. else if(button[icubel][icubeh].toString().charAt(17) == 'v' && button[icubel][icubeh].toString().charAt(18) == 'e') {
  1064.  
  1065. couleurBuffer[cubel][cubeh] = CouleurEnum.VERT;
  1066. }
  1067.  
  1068. else if(button[icubel][icubeh].toString().charAt(17) == 'o' && button[icubel][icubeh].toString().charAt(18) == 'r') {
  1069.  
  1070. couleurBuffer[cubel][cubeh] = CouleurEnum.ORANGE;
  1071. }
  1072.  
  1073. else if(button[icubel][icubeh].toString().charAt(17) == 'b' && button[icubel][icubeh].toString().charAt(19) == 'a') {
  1074.  
  1075. couleurBuffer[cubel][cubeh] = CouleurEnum.BLANC;
  1076. }
  1077.  
  1078. icubeh++;
  1079. }
  1080. }
  1081. icubeh = 0;
  1082. icubel++;
  1083.  
  1084. if(face == 0) {
  1085.  
  1086. FaceJaune = couleurBuffer;
  1087. }
  1088.  
  1089. else if(face == 1) {
  1090.  
  1091. FaceBleu = couleurBuffer;
  1092. }
  1093.  
  1094. else if(face == 2) {
  1095.  
  1096. FaceRouge = couleurBuffer;
  1097. }
  1098.  
  1099. else if(face == 3) {
  1100.  
  1101. FaceVert = couleurBuffer;
  1102. }
  1103.  
  1104. else if(face == 4) {
  1105.  
  1106. FaceOrange = couleurBuffer;
  1107. }
  1108.  
  1109. else if(face == 5) {
  1110.  
  1111. FaceBlanc = couleurBuffer;
  1112. }
  1113. }
  1114.  
  1115. bufferJaune = FaceJaune;
  1116. bufferBleu = FaceBleu;
  1117. bufferRouge = FaceRouge;
  1118. bufferVert = FaceVert;
  1119. bufferOrange = FaceOrange;
  1120. bufferBlanc = FaceBlanc;
  1121.  
  1122. int face_rot = 0;
  1123. int mul_face_rot = 0;
  1124.  
  1125. for(int i = 0; i < 289; i++) {
  1126.  
  1127. if(i > 0) {
  1128.  
  1129. FaceJaune = bufferJaune;
  1130. FaceBleu = bufferBleu;
  1131. FaceRouge = bufferRouge;
  1132. FaceVert = bufferVert;
  1133. FaceOrange = bufferOrange;
  1134. FaceBlanc = bufferBlanc;
  1135.  
  1136. for(int x = 1; x > -1; x--) {
  1137.  
  1138. char c = 0;
  1139.  
  1140. try {
  1141. c = optiMov.charAt(x);
  1142. } catch(Exception e2) {
  1143.  
  1144. }
  1145.  
  1146. if(c == 'R') {
  1147. RPMove();
  1148. }
  1149.  
  1150. else if(c == 'S') {
  1151. RMove();
  1152. }
  1153.  
  1154. else if(c == 'T') {
  1155. R2Move();
  1156. }
  1157.  
  1158. else if(c == 'F') {
  1159. FPMove();
  1160. }
  1161.  
  1162. else if(c == 'G') {
  1163. FMove();
  1164. }
  1165.  
  1166. else if(c == 'H') {
  1167. F2Move();
  1168. }
  1169.  
  1170. else if(c == 'L') {
  1171. LPMove();
  1172. }
  1173.  
  1174. else if(c == 'M') {
  1175. LMove();
  1176. }
  1177.  
  1178. else if(c == 'N') {
  1179. L2Move();
  1180. }
  1181.  
  1182. else if(c == 'U') {
  1183. UPMove();
  1184. }
  1185.  
  1186. else if(c == 'V') {
  1187. UMove();
  1188. }
  1189.  
  1190. else if(c == 'W') {
  1191. U2Move();
  1192. }
  1193.  
  1194. else if(c == 'B') {
  1195. BPMove();
  1196. }
  1197.  
  1198. else if(c == 'C') {
  1199. BMove();
  1200. }
  1201.  
  1202. else if(c == 'A') {
  1203. B2Move();
  1204. }
  1205.  
  1206. else if(c == 'D') {
  1207. DPMove();
  1208. }
  1209.  
  1210. else if(c == 'E') {
  1211. DMove();
  1212. }
  1213.  
  1214. else if(c == 'Z') {
  1215. D2Move();
  1216. }
  1217. }
  1218.  
  1219. optiMov = "";
  1220.  
  1221. if(mul_face_rot == 19) {
  1222. mul_face_rot = 0;
  1223. face_rot++;
  1224. }
  1225.  
  1226. if(face_rot == 0){
  1227.  
  1228. RMove();
  1229. optiMov = optiMov + "R";
  1230. }
  1231.  
  1232. else if(face_rot == 1){
  1233.  
  1234. RPMove();
  1235. optiMov = optiMov + "S";
  1236. }
  1237.  
  1238. else if(face_rot == 2){
  1239.  
  1240. R2Move();
  1241. optiMov = optiMov + "T";
  1242. }
  1243.  
  1244. else if(face_rot == 3){
  1245.  
  1246. FMove();
  1247. optiMov = optiMov + "F";
  1248. }
  1249.  
  1250. else if(face_rot == 4){
  1251.  
  1252. FPMove();
  1253. optiMov = optiMov + "G";
  1254. }
  1255.  
  1256. else if(face_rot == 5){
  1257.  
  1258. F2Move();
  1259. optiMov = optiMov + "H";
  1260. }
  1261.  
  1262. else if(face_rot == 6){
  1263.  
  1264. LMove();
  1265. optiMov = optiMov + "L";
  1266. }
  1267.  
  1268. else if(face_rot == 7){
  1269.  
  1270. LPMove();
  1271. optiMov = optiMov + "M";
  1272. }
  1273.  
  1274. else if(face_rot == 8){
  1275.  
  1276. L2Move();
  1277. optiMov = optiMov + "N";
  1278. }
  1279.  
  1280. else if(face_rot == 9){
  1281.  
  1282. UMove();
  1283. optiMov = optiMov + "U";
  1284. }
  1285.  
  1286. else if(face_rot == 10){
  1287.  
  1288. UPMove();
  1289. optiMov = optiMov + "V";
  1290. }
  1291.  
  1292. else if(face_rot == 11){
  1293.  
  1294. U2Move();
  1295. optiMov = optiMov + "W";
  1296. }
  1297.  
  1298. else if(face_rot == 12){
  1299.  
  1300. BMove();
  1301. optiMov = optiMov + "B";
  1302. }
  1303.  
  1304. else if(face_rot == 13){
  1305.  
  1306. BPMove();
  1307. optiMov = optiMov + "C";
  1308. }
  1309.  
  1310. else if(face_rot == 14){
  1311.  
  1312. B2Move();
  1313. optiMov = optiMov + "A";
  1314. }
  1315.  
  1316. else if(face_rot == 15){
  1317.  
  1318. DMove();
  1319. optiMov = optiMov + "D";
  1320. }
  1321.  
  1322. else if(face_rot == 16){
  1323.  
  1324. DPMove();
  1325. optiMov = optiMov + "E";
  1326. }
  1327.  
  1328. else if(face_rot == 17){
  1329.  
  1330. D2Move();
  1331. optiMov = optiMov + "Z";
  1332. }
  1333.  
  1334. if(face_rot >= 0 && face_rot <= 2 && mul_face_rot >= 0 && mul_face_rot <= 2) {
  1335. mul_face_rot = 3;
  1336. }
  1337.  
  1338. if(face_rot >= 3 && face_rot <= 5 && mul_face_rot >= 3 && mul_face_rot <= 5) {
  1339. mul_face_rot = 6;
  1340. }
  1341.  
  1342. if(face_rot >= 6 && face_rot <= 8 && mul_face_rot >= 6 && mul_face_rot <= 8) {
  1343. mul_face_rot = 9;
  1344. }
  1345.  
  1346. if(face_rot >= 9 && face_rot <= 11 && mul_face_rot >= 9 && mul_face_rot <= 11) {
  1347. mul_face_rot = 12;
  1348. }
  1349.  
  1350. if(face_rot >= 12 && face_rot <= 14 && mul_face_rot >= 12 && mul_face_rot <= 14) {
  1351. mul_face_rot = 15;
  1352. }
  1353.  
  1354. if(face_rot >= 15 && face_rot <= 17 && mul_face_rot >= 15 && mul_face_rot <= 17) {
  1355. mul_face_rot = 18;
  1356. }
  1357.  
  1358.  
  1359. if(mul_face_rot == 0){
  1360.  
  1361. RMove();
  1362. optiMov = optiMov + "R";
  1363. }
  1364.  
  1365. else if(mul_face_rot == 1) {
  1366.  
  1367. RPMove();
  1368. optiMov = optiMov + "S";
  1369. }
  1370.  
  1371. else if(mul_face_rot == 2) {
  1372.  
  1373. R2Move();
  1374. optiMov = optiMov + "T";
  1375. }
  1376.  
  1377. else if(mul_face_rot == 3) {
  1378.  
  1379. FMove();
  1380. optiMov = optiMov + "F";
  1381. }
  1382.  
  1383. else if(mul_face_rot == 4) {
  1384.  
  1385. FPMove();
  1386. optiMov = optiMov + "G";
  1387. }
  1388.  
  1389. else if(mul_face_rot == 5) {
  1390.  
  1391. F2Move();
  1392. optiMov = optiMov + "H";
  1393. }
  1394.  
  1395. else if(mul_face_rot == 6) {
  1396.  
  1397. LMove();
  1398. optiMov = optiMov + "L";
  1399. }
  1400.  
  1401. else if(mul_face_rot == 7) {
  1402.  
  1403. LPMove();
  1404. optiMov = optiMov + "M";
  1405. }
  1406.  
  1407. else if(mul_face_rot == 8) {
  1408.  
  1409. L2Move();
  1410. optiMov = optiMov + "N";
  1411. }
  1412.  
  1413. else if(mul_face_rot == 9) {
  1414.  
  1415. UMove();
  1416. optiMov = optiMov + "U";
  1417. }
  1418.  
  1419. else if(mul_face_rot == 10) {
  1420.  
  1421. UPMove();
  1422. optiMov = optiMov + "V";
  1423. }
  1424.  
  1425. else if(mul_face_rot == 11) {
  1426.  
  1427. U2Move();
  1428. optiMov = optiMov + "W";
  1429. }
  1430.  
  1431. else if(mul_face_rot == 12) {
  1432.  
  1433. BMove();
  1434. optiMov = optiMov + "B";
  1435. }
  1436.  
  1437. else if(mul_face_rot == 13) {
  1438.  
  1439. BPMove();
  1440. optiMov = optiMov + "C";
  1441. }
  1442.  
  1443. else if(mul_face_rot == 14) {
  1444.  
  1445. B2Move();
  1446. optiMov = optiMov + "A";
  1447. }
  1448.  
  1449. else if(mul_face_rot == 15) {
  1450.  
  1451. DMove();
  1452. optiMov = optiMov + "D";
  1453. }
  1454.  
  1455. else if(mul_face_rot == 16) {
  1456.  
  1457. DPMove();
  1458. optiMov = optiMov + "E";
  1459. }
  1460.  
  1461. else if(mul_face_rot == 17) {
  1462.  
  1463. D2Move();
  1464. optiMov = optiMov + "Z";
  1465. }
  1466.  
  1467. mul_face_rot++;
  1468. }
  1469.  
  1470. /*
  1471. * SUITE DECLARATION COINS
  1472. */
  1473.  
  1474. JVO.setCouleur(i1, FaceJaune[0][0]);
  1475. JVO.setCouleur(i2, FaceVert[0][2]);
  1476. JVO.setCouleur(i3, FaceOrange[0][0]);
  1477. JRV.setCouleur(i1, FaceJaune[0][2]);
  1478. JRV.setCouleur(i2, FaceRouge[0][2]);
  1479. JRV.setCouleur(i3, FaceVert[0][0]);
  1480. JBR.setCouleur(i1, FaceJaune[2][2]);
  1481. JBR.setCouleur(i2, FaceBleu[0][2]);
  1482. JBR.setCouleur(i3, FaceRouge[0][0]);
  1483. JBO.setCouleur(i1, FaceJaune[2][0]);
  1484. JBO.setCouleur(i2, FaceBleu[0][0]);
  1485. JBO.setCouleur(i3, FaceOrange[0][2]);
  1486. BOBl.setCouleur(i1, FaceBleu[2][0]);
  1487. BOBl.setCouleur(i2, FaceOrange[2][2]);
  1488. BOBl.setCouleur(i3, FaceBlanc[0][0]);
  1489. BRBl.setCouleur(i1, FaceBleu[2][2]);
  1490. BRBl.setCouleur(i2, FaceRouge[2][0]);
  1491. BRBl.setCouleur(i3, FaceBlanc[0][2]);
  1492. RVBl.setCouleur(i1, FaceRouge[2][2]);
  1493. RVBl.setCouleur(i2, FaceVert[2][0]);
  1494. RVBl.setCouleur(i3, FaceBlanc[2][2]);
  1495. VOBl.setCouleur(i1, FaceVert[2][2]);
  1496. VOBl.setCouleur(i2, FaceOrange[2][0]);
  1497. VOBl.setCouleur(i3, FaceBlanc[2][0]);
  1498.  
  1499. /*
  1500. * SUITE DECLARATION ARETES
  1501. */
  1502.  
  1503. JV.setCouleur(i1, FaceJaune[0][1]);
  1504. JV.setCouleur(i2, FaceVert[0][1]);
  1505. JR.setCouleur(i1, FaceJaune[1][2]);
  1506. JR.setCouleur(i2, FaceRouge[0][1]);
  1507. JB.setCouleur(i1, FaceJaune[2][1]);
  1508. JB.setCouleur(i2, FaceBleu[0][1]);
  1509. JO.setCouleur(i1, FaceJaune[1][0]);
  1510. JO.setCouleur(i2, FaceOrange[0][1]);
  1511. VO.setCouleur(i1, FaceVert[1][2]);
  1512. VO.setCouleur(i2, FaceOrange[1][0]);
  1513. RV.setCouleur(i1, FaceRouge[1][2]);
  1514. RV.setCouleur(i2, FaceVert[1][0]);
  1515. BR.setCouleur(i1, FaceBleu[1][2]);
  1516. BR.setCouleur(i2, FaceRouge[1][0]);
  1517. BO.setCouleur(i1, FaceBleu[1][0]);
  1518. BO.setCouleur(i2, FaceOrange[1][2]);
  1519. BBl.setCouleur(i1, FaceBleu[2][1]);
  1520. BBl.setCouleur(i2, FaceBlanc[0][1]);
  1521. RBl.setCouleur(i1, FaceRouge[2][1]);
  1522. RBl.setCouleur(i2, FaceBlanc[1][2]);
  1523. VBl.setCouleur(i1, FaceVert[2][1]);
  1524. VBl.setCouleur(i2, FaceBlanc[2][1]);
  1525. OBl.setCouleur(i1, FaceOrange[2][1]);
  1526. OBl.setCouleur(i2, FaceBlanc[1][0]);
  1527.  
  1528. /*
  1529. *
  1530. * COINS
  1531. *
  1532. */
  1533.  
  1534. Coin Buffer = new Coin();
  1535.  
  1536. /*
  1537. * DETECTION DES COINS DEJA BIEN PLACES
  1538. */
  1539.  
  1540. if(JRV.contient(CouleurEnum.JAUNE, CouleurEnum.ROUGE, CouleurEnum.VERT)) {
  1541.  
  1542. if(!(JRV.getCouleur(i1) == CouleurEnum.JAUNE && JRV.getCouleur(i2) == CouleurEnum.ROUGE && JRV.getCouleur(i3) == CouleurEnum.VERT)) {
  1543.  
  1544. CoinOri.add("JRV");
  1545. Coin[0] = "";
  1546. }
  1547.  
  1548. else {
  1549. Coin[0] = "";
  1550.  
  1551. }
  1552. }
  1553.  
  1554. if(JBR.contient(CouleurEnum.JAUNE, CouleurEnum.BLEU, CouleurEnum.ROUGE)) {
  1555.  
  1556. if(!(JBR.getCouleur(i1) == CouleurEnum.JAUNE && JBR.getCouleur(i2) == CouleurEnum.BLEU && JBR.getCouleur(i3) == CouleurEnum.ROUGE)) {
  1557.  
  1558. CoinOri.add("JBR");
  1559. Coin[1] = "";
  1560. }
  1561.  
  1562. else {
  1563. Coin[1] = "";
  1564.  
  1565. }
  1566. }
  1567.  
  1568. if(JBO.contient(CouleurEnum.JAUNE, CouleurEnum.BLEU, CouleurEnum.ORANGE)) {
  1569.  
  1570. if(!(JBO.getCouleur(i1) == CouleurEnum.JAUNE && JBO.getCouleur(i2) == CouleurEnum.BLEU && JBO.getCouleur(i3) == CouleurEnum.ORANGE)) {
  1571.  
  1572. CoinOri.add("JBO");
  1573. Coin[2] = "";
  1574. }
  1575.  
  1576. else {
  1577.  
  1578. Coin[2] = "";
  1579. }
  1580. }
  1581.  
  1582. if(BOBl.contient(CouleurEnum.BLEU, CouleurEnum.ORANGE, CouleurEnum.BLANC)) {
  1583.  
  1584. if(!(BOBl.getCouleur(i1) == CouleurEnum.BLEU && BOBl.getCouleur(i2) == CouleurEnum.ORANGE && BOBl.getCouleur(i3) == CouleurEnum.BLANC)) {
  1585.  
  1586. CoinOri.add("BOBl");
  1587. Coin[3] = "";
  1588. }
  1589.  
  1590. else {
  1591.  
  1592. Coin[3] = "";
  1593. }
  1594. }
  1595.  
  1596. if(BRBl.contient(CouleurEnum.BLEU, CouleurEnum.ROUGE, CouleurEnum.BLANC)) {
  1597.  
  1598. if(!(BRBl.getCouleur(i1) == CouleurEnum.BLEU && BRBl.getCouleur(i2) == CouleurEnum.ROUGE && BRBl.getCouleur(i3) == CouleurEnum.BLANC)) {
  1599.  
  1600. CoinOri.add("BRBl");
  1601. Coin[4] = "";
  1602. }
  1603.  
  1604. else {
  1605.  
  1606. Coin[4] = "";
  1607. }
  1608. }
  1609.  
  1610. if(RVBl.contient(CouleurEnum.ROUGE, CouleurEnum.VERT, CouleurEnum.BLANC)) {
  1611.  
  1612. if(!(RVBl.getCouleur(i1) == CouleurEnum.ROUGE && RVBl.getCouleur(i2) == CouleurEnum.VERT && RVBl.getCouleur(i3) == CouleurEnum.BLANC)) {
  1613.  
  1614. CoinOri.add("RVBl");
  1615. Coin[5] = "";
  1616. }
  1617.  
  1618. else {
  1619.  
  1620. Coin[5] = "";
  1621. }
  1622. }
  1623.  
  1624. if(VOBl.contient(CouleurEnum.VERT, CouleurEnum.ORANGE, CouleurEnum.BLANC)) {
  1625.  
  1626. if(!(VOBl.getCouleur(i1) == CouleurEnum.VERT && VOBl.getCouleur(i2) == CouleurEnum.ORANGE && VOBl.getCouleur(i3) == CouleurEnum.BLANC)) {
  1627.  
  1628. CoinOri.add("VOBl");
  1629. Coin[6] = "";
  1630. }
  1631.  
  1632. else {
  1633.  
  1634. Coin[6] = "";
  1635. }
  1636. }
  1637.  
  1638. /*
  1639. * WHILE POUR LES COINS MAL PLACES
  1640. */
  1641.  
  1642. while(!(Coin[0] == "" && Coin[1] == "" && Coin[2] == "" && Coin[3] == "" && Coin[4] == "" && Coin[5] == "" && Coin[6] == "")) {
  1643.  
  1644. /*
  1645. * CHOIX PREMIERE FACE A CHECK
  1646. */
  1647.  
  1648. if(prochaineCouleur == "JAUNE") {
  1649. Buffer.setCouleur(i1, FaceJaune[prochainX][prochainY]);
  1650. TabRef = FaceJaune;
  1651. }
  1652.  
  1653.  
  1654. else if(prochaineCouleur == "BLEU") {
  1655. Buffer.setCouleur(i1, FaceBleu[prochainX][prochainY]);
  1656. TabRef = FaceBleu;
  1657. }
  1658.  
  1659.  
  1660. else if(prochaineCouleur == "ROUGE") {
  1661. Buffer.setCouleur(i1, FaceRouge[prochainX][prochainY]);
  1662. TabRef = FaceRouge;
  1663. }
  1664.  
  1665.  
  1666. else if(prochaineCouleur == "VERT") {
  1667. Buffer.setCouleur(i1, FaceVert[prochainX][prochainY]);
  1668. TabRef = FaceVert;
  1669. }
  1670.  
  1671.  
  1672. else if(prochaineCouleur == "ORANGE") {
  1673. Buffer.setCouleur(i1, FaceOrange[prochainX][prochainY]);
  1674. TabRef = FaceOrange;
  1675. }
  1676.  
  1677. else if(prochaineCouleur == "BLANC") {
  1678. Buffer.setCouleur(i1, FaceBlanc[prochainX][prochainY]);
  1679. TabRef = FaceBlanc;
  1680. }
  1681.  
  1682. /*
  1683. * CHOIX DEUXIEME FACE A CHECK
  1684. */
  1685.  
  1686. if(prochaineCouleur2 == "JAUNE") {
  1687. Buffer.setCouleur(i2, FaceJaune[prochainX2][prochainY2]);
  1688. }
  1689.  
  1690.  
  1691. else if(prochaineCouleur2 == "BLEU") {
  1692. Buffer.setCouleur(i2, FaceBleu[prochainX2][prochainY2]);
  1693. }
  1694.  
  1695.  
  1696. else if(prochaineCouleur2 == "ROUGE") {
  1697. Buffer.setCouleur(i2, FaceRouge[prochainX2][prochainY2]);
  1698. }
  1699.  
  1700.  
  1701. else if(prochaineCouleur2 == "VERT") {
  1702. Buffer.setCouleur(i2, FaceVert[prochainX2][prochainY2]);
  1703. }
  1704.  
  1705.  
  1706. else if(prochaineCouleur2 == "ORANGE") {
  1707. Buffer.setCouleur(i2, FaceOrange[prochainX2][prochainY2]);
  1708. }
  1709.  
  1710. else if(prochaineCouleur2 == "BLANC") {
  1711. Buffer.setCouleur(i2, FaceBlanc[prochainX2][prochainY2]);
  1712. }
  1713.  
  1714. /*
  1715. * CHOIX TROISIEME FACE A CHECK
  1716. */
  1717.  
  1718. if(prochaineCouleur3 == "JAUNE") {
  1719. Buffer.setCouleur(i3, FaceJaune[prochainX3][prochainY3]);
  1720. }
  1721.  
  1722. else if(prochaineCouleur3 == "BLEU") {
  1723. Buffer.setCouleur(i3, FaceBleu[prochainX3][prochainY3]);
  1724. }
  1725.  
  1726. else if(prochaineCouleur3 == "ROUGE") {
  1727. Buffer.setCouleur(i3, FaceRouge[prochainX3][prochainY3]);
  1728. }
  1729.  
  1730. else if(prochaineCouleur3 == "VERT") {
  1731. Buffer.setCouleur(i3, FaceVert[prochainX3][prochainY3]);
  1732. }
  1733.  
  1734. else if(prochaineCouleur3 == "ORANGE") {
  1735. Buffer.setCouleur(i3, FaceOrange[prochainX3][prochainY3]);
  1736. }
  1737.  
  1738. else if(prochaineCouleur3 == "BLANC") {
  1739. Buffer.setCouleur(i3, FaceBlanc[prochainX3][prochainY3]);
  1740. }
  1741.  
  1742. /*
  1743. * CAS DU COIN JRV
  1744. */
  1745.  
  1746. if(Buffer.contient(CouleurEnum.JAUNE, CouleurEnum.ROUGE, CouleurEnum.VERT)) {
  1747.  
  1748. //System.out.println("JRV");
  1749.  
  1750. if(Coin[0] == "") {
  1751. BooJVO = true;
  1752. }
  1753.  
  1754. else if(TabRef[prochainX][prochainY] == CouleurEnum.JAUNE) {
  1755.  
  1756. Resolution = Resolution + JRVJ;
  1757. //System.out.println(JRVJ);
  1758. string_solv.add("JRVJ");
  1759. string_solv.add(JRVJ);
  1760. prochainX = Character.getNumericValue(JRVJP.charAt(0));
  1761. prochainY = Character.getNumericValue(JRVJP.charAt(1));
  1762. prochainX2 = Character.getNumericValue(JRVRP.charAt(0));
  1763. prochainY2 = Character.getNumericValue(JRVRP.charAt(1));
  1764. prochainX3 = Character.getNumericValue(JRVVP.charAt(0));
  1765. prochainY3 = Character.getNumericValue(JRVVP.charAt(1));
  1766.  
  1767. prochaineCouleur = "JAUNE";
  1768. prochaineCouleur2 = "ROUGE";
  1769. prochaineCouleur3 = "VERT";
  1770. Coin[0] = "";
  1771. paireimpaire++;
  1772.  
  1773. }
  1774.  
  1775. else if(TabRef[prochainX][prochainY] == CouleurEnum.ROUGE) {
  1776.  
  1777. Resolution = Resolution + JRVR;
  1778. //System.out.println(JRVR);
  1779. string_solv.add("JRVR");
  1780. string_solv.add(JRVR);
  1781. prochainX = Character.getNumericValue(JRVRP.charAt(0));
  1782. prochainY = Character.getNumericValue(JRVRP.charAt(1));
  1783. prochainX2 = Character.getNumericValue(JRVJP.charAt(0));
  1784. prochainY2 = Character.getNumericValue(JRVJP.charAt(1));
  1785. prochainX3 = Character.getNumericValue(JRVVP.charAt(0));
  1786. prochainY3 = Character.getNumericValue(JRVVP.charAt(1));
  1787.  
  1788. prochaineCouleur = "ROUGE";
  1789. prochaineCouleur2 = "JAUNE";
  1790. prochaineCouleur3 = "VERT";
  1791.  
  1792. Coin[0] = "";
  1793. paireimpaire++;
  1794.  
  1795. }
  1796.  
  1797. else if(TabRef[prochainX][prochainY] == CouleurEnum.VERT) {
  1798.  
  1799. Resolution = Resolution + JRVV;
  1800. //System.out.println(JRVV);
  1801. string_solv.add("JRVV");
  1802. string_solv.add(JRVV);
  1803. prochainX = Character.getNumericValue(JRVVP.charAt(0));
  1804. prochainY = Character.getNumericValue(JRVVP.charAt(1));
  1805. prochainX2 = Character.getNumericValue(JRVJP.charAt(0));
  1806. prochainY2 = Character.getNumericValue(JRVJP.charAt(1));
  1807. prochainX3 = Character.getNumericValue(JRVRP.charAt(0));
  1808. prochainY3 = Character.getNumericValue(JRVRP.charAt(1));
  1809.  
  1810. prochaineCouleur = "VERT";
  1811. prochaineCouleur2 = "JAUNE";
  1812. prochaineCouleur3 = "ROUGE";
  1813.  
  1814. Coin[0] = "";
  1815. paireimpaire++;
  1816.  
  1817. }
  1818. }
  1819.  
  1820. /*
  1821. * CAS DU COIN JBR
  1822. */
  1823.  
  1824. else if(Buffer.contient(CouleurEnum.JAUNE, CouleurEnum.BLEU, CouleurEnum.ROUGE)) {
  1825.  
  1826. //System.out.println("JBR");
  1827. if(Coin[1] == "") {
  1828. BooJVO = true;
  1829. }
  1830.  
  1831. else if(TabRef[prochainX][prochainY] == CouleurEnum.JAUNE) {
  1832.  
  1833. Resolution = Resolution + JBRJ;
  1834. //System.out.println(JBRJ);
  1835. string_solv.add("JBRJ");
  1836. string_solv.add(JBRJ);
  1837. prochainX = Character.getNumericValue(JBRJP.charAt(0));
  1838. prochainY = Character.getNumericValue(JBRJP.charAt(1));
  1839. prochainX2 = Character.getNumericValue(JBRBP.charAt(0));
  1840. prochainY2 = Character.getNumericValue(JBRBP.charAt(1));
  1841. prochainX3 = Character.getNumericValue(JBRRP.charAt(0));
  1842. prochainY3 = Character.getNumericValue(JBRRP.charAt(1));
  1843.  
  1844. prochaineCouleur = "JAUNE";
  1845. prochaineCouleur2 = "BLEU";
  1846. prochaineCouleur3 = "ROUGE";
  1847. Coin[1] = "";
  1848. paireimpaire++;
  1849.  
  1850. }
  1851.  
  1852. else if(TabRef[prochainX][prochainY] == CouleurEnum.BLEU) {
  1853.  
  1854. Resolution = Resolution + JBRB;
  1855. //System.out.println(JBRB);
  1856. string_solv.add("JBRB");
  1857. string_solv.add(JBRB);
  1858. prochainX = Character.getNumericValue(JBRBP.charAt(0));
  1859. prochainY = Character.getNumericValue(JBRBP.charAt(1));
  1860. prochainX2 = Character.getNumericValue(JBRJP.charAt(0));
  1861. prochainY2 = Character.getNumericValue(JBRJP.charAt(1));
  1862. prochainX3 = Character.getNumericValue(JBRRP.charAt(0));
  1863. prochainY3 = Character.getNumericValue(JBRRP.charAt(1));
  1864.  
  1865. prochaineCouleur = "BLEU";
  1866. prochaineCouleur2 = "JAUNE";
  1867. prochaineCouleur3 = "ROUGE";
  1868.  
  1869. Coin[1] = "";
  1870. paireimpaire++;
  1871.  
  1872. }
  1873.  
  1874. else if(TabRef[prochainX][prochainY] == CouleurEnum.ROUGE) {
  1875.  
  1876. Resolution = Resolution + JBRR;
  1877. //System.out.println(JBRR);
  1878. string_solv.add("JBRR");
  1879. string_solv.add(JBRR);
  1880. prochainX = Character.getNumericValue(JBRRP.charAt(0));
  1881. prochainY = Character.getNumericValue(JBRRP.charAt(1));
  1882. prochainX2 = Character.getNumericValue(JBRJP.charAt(0));
  1883. prochainY2 = Character.getNumericValue(JBRJP.charAt(1));
  1884. prochainX3 = Character.getNumericValue(JBRBP.charAt(0));
  1885. prochainY3 = Character.getNumericValue(JBRBP.charAt(1));
  1886.  
  1887. prochaineCouleur = "ROUGE";
  1888. prochaineCouleur2 = "JAUNE";
  1889. prochaineCouleur3 = "BLEU";
  1890.  
  1891. Coin[1] = "";
  1892. paireimpaire++;
  1893.  
  1894. }
  1895. }
  1896.  
  1897. /*
  1898. * CAS DU COIN JBO
  1899. */
  1900.  
  1901. else if(Buffer.contient(CouleurEnum.JAUNE, CouleurEnum.BLEU, CouleurEnum.ORANGE)) {
  1902.  
  1903. //System.out.println("JBO");
  1904. if(Coin[2] == "") {
  1905. BooJVO = true;
  1906. }
  1907.  
  1908. else if(TabRef[prochainX][prochainY] == CouleurEnum.JAUNE) {
  1909.  
  1910. Resolution = Resolution + JBOJ;
  1911. //System.out.println(JBOJ);
  1912. string_solv.add("JBOJ");
  1913. string_solv.add(JBOJ);
  1914. prochainX = Character.getNumericValue(JBOJP.charAt(0));
  1915. prochainY = Character.getNumericValue(JBOJP.charAt(1));
  1916. prochainX2 = Character.getNumericValue(JBOBP.charAt(0));
  1917. prochainY2 = Character.getNumericValue(JBOBP.charAt(1));
  1918. prochainX3 = Character.getNumericValue(JBOOP.charAt(0));
  1919. prochainY3 = Character.getNumericValue(JBOOP.charAt(1));
  1920.  
  1921. prochaineCouleur = "JAUNE";
  1922. prochaineCouleur2 = "BLEU";
  1923. prochaineCouleur3 = "ORANGE";
  1924. Coin[2] = "";
  1925. paireimpaire++;
  1926.  
  1927. }
  1928.  
  1929. else if(TabRef[prochainX][prochainY] == CouleurEnum.BLEU) {
  1930.  
  1931. Resolution = Resolution + JBOB;
  1932. //System.out.println(JBOB);
  1933. string_solv.add("JBOB");
  1934. string_solv.add(JBOB);
  1935. prochainX = Character.getNumericValue(JBOBP.charAt(0));
  1936. prochainY = Character.getNumericValue(JBOBP.charAt(1));
  1937. prochainX2 = Character.getNumericValue(JBOJP.charAt(0));
  1938. prochainY2 = Character.getNumericValue(JBOJP.charAt(1));
  1939. prochainX3 = Character.getNumericValue(JBOOP.charAt(0));
  1940. prochainY3 = Character.getNumericValue(JBOOP.charAt(1));
  1941.  
  1942. prochaineCouleur = "BLEU";
  1943. prochaineCouleur2 = "JAUNE";
  1944. prochaineCouleur3 = "ORANGE";
  1945. Coin[2] = "";
  1946. paireimpaire++;
  1947.  
  1948. }
  1949. else if(TabRef[prochainX][prochainY] == CouleurEnum.ORANGE) {
  1950.  
  1951. Resolution = Resolution + JBOO;
  1952. //System.out.println(JBOO);
  1953. string_solv.add("JBOO");
  1954. string_solv.add(JBOO);
  1955. prochainX = Character.getNumericValue(JBOOP.charAt(0));
  1956. prochainY = Character.getNumericValue(JBOOP.charAt(1));
  1957. prochainX2 = Character.getNumericValue(JBOJP.charAt(0));
  1958. prochainY2 = Character.getNumericValue(JBOJP.charAt(1));
  1959. prochainX3 = Character.getNumericValue(JBOBP.charAt(0));
  1960. prochainY3 = Character.getNumericValue(JBOBP.charAt(1));
  1961.  
  1962. prochaineCouleur = "ORANGE";
  1963. prochaineCouleur2 = "JAUNE";
  1964. prochaineCouleur3 = "BLEU";
  1965. Coin[2] = "";
  1966. paireimpaire++;
  1967.  
  1968. }
  1969. }
  1970.  
  1971. /*
  1972. * CAS DU COIN BOBl
  1973. */
  1974.  
  1975. else if(Buffer.contient(CouleurEnum.BLEU, CouleurEnum.ORANGE, CouleurEnum.BLANC)) {
  1976.  
  1977. //System.out.println("BOBl");
  1978. if(Coin[3] == "") {
  1979. BooJVO = true;
  1980. }
  1981.  
  1982. else if(TabRef[prochainX][prochainY] == CouleurEnum.BLEU) {
  1983.  
  1984. Resolution = Resolution + BOBlB;
  1985. //System.out.println(BOBlB);
  1986. string_solv.add("BOBlB");
  1987. string_solv.add(BOBlB);
  1988. prochainX = Character.getNumericValue(BOBlBP.charAt(0));
  1989. prochainY = Character.getNumericValue(BOBlBP.charAt(1));
  1990. prochainX2 = Character.getNumericValue(BOBlOP.charAt(0));
  1991. prochainY2 = Character.getNumericValue(BOBlOP.charAt(1));
  1992. prochainX3 = Character.getNumericValue(BOBlBlP.charAt(0));
  1993. prochainY3 = Character.getNumericValue(BOBlBlP.charAt(1));
  1994.  
  1995. prochaineCouleur = "BLEU";
  1996. prochaineCouleur2 = "ORANGE";
  1997. prochaineCouleur3 = "BLANC";
  1998. Coin[3] = "";
  1999. paireimpaire++;
  2000.  
  2001. }
  2002. else if(TabRef[prochainX][prochainY] == CouleurEnum.ORANGE) {
  2003.  
  2004. Resolution = Resolution + BOBlO;
  2005. //System.out.println(BOBlO);
  2006. string_solv.add("BOBlO");
  2007. string_solv.add(BOBlO);
  2008. prochainX = Character.getNumericValue(BOBlOP.charAt(0));
  2009. prochainY = Character.getNumericValue(BOBlOP.charAt(1));
  2010. prochainX2 = Character.getNumericValue(BOBlBP.charAt(0));
  2011. prochainY2 = Character.getNumericValue(BOBlBP.charAt(1));
  2012. prochainX3 = Character.getNumericValue(BOBlBlP.charAt(0));
  2013. prochainY3 = Character.getNumericValue(BOBlBlP.charAt(1));
  2014.  
  2015. prochaineCouleur = "ORANGE";
  2016. prochaineCouleur2 = "BLEU";
  2017. prochaineCouleur3 = "BLANC";
  2018. Coin[3] = "";
  2019. paireimpaire++;
  2020.  
  2021. }
  2022. else if(TabRef[prochainX][prochainY] == CouleurEnum.BLANC) {
  2023.  
  2024. Resolution = Resolution + BOBlBl;
  2025. //System.out.println(BOBlBl);
  2026. string_solv.add("BOBlBl");
  2027. string_solv.add(BOBlBl);
  2028. prochainX = Character.getNumericValue(BOBlBlP.charAt(0));
  2029. prochainY = Character.getNumericValue(BOBlBlP.charAt(1));
  2030. prochainX2 = Character.getNumericValue(BOBlBP.charAt(0));
  2031. prochainY2 = Character.getNumericValue(BOBlBP.charAt(1));
  2032. prochainX3 = Character.getNumericValue(BOBlOP.charAt(0));
  2033. prochainY3 = Character.getNumericValue(BOBlOP.charAt(1));
  2034.  
  2035. prochaineCouleur = "BLANC";
  2036. prochaineCouleur2 = "BLEU";
  2037. prochaineCouleur3 = "ORANGE";
  2038. Coin[3] = "";
  2039. paireimpaire++;
  2040.  
  2041. }
  2042. }
  2043.  
  2044. /*
  2045. * CAS DU COIN BRBl
  2046. */
  2047.  
  2048. else if(Buffer.contient(CouleurEnum.BLEU, CouleurEnum.ROUGE, CouleurEnum.BLANC)) {
  2049.  
  2050. //System.out.println("BRBl");
  2051. if(Coin[4] == "") {
  2052. BooJVO = true;
  2053. }
  2054.  
  2055. else if(TabRef[prochainX][prochainY] == CouleurEnum.BLEU) {
  2056.  
  2057. Resolution = Resolution + BRBlB;
  2058. //System.out.println(BRBlB);
  2059. string_solv.add("BRBlB");
  2060. string_solv.add(BRBlB);
  2061. prochainX = Character.getNumericValue(BRBlBP.charAt(0));
  2062. prochainY = Character.getNumericValue(BRBlBP.charAt(1));
  2063. prochainX2 = Character.getNumericValue(BRBlRP.charAt(0));
  2064. prochainY2 = Character.getNumericValue(BRBlRP.charAt(1));
  2065. prochainX3 = Character.getNumericValue(BRBlBlP.charAt(0));
  2066. prochainY3 = Character.getNumericValue(BRBlBlP.charAt(1));
  2067.  
  2068. prochaineCouleur = "BLEU";
  2069. prochaineCouleur2 = "ROUGE";
  2070. prochaineCouleur3 = "BLANC";
  2071. Coin[4] = "";
  2072. paireimpaire++;
  2073.  
  2074. }
  2075. else if(TabRef[prochainX][prochainY] == CouleurEnum.ROUGE) {
  2076.  
  2077. Resolution = Resolution + BRBlR;
  2078. //System.out.println(BRBlR);
  2079. string_solv.add("BRBlR");
  2080. string_solv.add(BRBlR);
  2081. prochainX = Character.getNumericValue(BRBlRP.charAt(0));
  2082. prochainY = Character.getNumericValue(BRBlRP.charAt(1));
  2083. prochainX2 = Character.getNumericValue(BRBlBP.charAt(0));
  2084. prochainY2 = Character.getNumericValue(BRBlBP.charAt(1));
  2085. prochainX3 = Character.getNumericValue(BRBlBlP.charAt(0));
  2086. prochainY3 = Character.getNumericValue(BRBlBlP.charAt(1));
  2087.  
  2088. prochaineCouleur = "ROUGE";
  2089. prochaineCouleur2 = "BLEU";
  2090. prochaineCouleur3 = "BLANC";
  2091. Coin[4] = "";
  2092. paireimpaire++;
  2093.  
  2094. }
  2095. else if(TabRef[prochainX][prochainY] == CouleurEnum.BLANC) {
  2096.  
  2097. Resolution = Resolution + BRBlBl;
  2098. //System.out.println(BRBlBl);
  2099. string_solv.add("BRBlBl");
  2100. string_solv.add(BRBlBl);
  2101. prochainX = Character.getNumericValue(BRBlBlP.charAt(0));
  2102. prochainY = Character.getNumericValue(BRBlBlP.charAt(1));
  2103. prochainX2 = Character.getNumericValue(BRBlBP.charAt(0));
  2104. prochainY2 = Character.getNumericValue(BRBlBP.charAt(1));
  2105. prochainX3 = Character.getNumericValue(BRBlRP.charAt(0));
  2106. prochainY3 = Character.getNumericValue(BRBlRP.charAt(1));
  2107.  
  2108. prochaineCouleur = "BLANC";
  2109. prochaineCouleur2 = "BLEU";
  2110. prochaineCouleur3 = "ROUGE";
  2111. Coin[4] = "";
  2112. paireimpaire++;
  2113.  
  2114. }
  2115. }
  2116.  
  2117. /*
  2118. * CAS DU COIN RVBl
  2119. */
  2120.  
  2121. else if(Buffer.contient(CouleurEnum.ROUGE, CouleurEnum.VERT, CouleurEnum.BLANC)) {
  2122.  
  2123. //System.out.println("RVBl");
  2124. if(Coin[5] == "") {
  2125. BooJVO = true;
  2126. }
  2127.  
  2128. else if(TabRef[prochainX][prochainY] == CouleurEnum.ROUGE) {
  2129.  
  2130. Resolution = Resolution + RVBlR;
  2131. //System.out.println(RVBlR);
  2132. string_solv.add("RVBlR");
  2133. string_solv.add(RVBlR);
  2134. prochainX = Character.getNumericValue(RVBlRP.charAt(0));
  2135. prochainY = Character.getNumericValue(RVBlRP.charAt(1));
  2136. prochainX2 = Character.getNumericValue(RVBlVP.charAt(0));
  2137. prochainY2 = Character.getNumericValue(RVBlVP.charAt(1));
  2138. prochainX3 = Character.getNumericValue(RVBlBlP.charAt(0));
  2139. prochainY3 = Character.getNumericValue(RVBlBlP.charAt(1));
  2140.  
  2141. prochaineCouleur = "ROUGE";
  2142. prochaineCouleur2 = "VERT";
  2143. prochaineCouleur3 = "BLANC";
  2144. Coin[5] = "";
  2145. paireimpaire++;
  2146.  
  2147. }
  2148. else if(TabRef[prochainX][prochainY] == CouleurEnum.VERT) {
  2149.  
  2150. Resolution = Resolution + RVBlV;
  2151. //System.out.println(RVBlV);
  2152. string_solv.add("RVBlV");
  2153. string_solv.add(RVBlV);
  2154. prochainX = Character.getNumericValue(RVBlVP.charAt(0));
  2155. prochainY = Character.getNumericValue(RVBlVP.charAt(1));
  2156. prochainX2 = Character.getNumericValue(RVBlRP.charAt(0));
  2157. prochainY2 = Character.getNumericValue(RVBlRP.charAt(1));
  2158. prochainX3 = Character.getNumericValue(RVBlBlP.charAt(0));
  2159. prochainY3 = Character.getNumericValue(RVBlBlP.charAt(1));
  2160.  
  2161. prochaineCouleur = "VERT";
  2162. prochaineCouleur2 = "ROUGE";
  2163. prochaineCouleur3 = "BLANC";
  2164. Coin[5] = "";
  2165. paireimpaire++;
  2166.  
  2167. }
  2168. else if(TabRef[prochainX][prochainY] == CouleurEnum.BLANC) {
  2169.  
  2170. Resolution = Resolution + RVBlBl;
  2171. //System.out.println(RVBlBl);
  2172. string_solv.add("RVBlBl");
  2173. string_solv.add(RVBlBl);
  2174. prochainX = Character.getNumericValue(RVBlBlP.charAt(0));
  2175. prochainY = Character.getNumericValue(RVBlBlP.charAt(1));
  2176. prochainX2 = Character.getNumericValue(RVBlRP.charAt(0));
  2177. prochainY2 = Character.getNumericValue(RVBlRP.charAt(1));
  2178. prochainX3 = Character.getNumericValue(RVBlVP.charAt(0));
  2179. prochainY3 = Character.getNumericValue(RVBlVP.charAt(1));
  2180.  
  2181. prochaineCouleur = "BLANC";
  2182. prochaineCouleur2 = "ROUGE";
  2183. prochaineCouleur3 = "VERT";
  2184. Coin[5] = "";
  2185. paireimpaire++;
  2186.  
  2187. }
  2188. }
  2189.  
  2190. /*
  2191. * CAS DU COIN VOBl
  2192. */
  2193.  
  2194. else if(Buffer.contient(CouleurEnum.VERT, CouleurEnum.ORANGE, CouleurEnum.BLANC)) {
  2195.  
  2196. //System.out.println("VOBl");
  2197. if(Coin[6] == "") {
  2198. BooJVO = true;
  2199. }
  2200.  
  2201. else if(TabRef[prochainX][prochainY] == CouleurEnum.VERT) {
  2202.  
  2203. Resolution = Resolution + VOBlV;
  2204. //System.out.println(VOBlV);
  2205. string_solv.add("VOBlV");
  2206. string_solv.add(VOBlV);
  2207. prochainX = Character.getNumericValue(VOBlVP.charAt(0));
  2208. prochainY = Character.getNumericValue(VOBlVP.charAt(1));
  2209. prochainX2 = Character.getNumericValue(VOBlOP.charAt(0));
  2210. prochainY2 = Character.getNumericValue(VOBlOP.charAt(1));
  2211. prochainX3 = Character.getNumericValue(VOBlBlP.charAt(0));
  2212. prochainY3 = Character.getNumericValue(VOBlBlP.charAt(1));
  2213.  
  2214. prochaineCouleur = "VERT";
  2215. prochaineCouleur2 = "ORANGE";
  2216. prochaineCouleur3 = "BLANC";
  2217. Coin[6] = "";
  2218. paireimpaire++;
  2219.  
  2220. }
  2221.  
  2222. else if(TabRef[prochainX][prochainY] == CouleurEnum.ORANGE) {
  2223.  
  2224. Resolution = Resolution + VOBlO;
  2225. //System.out.println(VOBlO);
  2226. string_solv.add("VOBlO");
  2227. string_solv.add(VOBlO);
  2228. prochainX = Character.getNumericValue(VOBlOP.charAt(0));
  2229. prochainY = Character.getNumericValue(VOBlOP.charAt(1));
  2230. prochainX2 = Character.getNumericValue(VOBlVP.charAt(0));
  2231. prochainY2 = Character.getNumericValue(VOBlVP.charAt(1));
  2232. prochainX3 = Character.getNumericValue(VOBlBlP.charAt(0));
  2233. prochainY3 = Character.getNumericValue(VOBlBlP.charAt(1));
  2234.  
  2235. prochaineCouleur = "ORANGE";
  2236. prochaineCouleur2 = "VERT";
  2237. prochaineCouleur3 = "BLANC";
  2238. Coin[6] = "";
  2239. paireimpaire++;
  2240.  
  2241. }
  2242.  
  2243. else if(TabRef[prochainX][prochainY] == CouleurEnum.BLANC) {
  2244.  
  2245. Resolution = Resolution + VOBlBl;
  2246. //System.out.println(VOBlBl);
  2247. string_solv.add("VOBlBl");
  2248. string_solv.add(VOBlBl);
  2249. prochainX = Character.getNumericValue(VOBlBlP.charAt(0));
  2250. prochainY = Character.getNumericValue(VOBlBlP.charAt(1));
  2251. prochainX2 = Character.getNumericValue(VOBlVP.charAt(0));
  2252. prochainY2 = Character.getNumericValue(VOBlVP.charAt(1));
  2253. prochainX3 = Character.getNumericValue(VOBlOP.charAt(0));
  2254. prochainY3 = Character.getNumericValue(VOBlOP.charAt(1));
  2255.  
  2256. prochaineCouleur = "BLANC";
  2257. prochaineCouleur2 = "VERT";
  2258. prochaineCouleur3 = "ORANGE";
  2259. Coin[6] = "";
  2260. paireimpaire++;
  2261.  
  2262. }
  2263. }
  2264.  
  2265. /*
  2266. * CAS DU COIN JVO
  2267. */
  2268.  
  2269. if(Buffer.contient(CouleurEnum.JAUNE, CouleurEnum.VERT, CouleurEnum.ORANGE)|| BooJVO) {
  2270.  
  2271. //System.out.println("JVO");
  2272. string_solv.add("JVO");
  2273. BooJVO = false;
  2274.  
  2275. if(Coin[0] != ""){
  2276.  
  2277. prochainX = Character.getNumericValue(JRVJP.charAt(0));
  2278. prochainY = Character.getNumericValue(JRVJP.charAt(1));
  2279. prochainX2 = Character.getNumericValue(JRVRP.charAt(0));
  2280. prochainY2 = Character.getNumericValue(JRVRP.charAt(1));
  2281. prochainX3 = Character.getNumericValue(JRVVP.charAt(0));
  2282. prochainY3 = Character.getNumericValue(JRVVP.charAt(1));
  2283.  
  2284. prochaineCouleur = "JAUNE";
  2285. prochaineCouleur2 = "ROUGE";
  2286. prochaineCouleur3 = "VERT";
  2287.  
  2288. Resolution = Resolution + JRVJ;
  2289. //System.out.println(JRVJ);
  2290. string_solv.add(JRVJ);
  2291. paireimpaire++;
  2292.  
  2293. }
  2294.  
  2295. else if(Coin[1] != ""){
  2296.  
  2297. prochainX = Character.getNumericValue(JBRJP.charAt(0));
  2298. prochainY = Character.getNumericValue(JBRJP.charAt(1));
  2299. prochainX2 = Character.getNumericValue(JBRBP.charAt(0));
  2300. prochainY2 = Character.getNumericValue(JBRBP.charAt(1));
  2301. prochainX3 = Character.getNumericValue(JBRRP.charAt(0));
  2302. prochainY3 = Character.getNumericValue(JBRRP.charAt(1));
  2303.  
  2304. prochaineCouleur = "JAUNE";
  2305. prochaineCouleur2 = "BLEU";
  2306. prochaineCouleur3 = "ROUGE";
  2307. Resolution = Resolution + JBRJ;
  2308. //System.out.println(JBRJ);
  2309. string_solv.add(JBRJ);
  2310. paireimpaire++;
  2311.  
  2312. }
  2313.  
  2314. else if(Coin[2] != ""){
  2315.  
  2316. prochainX = Character.getNumericValue(JBOJP.charAt(0));
  2317. prochainY = Character.getNumericValue(JBOJP.charAt(1));
  2318. prochainX2 = Character.getNumericValue(JBOBP.charAt(0));
  2319. prochainY2 = Character.getNumericValue(JBOBP.charAt(1));
  2320. prochainX3 = Character.getNumericValue(JBOOP.charAt(0));
  2321. prochainY3 = Character.getNumericValue(JBOOP.charAt(1));
  2322.  
  2323. prochaineCouleur = "JAUNE";
  2324. prochaineCouleur2 = "BLEU";
  2325. prochaineCouleur3 = "ORANGE";
  2326. Resolution = Resolution + JBOJ;
  2327. //System.out.println(JBOJ);
  2328. string_solv.add(JBOJ);
  2329. paireimpaire++;
  2330.  
  2331. }
  2332.  
  2333. else if(Coin[3] != ""){
  2334.  
  2335. prochainX = Character.getNumericValue(BOBlBP.charAt(0));
  2336. prochainY = Character.getNumericValue(BOBlBP.charAt(1));
  2337. prochainX2 = Character.getNumericValue(BOBlOP.charAt(0));
  2338. prochainY2 = Character.getNumericValue(BOBlOP.charAt(1));
  2339. prochainX3 = Character.getNumericValue(BOBlBlP.charAt(0));
  2340. prochainY3 = Character.getNumericValue(BOBlBlP.charAt(1));
  2341.  
  2342. prochaineCouleur = "BLEU";
  2343. prochaineCouleur2 = "ORANGE";
  2344. prochaineCouleur3 = "BLANC";
  2345. Resolution = Resolution + BOBlB;
  2346. //System.out.println(BOBlB);
  2347. string_solv.add(BOBlB);
  2348. paireimpaire++;
  2349.  
  2350. }
  2351.  
  2352. else if(Coin[4] != ""){
  2353.  
  2354.  
  2355. prochainX = Character.getNumericValue(BRBlBP.charAt(0));
  2356. prochainY = Character.getNumericValue(BRBlBP.charAt(1));
  2357. prochainX2 = Character.getNumericValue(BRBlRP.charAt(0));
  2358. prochainY2 = Character.getNumericValue(BRBlRP.charAt(1));
  2359. prochainX3 = Character.getNumericValue(BRBlBlP.charAt(0));
  2360. prochainY3 = Character.getNumericValue(BRBlBlP.charAt(1));
  2361.  
  2362. prochaineCouleur = "BLEU";
  2363. prochaineCouleur2 = "ROUGE";
  2364. prochaineCouleur3 = "BLANC";
  2365. Resolution = Resolution + BRBlB;
  2366. //System.out.println(BRBlB);
  2367. string_solv.add(BRBlB);
  2368. paireimpaire++;
  2369. }
  2370.  
  2371. else if(Coin[5] != ""){
  2372.  
  2373. prochainX = Character.getNumericValue(RVBlRP.charAt(0));
  2374. prochainY = Character.getNumericValue(RVBlRP.charAt(1));
  2375. prochainX2 = Character.getNumericValue(RVBlVP.charAt(0));
  2376. prochainY2 = Character.getNumericValue(RVBlVP.charAt(1));
  2377. prochainX3 = Character.getNumericValue(RVBlBlP.charAt(0));
  2378. prochainY3 = Character.getNumericValue(RVBlBlP.charAt(1));
  2379.  
  2380. prochaineCouleur = "ROUGE";
  2381. prochaineCouleur2 = "VERT";
  2382. prochaineCouleur3 = "BLANC";
  2383. Resolution = Resolution + RVBlR;
  2384. //System.out.println(RVBlR);
  2385. string_solv.add(RVBlR);
  2386. paireimpaire++;
  2387.  
  2388. }
  2389.  
  2390. else if(Coin[6] != ""){
  2391.  
  2392. prochainX = Character.getNumericValue(VOBlVP.charAt(0));
  2393. prochainY = Character.getNumericValue(VOBlVP.charAt(1));
  2394. prochainX2 = Character.getNumericValue(VOBlOP.charAt(0));
  2395. prochainY2 = Character.getNumericValue(VOBlOP.charAt(1));
  2396. prochainX3 = Character.getNumericValue(VOBlBlP.charAt(0));
  2397. prochainY3 = Character.getNumericValue(VOBlBlP.charAt(1));
  2398.  
  2399. prochaineCouleur = "VERT";
  2400. prochaineCouleur2 = "ORANGE";
  2401. prochaineCouleur3 = "BLANC";
  2402. Resolution = Resolution + VOBlV;
  2403. //System.out.println(VOBlV);
  2404. string_solv.add(VOBlV);
  2405. paireimpaire++;
  2406.  
  2407. }
  2408. }
  2409. }
  2410.  
  2411. /*
  2412. * WHILE POUR LES COINS BIEN PLACES
  2413. */
  2414.  
  2415. while(!(CoinOri.isEmpty())) {
  2416.  
  2417. if(CoinOri.get(0) == "JRV") {
  2418.  
  2419. Resolution = Resolution + JRVJ;
  2420. //System.out.println(JRVJ);
  2421. string_solv.add(JRVJ);
  2422.  
  2423. if(FaceJaune[0][2] == CouleurEnum.ROUGE) {
  2424.  
  2425. Resolution = Resolution + JRVR;
  2426. //System.out.println(JRVR);
  2427. string_solv.add(JRVR);
  2428. }
  2429.  
  2430. else if(FaceJaune[0][2] == CouleurEnum.VERT) {
  2431.  
  2432. Resolution = Resolution + JRVV;
  2433. //System.out.println(JRVV);
  2434. string_solv.add(JRVV);
  2435. }
  2436.  
  2437. CoinOri.remove("JRV");
  2438. }
  2439.  
  2440.  
  2441. else if(CoinOri.get(0) == "JBR") {
  2442.  
  2443.  
  2444. Resolution = Resolution + JBRJ;
  2445. //System.out.println(JBRJ);
  2446. string_solv.add(JBRJ);
  2447.  
  2448. if(FaceJaune[2][2] == CouleurEnum.BLEU) {
  2449.  
  2450. Resolution = Resolution + JBRB;
  2451. //System.out.println(JBRB);
  2452. string_solv.add(JBRB);
  2453. }
  2454.  
  2455. else if(FaceJaune[2][2] == CouleurEnum.ROUGE) {
  2456.  
  2457. Resolution = Resolution + JBRR;
  2458. //System.out.println(JBRR);
  2459. string_solv.add(JBRR);
  2460. }
  2461.  
  2462. CoinOri.remove("JBR");
  2463. }
  2464.  
  2465. else if(CoinOri.get(0) == "JBO") {
  2466.  
  2467. Resolution = Resolution + JBOJ;
  2468. //System.out.println(JBOJ);
  2469. string_solv.add(JBOJ);
  2470.  
  2471. if(FaceJaune[2][0] == CouleurEnum.BLEU) {
  2472.  
  2473. Resolution = Resolution + JBOB;
  2474. //System.out.println(JBOB);
  2475. string_solv.add(JBOB);
  2476. }
  2477.  
  2478. else if(FaceJaune[2][0] == CouleurEnum.ORANGE) {
  2479.  
  2480. Resolution = Resolution + JBOO;
  2481. //System.out.println(JBOO);
  2482. string_solv.add(JBOO);
  2483. }
  2484. CoinOri.remove("JBO");
  2485.  
  2486. }
  2487.  
  2488. else if(CoinOri.get(0) == "BOBl") {
  2489.  
  2490. Resolution = Resolution + BOBlBl;
  2491. //System.out.println(BOBlBl);
  2492. string_solv.add(BOBlBl);
  2493.  
  2494. if(FaceBlanc[0][0] == CouleurEnum.BLEU) {
  2495.  
  2496. Resolution = Resolution + BOBlB;
  2497. //System.out.println(BOBlB);
  2498. string_solv.add(BOBlB);
  2499. }
  2500.  
  2501. else if(FaceBlanc[0][0] == CouleurEnum.ORANGE) {
  2502.  
  2503. Resolution = Resolution + BOBlO;
  2504. //System.out.println(BOBlO);
  2505. string_solv.add(BOBlO);
  2506. }
  2507.  
  2508. CoinOri.remove("BOBl");
  2509. }
  2510.  
  2511. else if(CoinOri.get(0) == "BRBl") {
  2512.  
  2513. Resolution = Resolution + BRBlBl;
  2514. //System.out.println(BRBlBl);
  2515. string_solv.add(BRBlBl);
  2516.  
  2517. if(FaceBlanc[0][2] == CouleurEnum.BLEU) {
  2518.  
  2519. Resolution = Resolution + BRBlB;
  2520. //System.out.println(BRBlB);
  2521. string_solv.add(BRBlB);
  2522. }
  2523.  
  2524. else if(FaceBlanc[0][2] == CouleurEnum.ROUGE) {
  2525.  
  2526. Resolution = Resolution + BRBlR;
  2527. //System.out.println(BRBlR);
  2528. string_solv.add(BRBlR);
  2529. }
  2530.  
  2531. CoinOri.remove("BRBl");
  2532. }
  2533.  
  2534. else if(CoinOri.get(0) == "RVBl") {
  2535.  
  2536.  
  2537. Resolution = Resolution + RVBlBl;
  2538. //System.out.println(RVBlBl);
  2539. string_solv.add(RVBlBl);
  2540.  
  2541. if(FaceBlanc[2][2] == CouleurEnum.ROUGE) {
  2542.  
  2543. Resolution = Resolution + RVBlR;
  2544. //System.out.println(RVBlR);
  2545. string_solv.add(RVBlR);
  2546. }
  2547.  
  2548. else if(FaceBlanc[2][2] == CouleurEnum.VERT) {
  2549.  
  2550. Resolution = Resolution + RVBlV;
  2551. //System.out.println(RVBlV);
  2552. string_solv.add(RVBlV);
  2553. }
  2554.  
  2555. CoinOri.remove("RVBl");
  2556. }
  2557.  
  2558. else if(CoinOri.get(0) == "VOBl") {
  2559.  
  2560. Resolution = Resolution + VOBlBl;
  2561. //System.out.println(VOBlBl);
  2562. string_solv.add(VOBlBl);
  2563.  
  2564. if(FaceBlanc[2][0] == CouleurEnum.VERT) {
  2565.  
  2566. Resolution = Resolution + VOBlV;
  2567. //System.out.println(VOBlV);
  2568. string_solv.add(VOBlV);
  2569. }
  2570. else if(FaceBlanc[2][0] == CouleurEnum.ORANGE) {
  2571.  
  2572. Resolution = Resolution + VOBlO;
  2573. //System.out.println(VOBlO);
  2574. string_solv.add(VOBlO);
  2575. }
  2576.  
  2577. CoinOri.remove("VOBl");
  2578. }
  2579. }
  2580.  
  2581. cours = Resolution;
  2582.  
  2583. /*
  2584. *
  2585. * ARETES
  2586. *
  2587. */
  2588.  
  2589. /*
  2590. * DETECTION DES ARETES DEJA BIEN PLACEES
  2591. */
  2592.  
  2593. if(JV.contient(CouleurEnum.JAUNE, CouleurEnum.VERT)) {
  2594.  
  2595. if(!(JV.getCouleur(i1) == CouleurEnum.JAUNE && JV.getCouleur(i2) == CouleurEnum.VERT)) {
  2596.  
  2597. ArreteOri.add("JV");
  2598. Arrete[0] = "";
  2599. }
  2600.  
  2601. else {
  2602. Arrete[0] = "";
  2603.  
  2604. }
  2605. }
  2606.  
  2607. if(JB.contient(CouleurEnum.JAUNE, CouleurEnum.BLEU)) {
  2608.  
  2609. if(!(JB.getCouleur(i1) == CouleurEnum.JAUNE && JB.getCouleur(i2) == CouleurEnum.BLEU)) {
  2610.  
  2611. ArreteOri.add("JB");
  2612. Arrete[1] = "";
  2613. }
  2614.  
  2615. else {
  2616. Arrete[1] = "";
  2617.  
  2618. }
  2619. }
  2620.  
  2621. if(JO.contient(CouleurEnum.JAUNE, CouleurEnum.ORANGE)) {
  2622.  
  2623. if(!(JO.getCouleur(i1) == CouleurEnum.JAUNE && JO.getCouleur(i2) == CouleurEnum.ORANGE)) {
  2624.  
  2625. ArreteOri.add("JO");
  2626. Arrete[2] = "";
  2627. }
  2628.  
  2629. else {
  2630. Arrete[2] = "";
  2631.  
  2632. }
  2633. }
  2634.  
  2635. if(VO.contient(CouleurEnum.VERT, CouleurEnum.ORANGE)) {
  2636.  
  2637. if(!(VO.getCouleur(i1) == CouleurEnum.VERT && VO.getCouleur(i2) == CouleurEnum.ORANGE)) {
  2638.  
  2639. ArreteOri.add("VO");
  2640. Arrete[3] = "";
  2641. }
  2642.  
  2643. else {
  2644. Arrete[3] = "";
  2645.  
  2646. }
  2647. }
  2648.  
  2649. if(RV.contient(CouleurEnum.ROUGE, CouleurEnum.VERT)) {
  2650.  
  2651. if(!(RV.getCouleur(i1) == CouleurEnum.ROUGE && RV.getCouleur(i2) == CouleurEnum.VERT)) {
  2652.  
  2653. ArreteOri.add("RV");
  2654. Arrete[4] = "";
  2655. }
  2656.  
  2657. else {
  2658. Arrete[4] = "";
  2659.  
  2660. }
  2661. }
  2662.  
  2663. if(BR.contient(CouleurEnum.BLEU, CouleurEnum.ROUGE)) {
  2664.  
  2665. if(!(BR.getCouleur(i1) == CouleurEnum.BLEU && BR.getCouleur(i2) == CouleurEnum.ROUGE)) {
  2666.  
  2667. ArreteOri.add("BR");
  2668. Arrete[5] = "";
  2669. }
  2670.  
  2671. else {
  2672. Arrete[5] = "";
  2673. }
  2674. }
  2675.  
  2676. if(BO.contient(CouleurEnum.BLEU, CouleurEnum.ORANGE)) {
  2677.  
  2678. if(!(BO.getCouleur(i1) == CouleurEnum.BLEU && BO.getCouleur(i2) == CouleurEnum.ORANGE)) {
  2679.  
  2680. ArreteOri.add("BO");
  2681. Arrete[6] = "";
  2682. }
  2683.  
  2684. else {
  2685. Arrete[6] = "";
  2686. }
  2687. }
  2688.  
  2689. if(BBl.contient(CouleurEnum.BLEU, CouleurEnum.BLANC)) {
  2690.  
  2691. if(!(BBl.getCouleur(i1) == CouleurEnum.BLEU && BBl.getCouleur(i2) == CouleurEnum.BLANC)) {
  2692.  
  2693. ArreteOri.add("BBl");
  2694. Arrete[7] = "";
  2695. }
  2696.  
  2697. else {
  2698. Arrete[7] = "";
  2699. }
  2700. }
  2701.  
  2702. if(RBl.contient(CouleurEnum.ROUGE, CouleurEnum.BLANC)) {
  2703.  
  2704. if(!(RBl.getCouleur(i1) == CouleurEnum.ROUGE && RBl.getCouleur(i2) == CouleurEnum.BLANC)) {
  2705.  
  2706. ArreteOri.add("RBl");
  2707. Arrete[8] = "";
  2708. }
  2709.  
  2710. else {
  2711. Arrete[8] = "";
  2712. }
  2713. }
  2714.  
  2715. if(VBl.contient(CouleurEnum.VERT, CouleurEnum.BLANC)) {
  2716.  
  2717. if(!(VBl.getCouleur(i1) == CouleurEnum.VERT && VBl.getCouleur(i2) == CouleurEnum.BLANC)) {
  2718.  
  2719. ArreteOri.add("VBl");
  2720. Arrete[9] = "";
  2721. }
  2722.  
  2723. else {
  2724. Arrete[9] = "";
  2725. }
  2726. }
  2727.  
  2728. if(OBl.contient(CouleurEnum.ORANGE, CouleurEnum.BLANC)) {
  2729.  
  2730. if(!(OBl.getCouleur(i1) == CouleurEnum.ORANGE && OBl.getCouleur(i2) == CouleurEnum.BLANC)) {
  2731.  
  2732. ArreteOri.add("OBl");
  2733. Arrete[10] = "";
  2734. }
  2735.  
  2736. else {
  2737. Arrete[10] = "";
  2738. }
  2739. }
  2740.  
  2741. Arete BufferA = new Arete();
  2742.  
  2743. /*
  2744. * CAS DU NOMBRE DE MOUVEMENTS DE COIN IMPAIRE
  2745. */
  2746.  
  2747. if(paireimpaire % 2 != 0){
  2748. Resolution = Resolution + PLLRP;
  2749. //System.out.println(PLLRP);
  2750. string_solv.add(PLLRP);
  2751. }
  2752.  
  2753. /*
  2754. * WHILE POUR LES ARRETES MAL PLACEES
  2755. */
  2756.  
  2757. while(!(Arrete[0] == "" && Arrete[1] == "" && Arrete[2] == "" && Arrete[3] == "" && Arrete[4] == "" && Arrete[5] == "" && Arrete[6] == "" && Arrete[7] == "" && Arrete[8] == "" && Arrete[9] == "" && Arrete[10] == "" )) {
  2758.  
  2759. /*
  2760. * CHOIX PREMIERE FACE A CHECK
  2761. */
  2762.  
  2763. if(prochaineCouleurA == "JAUNE") {
  2764. BufferA.setCouleur(i1, FaceJaune[prochainXA][prochainYA]);
  2765. TabRef = FaceJaune;
  2766. }
  2767. else if(prochaineCouleurA == "BLEU") {
  2768. BufferA.setCouleur(i1, FaceBleu[prochainXA][prochainYA]);
  2769. TabRef = FaceBleu;
  2770. }
  2771. else if(prochaineCouleurA == "ROUGE") {
  2772. BufferA.setCouleur(i1, FaceRouge[prochainXA][prochainYA]);
  2773. TabRef = FaceRouge;
  2774. }
  2775. else if(prochaineCouleurA == "VERT") {
  2776. BufferA.setCouleur(i1, FaceVert[prochainXA][prochainYA]);
  2777. TabRef = FaceVert;
  2778. }
  2779. else if(prochaineCouleurA == "ORANGE") {
  2780. BufferA.setCouleur(i1, FaceOrange[prochainXA][prochainYA]);
  2781. TabRef = FaceOrange;
  2782. }
  2783. else if(prochaineCouleurA == "BLANC") {
  2784. BufferA.setCouleur(i1, FaceBlanc[prochainXA][prochainYA]);
  2785. TabRef = FaceBlanc;
  2786. }
  2787.  
  2788. /*
  2789. * CHOIX DEUXIEME FACE A CHECK
  2790. */
  2791.  
  2792. if(prochaineCouleur2A == "JAUNE") {
  2793. BufferA.setCouleur(i2, FaceJaune[prochainX2A][prochainY2A]);
  2794.  
  2795. }
  2796. else if(prochaineCouleur2A == "BLEU") {
  2797. BufferA.setCouleur(i2, FaceBleu[prochainX2A][prochainY2A]);
  2798.  
  2799. }
  2800. else if(prochaineCouleur2A == "ROUGE") {
  2801. BufferA.setCouleur(i2, FaceRouge[prochainX2A][prochainY2A]);
  2802.  
  2803. }
  2804. else if(prochaineCouleur2A == "VERT") {
  2805. BufferA.setCouleur(i2, FaceVert[prochainX2A][prochainY2A]);
  2806.  
  2807. }
  2808. else if(prochaineCouleur2A == "ORANGE") {
  2809. BufferA.setCouleur(i2, FaceOrange[prochainX2A][prochainY2A]);
  2810.  
  2811. }
  2812. else if(prochaineCouleur2A == "BLANC") {
  2813. BufferA.setCouleur(i2, FaceBlanc[prochainX2A][prochainY2A]);
  2814.  
  2815. }
  2816.  
  2817. /*
  2818. * CAS DE L'ARETE JV
  2819. */
  2820.  
  2821. if(BufferA.contient(CouleurEnum.JAUNE,CouleurEnum.VERT)) {
  2822. //System.out.println("JV");
  2823.  
  2824. if(Arrete[0] == ""){
  2825. BooJR = true;
  2826. }
  2827.  
  2828. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.JAUNE) {
  2829. Resolution = Resolution + JVJ;
  2830. //System.out.println(JVJ);
  2831. string_solv.add("JVJ");
  2832. string_solv.add(JVJ);
  2833. prochainXA = Character.getNumericValue(JVJP.charAt(0));
  2834. prochainYA = Character.getNumericValue(JVJP.charAt(1));
  2835. prochainX2A = Character.getNumericValue(JVVP.charAt(0));
  2836. prochainY2A = Character.getNumericValue(JVVP.charAt(1));
  2837.  
  2838.  
  2839. prochaineCouleurA = "JAUNE";
  2840. prochaineCouleur2A = "VERT";
  2841.  
  2842. Arrete[0] = "";
  2843. }
  2844. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.VERT) {
  2845. Resolution = Resolution + JVV;
  2846. //System.out.println(JVV);
  2847. string_solv.add("JVV");
  2848. string_solv.add(JVV);
  2849. prochainXA = Character.getNumericValue(JVVP.charAt(0));
  2850. prochainYA = Character.getNumericValue(JVVP.charAt(1));
  2851. prochainX2A = Character.getNumericValue(JVJP.charAt(0));
  2852. prochainY2A = Character.getNumericValue(JVJP.charAt(1));
  2853.  
  2854.  
  2855. prochaineCouleurA = "VERT";
  2856. prochaineCouleur2A = "JAUNE";
  2857.  
  2858. Arrete[0] = "";
  2859.  
  2860. }
  2861.  
  2862. }
  2863.  
  2864. /*
  2865. * CAS DE L'ARETE JB
  2866. */
  2867.  
  2868. else if(BufferA.contient(CouleurEnum.JAUNE,CouleurEnum.BLEU)) {
  2869. //System.out.println("JB");
  2870. if(Arrete[1] == ""){
  2871. BooJR = true;
  2872. }
  2873. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.JAUNE) {
  2874. Resolution = Resolution + JBJ;
  2875. //System.out.println(JBJ);
  2876. string_solv.add("JBJ");
  2877. string_solv.add(JBJ);
  2878. prochainXA = Character.getNumericValue(JBJP.charAt(0));
  2879. prochainYA = Character.getNumericValue(JBJP.charAt(1));
  2880. prochainX2A = Character.getNumericValue(JBBP.charAt(0));
  2881. prochainY2A = Character.getNumericValue(JBBP.charAt(1));
  2882.  
  2883.  
  2884. prochaineCouleurA = "JAUNE";
  2885. prochaineCouleur2A = "BLEU";
  2886.  
  2887. Arrete[1] = "";
  2888. }
  2889. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.BLEU) {
  2890. Resolution = Resolution + JBB;
  2891. //System.out.println(JBB);
  2892. string_solv.add("JBB");
  2893. string_solv.add(JBB);
  2894. prochainXA = Character.getNumericValue(JBBP.charAt(0));
  2895. prochainYA = Character.getNumericValue(JBBP.charAt(1));
  2896. prochainX2A = Character.getNumericValue(JBJP.charAt(0));
  2897. prochainY2A = Character.getNumericValue(JBJP.charAt(1));
  2898.  
  2899.  
  2900. prochaineCouleurA = "BLEU";
  2901. prochaineCouleur2A = "JAUNE";
  2902.  
  2903. Arrete[1] = "";
  2904.  
  2905. }
  2906.  
  2907. }
  2908.  
  2909. /*
  2910. * CAS DE L'ARETE JO
  2911. */
  2912.  
  2913. else if(BufferA.contient(CouleurEnum.JAUNE,CouleurEnum.ORANGE)) {
  2914. //System.out.println("JO");
  2915. if(Arrete[2] == ""){
  2916. BooJR = true;
  2917. }
  2918. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.JAUNE) {
  2919. Resolution = Resolution + JOJ;
  2920. //System.out.println(JOJ);
  2921. string_solv.add("JOJ");
  2922. string_solv.add(JOJ);
  2923. prochainXA = Character.getNumericValue(JOJP.charAt(0));
  2924. prochainYA = Character.getNumericValue(JOJP.charAt(1));
  2925. prochainX2A = Character.getNumericValue(JOOP.charAt(0));
  2926. prochainY2A = Character.getNumericValue(JOOP.charAt(1));
  2927.  
  2928.  
  2929. prochaineCouleurA = "JAUNE";
  2930. prochaineCouleur2A = "ORANGE";
  2931.  
  2932. Arrete[2] = "";
  2933. }
  2934. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.ORANGE) {
  2935. Resolution = Resolution + JOO;
  2936. //System.out.println(JOO);
  2937. string_solv.add("JOO");
  2938. string_solv.add(JOO);
  2939. prochainXA = Character.getNumericValue(JOOP.charAt(0));
  2940. prochainYA = Character.getNumericValue(JOOP.charAt(1));
  2941. prochainX2A = Character.getNumericValue(JOJP.charAt(0));
  2942. prochainY2A = Character.getNumericValue(JOJP.charAt(1));
  2943.  
  2944.  
  2945. prochaineCouleurA = "ORANGE";
  2946. prochaineCouleur2A = "JAUNE";
  2947.  
  2948. Arrete[2] = "";
  2949.  
  2950. }
  2951.  
  2952. }
  2953.  
  2954. /*
  2955. * CAS DE L'ARETE JO
  2956. */
  2957.  
  2958. else if(BufferA.contient(CouleurEnum.VERT,CouleurEnum.ORANGE)) {
  2959. //System.out.println("VO");
  2960. if(Arrete[3] == ""){
  2961. BooJR = true;
  2962. }
  2963. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.VERT) {
  2964. Resolution = Resolution + VOV;
  2965. //System.out.println(VOV);
  2966. string_solv.add("VOV");
  2967. string_solv.add(VOV);
  2968. prochainXA = Character.getNumericValue(VOVP.charAt(0));
  2969. prochainYA = Character.getNumericValue(VOVP.charAt(1));
  2970. prochainX2A = Character.getNumericValue(VOOP.charAt(0));
  2971. prochainY2A = Character.getNumericValue(VOOP.charAt(1));
  2972.  
  2973.  
  2974. prochaineCouleurA = "VERT";
  2975. prochaineCouleur2A = "ORANGE";
  2976.  
  2977. Arrete[3] = "";
  2978. }
  2979. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.ORANGE) {
  2980.  
  2981. Resolution = Resolution + VOO;
  2982. //System.out.println(VOO);
  2983. string_solv.add("VOO");
  2984. string_solv.add(VOO);
  2985. prochainXA = Character.getNumericValue(VOOP.charAt(0));
  2986. prochainYA = Character.getNumericValue(VOOP.charAt(1));
  2987. prochainX2A = Character.getNumericValue(VOVP.charAt(0));
  2988. prochainY2A = Character.getNumericValue(VOVP.charAt(1));
  2989.  
  2990.  
  2991. prochaineCouleurA = "ORANGE";
  2992. prochaineCouleur2A = "VERT";
  2993.  
  2994. Arrete[3] = "";
  2995.  
  2996. }
  2997.  
  2998. }
  2999. else if(BufferA.contient(CouleurEnum.ROUGE,CouleurEnum.VERT)) {
  3000. //System.out.println("RV");
  3001. if(Arrete[4] == ""){
  3002. BooJR = true;
  3003. }
  3004. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.ROUGE) {
  3005. Resolution = Resolution + RVR;
  3006. //System.out.println(RVR);
  3007. string_solv.add("RVR");
  3008. string_solv.add(RVR);
  3009. prochainXA = Character.getNumericValue(RVRP.charAt(0));
  3010. prochainYA = Character.getNumericValue(RVRP.charAt(1));
  3011. prochainX2A = Character.getNumericValue(RVVP.charAt(0));
  3012. prochainY2A = Character.getNumericValue(RVVP.charAt(1));
  3013.  
  3014.  
  3015. prochaineCouleurA = "ROUGE";
  3016. prochaineCouleur2A = "VERT";
  3017.  
  3018. Arrete[4] = "";
  3019. }
  3020. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.VERT) {
  3021. Resolution = Resolution + RVV;
  3022. //System.out.println(RVV);
  3023. string_solv.add("RVV");
  3024. string_solv.add(RVV);
  3025. prochainXA = Character.getNumericValue(RVVP.charAt(0));
  3026. prochainYA = Character.getNumericValue(RVVP.charAt(1));
  3027. prochainX2A = Character.getNumericValue(RVRP.charAt(0));
  3028. prochainY2A = Character.getNumericValue(RVRP.charAt(1));
  3029.  
  3030.  
  3031. prochaineCouleurA = "VERT";
  3032. prochaineCouleur2A = "ROUGE";
  3033.  
  3034. Arrete[4] = "";
  3035.  
  3036. }
  3037.  
  3038. }
  3039. else if(BufferA.contient(CouleurEnum.BLEU,CouleurEnum.ROUGE)) {
  3040. //System.out.println("BR");
  3041. if(Arrete[5] == ""){
  3042. BooJR = true;
  3043. }
  3044. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.BLEU) {
  3045. Resolution = Resolution + BRB;
  3046. //System.out.println(BRB);
  3047. string_solv.add("BRB");
  3048. string_solv.add(BRB);
  3049. prochainXA = Character.getNumericValue(BRBP.charAt(0));
  3050. prochainYA = Character.getNumericValue(BRBP.charAt(1));
  3051. prochainX2A = Character.getNumericValue(BRRP.charAt(0));
  3052. prochainY2A = Character.getNumericValue(BRRP.charAt(1));
  3053.  
  3054.  
  3055. prochaineCouleurA = "BLEU";
  3056. prochaineCouleur2A = "ROUGE";
  3057.  
  3058. Arrete[5] = "";
  3059. }
  3060. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.ROUGE) {
  3061. Resolution = Resolution + BRR;
  3062. //System.out.println(BRR);
  3063. string_solv.add("BRR");
  3064. string_solv.add(BRR);
  3065. prochainXA = Character.getNumericValue(BRRP.charAt(0));
  3066. prochainYA = Character.getNumericValue(BRRP.charAt(1));
  3067. prochainX2A = Character.getNumericValue(BRBP.charAt(0));
  3068. prochainY2A = Character.getNumericValue(BRBP.charAt(1));
  3069.  
  3070.  
  3071. prochaineCouleurA = "ROUGE";
  3072. prochaineCouleur2A = "BLEU";
  3073.  
  3074. Arrete[5] = "";
  3075.  
  3076. }
  3077.  
  3078. }
  3079. else if(BufferA.contient(CouleurEnum.BLEU,CouleurEnum.ORANGE)) {
  3080. //System.out.println("BO");
  3081. if(Arrete[6] == ""){
  3082. BooJR = true;
  3083. }
  3084. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.BLEU) {
  3085. Resolution = Resolution + BOB;
  3086. //System.out.println(BOB);
  3087. string_solv.add("BOB");
  3088. string_solv.add(BOB);
  3089. prochainXA = Character.getNumericValue(BOBP.charAt(0));
  3090. prochainYA = Character.getNumericValue(BOBP.charAt(1));
  3091. prochainX2A = Character.getNumericValue(BOOP.charAt(0));
  3092. prochainY2A = Character.getNumericValue(BOOP.charAt(1));
  3093.  
  3094.  
  3095. prochaineCouleurA = "BLEU";
  3096. prochaineCouleur2A = "ORANGE";
  3097.  
  3098. Arrete[6] = "";
  3099. }
  3100. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.ORANGE) {
  3101. Resolution = Resolution + BOO;
  3102. //System.out.println(BOO);
  3103. string_solv.add("BOO");
  3104. string_solv.add(BOO);
  3105. prochainXA = Character.getNumericValue(BOOP.charAt(0));
  3106. prochainYA = Character.getNumericValue(BOOP.charAt(1));
  3107. prochainX2A = Character.getNumericValue(BOBP.charAt(0));
  3108. prochainY2A = Character.getNumericValue(BOBP.charAt(1));
  3109.  
  3110.  
  3111. prochaineCouleurA = "ORANGE";
  3112. prochaineCouleur2A = "BLEU";
  3113.  
  3114. Arrete[6] = "";
  3115.  
  3116. }
  3117.  
  3118. }
  3119. else if(BufferA.contient(CouleurEnum.BLEU,CouleurEnum.BLANC)) {
  3120. //System.out.println("BBl");
  3121. if(Arrete[7] == ""){
  3122. BooJR = true;
  3123. }
  3124. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.BLEU) {
  3125. Resolution = Resolution + BBlB;
  3126. //System.out.println(BBlB);
  3127. string_solv.add("BBlB");
  3128. string_solv.add(BBlB);
  3129. prochainXA = Character.getNumericValue(BBlBP.charAt(0));
  3130. prochainYA = Character.getNumericValue(BBlBP.charAt(1));
  3131. prochainX2A = Character.getNumericValue(BBlBlP.charAt(0));
  3132. prochainY2A = Character.getNumericValue(BBlBlP.charAt(1));
  3133.  
  3134.  
  3135. prochaineCouleurA = "BLEU";
  3136. prochaineCouleur2A = "BLANC";
  3137.  
  3138. Arrete[7] = "";
  3139. }
  3140. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.BLANC) {
  3141. Resolution = Resolution + BBlBl;
  3142. //System.out.println(BBlBl);
  3143. string_solv.add("BBlBl");
  3144. string_solv.add(BBlBl);
  3145. prochainXA = Character.getNumericValue(BBlBlP.charAt(0));
  3146. prochainYA = Character.getNumericValue(BBlBlP.charAt(1));
  3147. prochainX2A = Character.getNumericValue(BBlBP.charAt(0));
  3148. prochainY2A = Character.getNumericValue(BBlBP.charAt(1));
  3149.  
  3150.  
  3151. prochaineCouleurA = "BLANC";
  3152. prochaineCouleur2A = "BLEU";
  3153.  
  3154. Arrete[7] = "";
  3155.  
  3156. }
  3157.  
  3158. }
  3159. else if(BufferA.contient(CouleurEnum.ROUGE,CouleurEnum.BLANC)) {
  3160. //System.out.println("RBl");
  3161. if(Arrete[8] == ""){
  3162. BooJR = true;
  3163. }
  3164. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.ROUGE) {
  3165. Resolution = Resolution + RBlR;
  3166. //System.out.println(RBlR);
  3167. string_solv.add("RBlR");
  3168. string_solv.add(RBlR);
  3169. prochainXA = Character.getNumericValue(RBlRP.charAt(0));
  3170. prochainYA = Character.getNumericValue(RBlRP.charAt(1));
  3171. prochainX2A = Character.getNumericValue(RBlBlP.charAt(0));
  3172. prochainY2A = Character.getNumericValue(RBlBlP.charAt(1));
  3173.  
  3174.  
  3175. prochaineCouleurA = "ROUGE";
  3176. prochaineCouleur2A = "BLANC";
  3177.  
  3178. Arrete[8] = "";
  3179. }
  3180. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.BLANC) {
  3181. Resolution = Resolution + RBlBl;
  3182. //System.out.println(RBlBl);
  3183. string_solv.add("RBBl");
  3184. string_solv.add(RBlBl);
  3185. prochainXA = Character.getNumericValue(RBlBlP.charAt(0));
  3186. prochainYA = Character.getNumericValue(RBlBlP.charAt(1));
  3187. prochainX2A = Character.getNumericValue(RBlRP.charAt(0));
  3188. prochainY2A = Character.getNumericValue(RBlRP.charAt(1));
  3189.  
  3190.  
  3191. prochaineCouleurA = "BLANC";
  3192. prochaineCouleur2A = "ROUGE";
  3193.  
  3194. Arrete[8] = "";
  3195.  
  3196. }
  3197.  
  3198. }
  3199. else if(BufferA.contient(CouleurEnum.VERT,CouleurEnum.BLANC)) {
  3200. //System.out.println("VBl");
  3201. if(Arrete[9] == ""){
  3202. BooJR = true;
  3203. }
  3204. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.VERT) {
  3205. Resolution = Resolution + VBlV;
  3206. //System.out.println(VBlV);
  3207. string_solv.add("VBlV");
  3208. string_solv.add(VBlV);
  3209. prochainXA = Character.getNumericValue(VBlVP.charAt(0));
  3210. prochainYA = Character.getNumericValue(VBlVP.charAt(1));
  3211. prochainX2A = Character.getNumericValue(VBlBlP.charAt(0));
  3212. prochainY2A = Character.getNumericValue(VBlBlP.charAt(1));
  3213.  
  3214.  
  3215. prochaineCouleurA = "VERT";
  3216. prochaineCouleur2A = "BLANC";
  3217.  
  3218. Arrete[9] = "";
  3219. }
  3220. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.BLANC) {
  3221. Resolution = Resolution + VBlBl;
  3222. //System.out.println(VBlBl);
  3223. string_solv.add("VBlBl");
  3224. string_solv.add(VBlBl);
  3225. prochainXA = Character.getNumericValue(VBlBlP.charAt(0));
  3226. prochainYA = Character.getNumericValue(VBlBlP.charAt(1));
  3227. prochainX2A = Character.getNumericValue(VBlVP.charAt(0));
  3228. prochainY2A = Character.getNumericValue(VBlVP.charAt(1));
  3229.  
  3230.  
  3231. prochaineCouleurA = "BLANC";
  3232. prochaineCouleur2A = "VERT";
  3233.  
  3234. Arrete[9] = "";
  3235.  
  3236. }
  3237.  
  3238. }
  3239. else if(BufferA.contient(CouleurEnum.ORANGE,CouleurEnum.BLANC)) {
  3240. //System.out.println("OBl");
  3241. if(Arrete[10] == ""){
  3242. BooJR = true;
  3243. }
  3244. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.ORANGE) {
  3245. Resolution = Resolution + OBlO;
  3246. //System.out.println(OBlO);
  3247. string_solv.add("OBlO");
  3248. string_solv.add(OBlO);
  3249. prochainXA = Character.getNumericValue(OBlOP.charAt(0));
  3250. prochainYA = Character.getNumericValue(OBlOP.charAt(1));
  3251. prochainX2A = Character.getNumericValue(OBlBlP.charAt(0));
  3252. prochainY2A = Character.getNumericValue(OBlBlP.charAt(1));
  3253.  
  3254.  
  3255. prochaineCouleurA = "ORANGE";
  3256. prochaineCouleur2A = "BLANC";
  3257.  
  3258. Arrete[10] = "";
  3259. }
  3260. else if(TabRef[prochainXA][prochainYA] == CouleurEnum.BLANC) {
  3261. Resolution = Resolution + OBlBl;
  3262. //System.out.println(OBlBl);
  3263. string_solv.add("OBlBl");
  3264. string_solv.add(OBlBl);
  3265. prochainXA = Character.getNumericValue(OBlBlP.charAt(0));
  3266. prochainYA = Character.getNumericValue(OBlBlP.charAt(1));
  3267. prochainX2A = Character.getNumericValue(OBlOP.charAt(0));
  3268. prochainY2A = Character.getNumericValue(OBlOP.charAt(1));
  3269.  
  3270.  
  3271. prochaineCouleurA = "BLANC";
  3272. prochaineCouleur2A = "ORANGE";
  3273.  
  3274. Arrete[10] = "";
  3275.  
  3276. }
  3277. }
  3278.  
  3279. /*
  3280. * CAS DU COIN JR
  3281. */
  3282.  
  3283. if(BufferA.contient(CouleurEnum.JAUNE,CouleurEnum.ROUGE) || BooJR == true) {
  3284. BooJR = false;
  3285. //System.out.println("JR");
  3286. if(Arrete[0] != ""){
  3287. prochainXA = Character.getNumericValue(JVJP.charAt(0));
  3288. prochainYA = Character.getNumericValue(JVJP.charAt(1));
  3289. prochainX2A = Character.getNumericValue(JVVP.charAt(0));
  3290. prochainY2A = Character.getNumericValue(JVVP.charAt(1));
  3291.  
  3292.  
  3293. prochaineCouleurA = "JAUNE";
  3294. prochaineCouleur2A = "VERT";
  3295.  
  3296. Resolution = Resolution + JVJ;
  3297. //System.out.println(JVJ);
  3298. string_solv.add(JVJ);
  3299. }
  3300. else if(Arrete[1] != ""){
  3301. prochainXA = Character.getNumericValue(JBJP.charAt(0));
  3302. prochainYA = Character.getNumericValue(JBJP.charAt(1));
  3303. prochainX2A = Character.getNumericValue(JBBP.charAt(0));
  3304. prochainY2A = Character.getNumericValue(JBBP.charAt(1));
  3305.  
  3306.  
  3307. prochaineCouleurA = "JAUNE";
  3308. prochaineCouleur2A = "BLEU";
  3309.  
  3310. Resolution = Resolution + JBJ;
  3311. //System.out.println(JBJ);
  3312. string_solv.add(JBJ);
  3313. }
  3314. else if(Arrete[2] != ""){
  3315. prochainXA = Character.getNumericValue(JOJP.charAt(0));
  3316. prochainYA = Character.getNumericValue(JOJP.charAt(1));
  3317. prochainX2A = Character.getNumericValue(JOOP.charAt(0));
  3318. prochainY2A = Character.getNumericValue(JOOP.charAt(1));
  3319.  
  3320.  
  3321. prochaineCouleurA = "JAUNE";
  3322. prochaineCouleur2A = "ORANGE";
  3323.  
  3324. Resolution = Resolution + JOJ;
  3325. //System.out.println(JOJ);
  3326. string_solv.add(JOJ);
  3327. }
  3328. else if(Arrete[3] != ""){
  3329. prochainXA = Character.getNumericValue(VOVP.charAt(0));
  3330. prochainYA = Character.getNumericValue(VOVP.charAt(1));
  3331. prochainX2A = Character.getNumericValue(VOOP.charAt(0));
  3332. prochainY2A = Character.getNumericValue(VOOP.charAt(1));
  3333.  
  3334.  
  3335. prochaineCouleurA = "VERT";
  3336. prochaineCouleur2A = "ORANGE";
  3337.  
  3338. Resolution = Resolution + VOV;
  3339. //System.out.println(VOV);
  3340. string_solv.add(VOV);
  3341. }
  3342. else if(Arrete[4] != ""){
  3343. prochainXA = Character.getNumericValue(RVRP.charAt(0));
  3344. prochainYA = Character.getNumericValue(RVRP.charAt(1));
  3345. prochainX2A = Character.getNumericValue(RVVP.charAt(0));
  3346. prochainY2A = Character.getNumericValue(RVVP.charAt(1));
  3347.  
  3348.  
  3349. prochaineCouleurA = "ROUGE";
  3350. prochaineCouleur2A = "VERT";
  3351.  
  3352. Resolution = Resolution + RVR;
  3353. //System.out.println(RVR);
  3354. string_solv.add(RVR);
  3355. }
  3356. else if(Arrete[5] != ""){
  3357. prochainXA = Character.getNumericValue(BRBP.charAt(0));
  3358. prochainYA = Character.getNumericValue(BRBP.charAt(1));
  3359. prochainX2A = Character.getNumericValue(BRRP.charAt(0));
  3360. prochainY2A = Character.getNumericValue(BRRP.charAt(1));
  3361.  
  3362.  
  3363. prochaineCouleurA = "BLEU";
  3364. prochaineCouleur2A = "ROUGE";
  3365.  
  3366. Resolution = Resolution + BRB;
  3367. //System.out.println(BRB);
  3368. string_solv.add(BRB);
  3369. }
  3370. else if(Arrete[6] != ""){
  3371. prochainXA = Character.getNumericValue(BOBP.charAt(0));
  3372. prochainYA = Character.getNumericValue(BOBP.charAt(1));
  3373. prochainX2A = Character.getNumericValue(BOOP.charAt(0));
  3374. prochainY2A = Character.getNumericValue(BOOP.charAt(1));
  3375.  
  3376.  
  3377. prochaineCouleurA = "BLEU";
  3378. prochaineCouleur2A = "ORANGE";
  3379.  
  3380. Resolution = Resolution + BOB;
  3381. //System.out.println(BOB);
  3382. string_solv.add(BOB);
  3383. }
  3384. else if(Arrete[7] != ""){
  3385. prochainXA = Character.getNumericValue(BBlBP.charAt(0));
  3386. prochainYA = Character.getNumericValue(BBlBP.charAt(1));
  3387. prochainX2A = Character.getNumericValue(BBlBlP.charAt(0));
  3388. prochainY2A = Character.getNumericValue(BBlBlP.charAt(1));
  3389.  
  3390.  
  3391. prochaineCouleurA = "BLEU";
  3392. prochaineCouleur2A = "BLANC";
  3393.  
  3394. Resolution = Resolution + BBlB;
  3395. //System.out.println(BBlB);
  3396. string_solv.add(BBlB);
  3397. }
  3398. else if(Arrete[8] != ""){
  3399. prochainXA = Character.getNumericValue(RBlRP.charAt(0));
  3400. prochainYA = Character.getNumericValue(RBlRP.charAt(1));
  3401. prochainX2A = Character.getNumericValue(RBlBlP.charAt(0));
  3402. prochainY2A = Character.getNumericValue(RBlBlP.charAt(1));
  3403.  
  3404.  
  3405. prochaineCouleurA = "ROUGE";
  3406. prochaineCouleur2A = "BLANC";
  3407.  
  3408. Resolution = Resolution + RBlR;
  3409. //System.out.println(RBlR);
  3410. string_solv.add(RBlR);
  3411. }
  3412. else if(Arrete[9] != ""){
  3413. prochainXA = Character.getNumericValue(VBlVP.charAt(0));
  3414. prochainYA = Character.getNumericValue(VBlVP.charAt(1));
  3415. prochainX2A = Character.getNumericValue(VBlBlP.charAt(0));
  3416. prochainY2A = Character.getNumericValue(VBlBlP.charAt(1));
  3417.  
  3418.  
  3419. prochaineCouleurA = "VERT";
  3420. prochaineCouleur2A = "BLANC";
  3421.  
  3422. Resolution = Resolution + VBlV;
  3423. //System.out.println(VBlV);
  3424. string_solv.add(VBlV);
  3425. }
  3426. else if(Arrete[10] != ""){
  3427. prochainXA = Character.getNumericValue(OBlOP.charAt(0));
  3428. prochainYA = Character.getNumericValue(OBlOP.charAt(1));
  3429. prochainX2A = Character.getNumericValue(OBlBlP.charAt(0));
  3430. prochainY2A = Character.getNumericValue(OBlBlP.charAt(1));
  3431.  
  3432.  
  3433. prochaineCouleurA = "ORANGE";
  3434. prochaineCouleur2A = "BLANC";
  3435.  
  3436. Resolution = Resolution + OBlO;
  3437. //System.out.println(OBlO);
  3438. string_solv.add(OBlO);
  3439. }
  3440. }
  3441. }
  3442.  
  3443. /*
  3444. * WHILE POUR LES ARETES BIEN PLACEES
  3445. */
  3446.  
  3447. while(!(ArreteOri.isEmpty())){
  3448. if(ArreteOri.get(0) == "JV"){
  3449. Resolution = Resolution + JVF;
  3450. //System.out.println(JVF);
  3451. string_solv.add(JVF);
  3452. ArreteOri.remove("JV");
  3453. }
  3454. else if(ArreteOri.get(0) == "JB"){
  3455. Resolution = Resolution + JBF;
  3456. //System.out.println(JBF);
  3457. string_solv.add(JBF);
  3458. ArreteOri.remove("JB");
  3459. }
  3460. else if(ArreteOri.get(0) == "JO"){
  3461. Resolution = Resolution + JOF;
  3462. //System.out.println(JOF);
  3463. string_solv.add(JOF);
  3464. ArreteOri.remove("JO");
  3465. }
  3466. else if(ArreteOri.get(0) == "VO"){
  3467. Resolution = Resolution + VOF;
  3468. //System.out.println(VOF);
  3469. string_solv.add(VOF);
  3470. ArreteOri.remove("VO");
  3471. }
  3472. else if(ArreteOri.get(0) == "RV"){
  3473. Resolution = Resolution + RVF;
  3474. //System.out.println(RVF);
  3475. string_solv.add(RVF);
  3476. ArreteOri.remove("RV");
  3477. }
  3478. else if(ArreteOri.get(0) == "BR"){
  3479. Resolution = Resolution + BRF;
  3480. //System.out.println(BRF);
  3481. string_solv.add(BRF);
  3482. ArreteOri.remove("BR");
  3483. }
  3484. else if(ArreteOri.get(0) == "BO"){
  3485. Resolution = Resolution + BOF;
  3486. //System.out.println(BOF);
  3487. string_solv.add(BOF);
  3488. ArreteOri.remove("BO");
  3489. }
  3490. else if(ArreteOri.get(0) == "BBl"){
  3491. Resolution = Resolution + BBlF;
  3492. //System.out.println(BBlF);
  3493. string_solv.add(BBlF);
  3494. ArreteOri.remove("BBl");
  3495. }
  3496. else if(ArreteOri.get(0) == "RBl"){
  3497. Resolution = Resolution + RBlF;
  3498. //System.out.println(RBlF);
  3499. string_solv.add(RBlF);
  3500. ArreteOri.remove("RBl");
  3501. }
  3502. else if(ArreteOri.get(0) == "VBl"){
  3503. Resolution = Resolution + VBlF;
  3504. //System.out.println(VBlF);
  3505. string_solv.add(VBlF);
  3506. ArreteOri.remove("VBl");
  3507. }
  3508. else if(ArreteOri.get(0) == "OBl"){
  3509. Resolution = Resolution + OBlF;
  3510. //System.out.println(OBlF);
  3511. string_solv.add(OBlF);
  3512. ArreteOri.remove("OBl");
  3513. }
  3514. }
  3515.  
  3516. /*
  3517. *
  3518. * TRANSFORMATION/OPTIMISATION
  3519. *
  3520. */
  3521.  
  3522. /*
  3523. * TRANSFORMATION
  3524. */
  3525.  
  3526. arduinoResolution = convert(Resolution);
  3527.  
  3528. /*
  3529. * OPTIMISATION
  3530. */
  3531.  
  3532. optiResolution = optimize(arduinoResolution) + '/';
  3533.  
  3534. if(i == 0) {
  3535. System.out.println(optiResolution.length());
  3536. reducResolution = optiResolution;
  3537. }
  3538.  
  3539. if(optiResolution.length() < reducResolution.length()) {
  3540.  
  3541. reducResolution = optiResolution;
  3542. reducResolution1 = Resolution;
  3543. reducResolution2 = arduinoResolution;
  3544. final_cours = cours;
  3545. fin_optiMov = optiMov;
  3546. fin_string_solv = string_solv;
  3547. System.out.println(optiMov);
  3548. System.out.println(fin_string_solv);
  3549. }
  3550.  
  3551. string_solv.clear();
  3552.  
  3553. BooJVO = false;
  3554. BooJR = false;
  3555.  
  3556. Resolution = "";
  3557. arduinoResolution = "";
  3558. optiResolution = "";
  3559. optiInt = 0;
  3560.  
  3561. prochaineCouleur = "JAUNE";
  3562. prochaineCouleur2 = "VERT";
  3563. prochaineCouleur3 = "ORANGE";
  3564.  
  3565. prochainX = 0;
  3566. prochainY = 0;
  3567. prochainX2 = 0;
  3568. prochainY2 = 2;
  3569. prochainX3 = 0;
  3570. prochainY3 = 0;
  3571.  
  3572. Coin[0] = "JRV";
  3573. Coin[1] = "JBR";
  3574. Coin[2] = "JBO";
  3575. Coin[3] = "BOBl";
  3576. Coin[4] = "BRBl";
  3577. Coin[5] = "RVBl";
  3578. Coin[6] = "VOBl";
  3579.  
  3580. CoinOri.clear();
  3581.  
  3582. prochaineCouleurA = "JAUNE";
  3583. prochaineCouleur2A = "ROUGE";
  3584.  
  3585. prochainXA = 1;
  3586. prochainYA = 2;
  3587. prochainX2A = 0;
  3588. prochainY2A = 1;
  3589.  
  3590. Arrete[0] = "JV";
  3591. Arrete[1] = "JB";
  3592. Arrete[2] = "JO";
  3593. Arrete[3] = "VO";
  3594. Arrete[4] = "RV";
  3595. Arrete[5] = "BR";
  3596. Arrete[6] = "BO";
  3597. Arrete[7] = "BBl";
  3598. Arrete[8] = "RBl";
  3599. Arrete[9] = "VBl";
  3600. Arrete[10] = "OBl";
  3601.  
  3602. ArreteOri.clear();
  3603.  
  3604. i1 = 1;
  3605. i2 = 2;
  3606. i3 = 3;
  3607. paireimpaire = 0;
  3608. test = 0;
  3609.  
  3610. }
  3611.  
  3612. optiMov = "";
  3613. face_rot = 0;
  3614. mul_face_rot = 0;
  3615.  
  3616. /*
  3617. *
  3618. * INITIALISATION DE LA CONNECTION
  3619. *
  3620. */
  3621.  
  3622. SerialPort[] computerPorts = SerialPort.getCommPorts();
  3623.  
  3624. SerialPort selectedPort = null;
  3625.  
  3626. for (SerialPort p : computerPorts) {
  3627. if (p.getSystemPortName().equals("COM3")) {
  3628. selectedPort = p;
  3629. }
  3630. }
  3631.  
  3632. if (selectedPort == null) {
  3633. return;
  3634. }
  3635.  
  3636. else if (selectedPort.openPort()) {
  3637. System.out.println(selectedPort.getSystemPortName() + " s'est ouvert correctement");
  3638. }
  3639.  
  3640. else {
  3641. System.out.println(selectedPort.getSystemPortName() + " n'a pas réussi à s'ouvrir");
  3642. return;
  3643. }
  3644.  
  3645. pw = new PrintWriter(selectedPort.getOutputStream());
  3646. try {
  3647. Thread.sleep(3000);
  3648. } catch (InterruptedException e2) {
  3649. e2.printStackTrace();
  3650. }
  3651.  
  3652. /*
  3653. *
  3654. * ENVOI
  3655. *
  3656. */
  3657.  
  3658. System.out.println(fin_string_solv);
  3659.  
  3660. System.out.println(fin_optiMov);
  3661.  
  3662. System.out.println(final_cours.length());
  3663. System.out.println(reducResolution1);
  3664. System.out.println(reducResolution2);
  3665. reducResolution = fin_optiMov + reducResolution;
  3666. System.out.println(reducResolution);
  3667. int lastChar = reducResolution.length();
  3668. System.out.println(lastChar);
  3669.  
  3670. for(int y = 0; y < reducResolution.length(); y++) {
  3671. pw.write(reducResolution.charAt(y));
  3672. pw.flush();
  3673. try {
  3674. Thread.sleep(1);
  3675. } catch (InterruptedException e1) {
  3676. e1.printStackTrace();
  3677. }
  3678. }
  3679.  
  3680.  
  3681. selectedPort.closePort();
  3682.  
  3683. //System.out.println("Resolution envoyée");
  3684.  
  3685.  
  3686.  
  3687. }
  3688. }
  3689.  
  3690. public static BufferedImage Mat2BufferedImage(Mat m) {
  3691. //source: http://answers.opencv.org/question/10344/opencv-java-load-image-to-gui/
  3692. //Fastest code
  3693. //The output can be assigned either to a BufferedImage or to an Image
  3694.  
  3695. int type = BufferedImage.TYPE_BYTE_GRAY;
  3696. if ( m.channels() > 1 ) {
  3697. type = BufferedImage.TYPE_3BYTE_BGR;
  3698. }
  3699. int bufferSize = m.channels()*m.cols()*m.rows();
  3700. byte [] b = new byte[bufferSize];
  3701. m.get(0,0,b); // get all the pixels
  3702. BufferedImage image = new BufferedImage(m.cols(),m.rows(), type);
  3703. final byte[] targetPixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
  3704. System.arraycopy(b, 0, targetPixels, 0, b.length);
  3705. return image;
  3706. }
  3707.  
  3708. /*
  3709. * R
  3710. */
  3711.  
  3712. public void RMove () {
  3713.  
  3714. CouleurEnum buffer = null;
  3715.  
  3716. buffer = FaceJaune[2][2];
  3717. FaceJaune[2][2] = FaceBleu[2][2];
  3718. FaceBleu[2][2] = FaceBlanc[2][2];
  3719. FaceBlanc[2][2] = FaceVert[0][0];
  3720. FaceVert[0][0] = buffer;
  3721.  
  3722. buffer = FaceJaune[1][2];
  3723. FaceJaune[1][2] = FaceBleu[1][2];
  3724. FaceBleu[1][2] = FaceBlanc[1][2];
  3725. FaceBlanc[1][2] = FaceVert[1][0];
  3726. FaceVert[1][0] = buffer;
  3727.  
  3728. buffer = FaceJaune[0][2];
  3729. FaceJaune[0][2] = FaceBleu[0][2];
  3730. FaceBleu[0][2] = FaceBlanc[0][2];
  3731. FaceBlanc[0][2] = FaceVert[2][0];
  3732. FaceVert[2][0] = buffer;
  3733.  
  3734. buffer = FaceRouge[0][0];
  3735. FaceRouge[0][0] = FaceRouge[2][0];
  3736. FaceRouge[2][0] = FaceRouge[2][2];
  3737. FaceRouge[2][2] = FaceRouge[0][2];
  3738. FaceRouge[0][2] = buffer;
  3739.  
  3740. buffer = FaceRouge[0][1];
  3741. FaceRouge[0][1] = FaceRouge[1][0];
  3742. FaceRouge[1][0] = FaceRouge[2][1];
  3743. FaceRouge[2][1] = FaceRouge[1][2];
  3744. FaceRouge[1][2] = buffer;
  3745. }
  3746.  
  3747. /*
  3748. * R'
  3749. */
  3750.  
  3751. public void RPMove () {
  3752.  
  3753. CouleurEnum buffer = null;
  3754.  
  3755. buffer = FaceJaune[2][2];
  3756. FaceJaune[2][2] = FaceVert[0][0];
  3757. FaceVert[0][0] = FaceBlanc[2][2];
  3758. FaceBlanc[2][2] = FaceBleu[2][2];
  3759. FaceBleu[2][2] = buffer;
  3760.  
  3761. buffer = FaceJaune[1][2];
  3762. FaceJaune[1][2] = FaceVert[1][0];
  3763. FaceVert[1][0] = FaceBlanc[1][2];
  3764. FaceBlanc[1][2] = FaceBleu[1][2];
  3765. FaceBleu[1][2] = buffer;
  3766.  
  3767. buffer = FaceJaune[0][2];
  3768. FaceJaune[0][2] = FaceVert[2][0];
  3769. FaceVert[2][0] = FaceBlanc[0][2];
  3770. FaceBlanc[0][2] = FaceBleu[0][2];
  3771. FaceBleu[0][2] = buffer;
  3772.  
  3773. buffer = FaceRouge[0][0];
  3774. FaceRouge[0][0] = FaceRouge[0][2];
  3775. FaceRouge[0][2] = FaceRouge[2][2];
  3776. FaceRouge[2][2] = FaceRouge[2][0];
  3777. FaceRouge[2][0] = buffer;
  3778.  
  3779. buffer = FaceRouge[0][1];
  3780. FaceRouge[0][1] = FaceRouge[1][2];
  3781. FaceRouge[1][2] = FaceRouge[2][1];
  3782. FaceRouge[2][1] = FaceRouge[1][0];
  3783. FaceRouge[1][0] = buffer;
  3784. }
  3785.  
  3786. public void R2Move() {
  3787.  
  3788. CouleurEnum buffer = null;
  3789.  
  3790. buffer = FaceJaune[2][2];
  3791. FaceJaune[2][2] = FaceBleu[2][2];
  3792. FaceBleu[2][2] = FaceBlanc[2][2];
  3793. FaceBlanc[2][2] = FaceVert[0][0];
  3794. FaceVert[0][0] = buffer;
  3795.  
  3796. buffer = FaceJaune[1][2];
  3797. FaceJaune[1][2] = FaceBleu[1][2];
  3798. FaceBleu[1][2] = FaceBlanc[1][2];
  3799. FaceBlanc[1][2] = FaceVert[1][0];
  3800. FaceVert[1][0] = buffer;
  3801.  
  3802. buffer = FaceJaune[0][2];
  3803. FaceJaune[0][2] = FaceBleu[0][2];
  3804. FaceBleu[0][2] = FaceBlanc[0][2];
  3805. FaceBlanc[0][2] = FaceVert[2][0];
  3806. FaceVert[2][0] = buffer;
  3807.  
  3808. buffer = FaceRouge[0][0];
  3809. FaceRouge[0][0] = FaceRouge[2][0];
  3810. FaceRouge[2][0] = FaceRouge[2][2];
  3811. FaceRouge[2][2] = FaceRouge[0][2];
  3812. FaceRouge[0][2] = buffer;
  3813.  
  3814. buffer = FaceRouge[0][1];
  3815. FaceRouge[0][1] = FaceRouge[1][0];
  3816. FaceRouge[1][0] = FaceRouge[2][1];
  3817. FaceRouge[2][1] = FaceRouge[1][2];
  3818. FaceRouge[1][2] = buffer;
  3819.  
  3820.  
  3821. buffer = FaceJaune[2][2];
  3822. FaceJaune[2][2] = FaceBleu[2][2];
  3823. FaceBleu[2][2] = FaceBlanc[2][2];
  3824. FaceBlanc[2][2] = FaceVert[0][0];
  3825. FaceVert[0][0] = buffer;
  3826.  
  3827. buffer = FaceJaune[1][2];
  3828. FaceJaune[1][2] = FaceBleu[1][2];
  3829. FaceBleu[1][2] = FaceBlanc[1][2];
  3830. FaceBlanc[1][2] = FaceVert[1][0];
  3831. FaceVert[1][0] = buffer;
  3832.  
  3833. buffer = FaceJaune[0][2];
  3834. FaceJaune[0][2] = FaceBleu[0][2];
  3835. FaceBleu[0][2] = FaceBlanc[0][2];
  3836. FaceBlanc[0][2] = FaceVert[2][0];
  3837. FaceVert[2][0] = buffer;
  3838.  
  3839. buffer = FaceRouge[0][0];
  3840. FaceRouge[0][0] = FaceRouge[2][0];
  3841. FaceRouge[2][0] = FaceRouge[2][2];
  3842. FaceRouge[2][2] = FaceRouge[0][2];
  3843. FaceRouge[0][2] = buffer;
  3844.  
  3845. buffer = FaceRouge[0][1];
  3846. FaceRouge[0][1] = FaceRouge[1][0];
  3847. FaceRouge[1][0] = FaceRouge[2][1];
  3848. FaceRouge[2][1] = FaceRouge[1][2];
  3849. FaceRouge[1][2] = buffer;
  3850.  
  3851. }
  3852.  
  3853. public void LMove() {
  3854.  
  3855. CouleurEnum buffer = null;
  3856.  
  3857. buffer = FaceJaune[2][0];
  3858. FaceJaune[2][0] = FaceVert[0][2];
  3859. FaceVert[0][2] = FaceBlanc[2][0];
  3860. FaceBlanc[2][0] = FaceBleu[2][0];
  3861. FaceBleu[2][0] = buffer;
  3862.  
  3863. buffer = FaceJaune[1][0];
  3864. FaceJaune[1][0] = FaceVert[1][2];
  3865. FaceVert[1][2] = FaceBlanc[1][0];
  3866. FaceBlanc[1][0] = FaceBleu[1][0];
  3867. FaceBleu[1][0] = buffer;
  3868.  
  3869. buffer = FaceJaune[0][0];
  3870. FaceJaune[0][0] = FaceVert[2][2];
  3871. FaceVert[2][2] = FaceBlanc[0][0];
  3872. FaceBlanc[0][0] = FaceBleu[0][0];
  3873. FaceBleu[0][0] = buffer;
  3874.  
  3875. buffer = FaceOrange[0][1];
  3876. FaceOrange[0][1] = FaceOrange[1][0];
  3877. FaceOrange[1][0] = FaceOrange[2][1];
  3878. FaceOrange[2][1] = FaceOrange[1][2];
  3879. FaceOrange[1][2] = buffer;
  3880.  
  3881. buffer = FaceOrange[0][0];
  3882. FaceOrange[0][0] = FaceOrange[2][0];
  3883. FaceOrange[2][0] = FaceOrange[2][2];
  3884. FaceOrange[2][2] = FaceOrange[0][2];
  3885. FaceOrange[0][2] = buffer;
  3886. }
  3887.  
  3888. public void LPMove() {
  3889.  
  3890. CouleurEnum buffer = null;
  3891.  
  3892. buffer = FaceJaune[2][0];
  3893. FaceJaune[2][0] = FaceBleu[2][0];
  3894. FaceBleu[2][0] = FaceBlanc[2][0];
  3895. FaceBlanc[2][0] = FaceVert[0][2];
  3896. FaceVert[0][2] = buffer;
  3897.  
  3898. buffer = FaceJaune[1][0];
  3899. FaceJaune[1][0] = FaceBleu[1][0];
  3900. FaceBleu[1][0] = FaceBlanc[1][0];
  3901. FaceBlanc[1][0] = FaceVert[1][2];
  3902. FaceVert[1][2] = buffer;
  3903.  
  3904. buffer = FaceJaune[0][0];
  3905. FaceJaune[0][0] = FaceBleu[0][0];
  3906. FaceBleu[0][0] = FaceBlanc[0][0];
  3907. FaceBlanc[0][0] = FaceVert[2][2];
  3908. FaceVert[2][2] = buffer;
  3909.  
  3910. buffer = FaceOrange[0][0];
  3911. FaceOrange[0][0] = FaceOrange[0][2];
  3912. FaceOrange[0][2] = FaceOrange[2][2];
  3913. FaceOrange[2][2] = FaceOrange[2][0];
  3914. FaceOrange[2][0] = buffer;
  3915.  
  3916. buffer = FaceOrange[0][1];
  3917. FaceOrange[0][1] = FaceOrange[1][2];
  3918. FaceOrange[1][2] = FaceOrange[2][1];
  3919. FaceOrange[2][1] = FaceOrange[1][0];
  3920. FaceOrange[1][0] = buffer;
  3921. }
  3922.  
  3923. public void L2Move() {
  3924.  
  3925. CouleurEnum buffer = null;
  3926.  
  3927. buffer = FaceJaune[2][0];
  3928. FaceJaune[2][0] = FaceVert[0][2];
  3929. FaceVert[0][2] = FaceBlanc[2][0];
  3930. FaceBlanc[2][0] = FaceBleu[2][0];
  3931. FaceBleu[2][0] = buffer;
  3932.  
  3933. buffer = FaceJaune[1][0];
  3934. FaceJaune[1][0] = FaceVert[1][2];
  3935. FaceVert[1][2] = FaceBlanc[1][0];
  3936. FaceBlanc[1][0] = FaceBleu[1][0];
  3937. FaceBleu[1][0] = buffer;
  3938.  
  3939. buffer = FaceJaune[0][0];
  3940. FaceJaune[0][0] = FaceVert[2][2];
  3941. FaceVert[2][2] = FaceBlanc[0][0];
  3942. FaceBlanc[0][0] = FaceBleu[0][0];
  3943. FaceBleu[0][0] = buffer;
  3944.  
  3945. buffer = FaceOrange[0][1];
  3946. FaceOrange[0][1] = FaceOrange[1][0];
  3947. FaceOrange[1][0] = FaceOrange[2][1];
  3948. FaceOrange[2][1] = FaceOrange[1][2];
  3949. FaceOrange[1][2] = buffer;
  3950.  
  3951. buffer = FaceOrange[0][0];
  3952. FaceOrange[0][0] = FaceOrange[2][0];
  3953. FaceOrange[2][0] = FaceOrange[2][2];
  3954. FaceOrange[2][2] = FaceOrange[0][2];
  3955. FaceOrange[0][2] = buffer;
  3956.  
  3957.  
  3958. buffer = FaceJaune[2][0];
  3959. FaceJaune[2][0] = FaceVert[0][2];
  3960. FaceVert[0][2] = FaceBlanc[2][0];
  3961. FaceBlanc[2][0] = FaceBleu[2][0];
  3962. FaceBleu[2][0] = buffer;
  3963.  
  3964. buffer = FaceJaune[1][0];
  3965. FaceJaune[1][0] = FaceVert[1][2];
  3966. FaceVert[1][2] = FaceBlanc[1][0];
  3967. FaceBlanc[1][0] = FaceBleu[1][0];
  3968. FaceBleu[1][0] = buffer;
  3969.  
  3970. buffer = FaceJaune[0][0];
  3971. FaceJaune[0][0] = FaceVert[2][2];
  3972. FaceVert[2][2] = FaceBlanc[0][0];
  3973. FaceBlanc[0][0] = FaceBleu[0][0];
  3974. FaceBleu[0][0] = buffer;
  3975.  
  3976. buffer = FaceOrange[0][1];
  3977. FaceOrange[0][1] = FaceOrange[1][0];
  3978. FaceOrange[1][0] = FaceOrange[2][1];
  3979. FaceOrange[2][1] = FaceOrange[1][2];
  3980. FaceOrange[1][2] = buffer;
  3981.  
  3982. buffer = FaceOrange[0][0];
  3983. FaceOrange[0][0] = FaceOrange[2][0];
  3984. FaceOrange[2][0] = FaceOrange[2][2];
  3985. FaceOrange[2][2] = FaceOrange[0][2];
  3986. FaceOrange[0][2] = buffer;
  3987. }
  3988.  
  3989. public void UMove() {
  3990.  
  3991. CouleurEnum buffer = null;
  3992.  
  3993. buffer = FaceBleu[0][0];
  3994. FaceBleu[0][0] = FaceRouge[0][0];
  3995. FaceRouge[0][0] = FaceVert[0][0];
  3996. FaceVert[0][0] = FaceOrange[0][0];
  3997. FaceOrange[0][0] = buffer;
  3998.  
  3999. buffer = FaceBleu[0][1];
  4000. FaceBleu[0][1] = FaceRouge[0][1];
  4001. FaceRouge[0][1] = FaceVert[0][1];
  4002. FaceVert[0][1] = FaceOrange[0][1];
  4003. FaceOrange[0][1] = buffer;
  4004.  
  4005. buffer = FaceBleu[0][2];
  4006. FaceBleu[0][2] = FaceRouge[0][2];
  4007. FaceRouge[0][2] = FaceVert[0][2];
  4008. FaceVert[0][2] = FaceOrange[0][2];
  4009. FaceOrange[0][2] = buffer;
  4010.  
  4011. buffer = FaceJaune[0][1];
  4012. FaceJaune[0][1] = FaceJaune[1][0];
  4013. FaceJaune[1][0] = FaceJaune[2][1];
  4014. FaceJaune[2][1] = FaceJaune[1][2];
  4015. FaceJaune[1][2] = buffer;
  4016.  
  4017. buffer = FaceJaune[0][0];
  4018. FaceJaune[0][0] = FaceJaune[2][0];
  4019. FaceJaune[2][0] = FaceJaune[2][2];
  4020. FaceJaune[2][2] = FaceJaune[0][2];
  4021. FaceJaune[0][2] = buffer;
  4022. }
  4023.  
  4024. public void UPMove() {
  4025.  
  4026. CouleurEnum buffer = null;
  4027.  
  4028. buffer = FaceBleu[0][0];
  4029. FaceBleu[0][0] = FaceOrange[0][0];
  4030. FaceOrange[0][0] = FaceVert[0][0];
  4031. FaceVert[0][0] = FaceRouge[0][0];
  4032. FaceRouge[0][0] = buffer;
  4033.  
  4034. buffer = FaceBleu[0][1];
  4035. FaceBleu[0][1] = FaceOrange[0][1];
  4036. FaceOrange[0][1] = FaceVert[0][1];
  4037. FaceVert[0][1] = FaceRouge[0][1];
  4038. FaceRouge[0][1] = buffer;
  4039.  
  4040. buffer = FaceBleu[0][2];
  4041. FaceBleu[0][2] = FaceOrange[0][2];
  4042. FaceOrange[0][2] = FaceVert[0][2];
  4043. FaceVert[0][2] = FaceRouge[0][2];
  4044. FaceRouge[0][2] = buffer;
  4045.  
  4046. buffer = FaceJaune[0][0];
  4047. FaceJaune[0][0] = FaceJaune[0][2];
  4048. FaceJaune[0][2] = FaceJaune[2][2];
  4049. FaceJaune[2][2] = FaceJaune[2][0];
  4050. FaceJaune[2][0] = buffer;
  4051.  
  4052. buffer = FaceJaune[0][1];
  4053. FaceJaune[0][1] = FaceJaune[1][2];
  4054. FaceJaune[1][2] = FaceJaune[2][1];
  4055. FaceJaune[2][1] = FaceJaune[1][0];
  4056. FaceJaune[1][0] = buffer;
  4057. }
  4058.  
  4059. public void U2Move() {
  4060.  
  4061. CouleurEnum buffer = null;
  4062.  
  4063. buffer = FaceBleu[0][0];
  4064. FaceBleu[0][0] = FaceRouge[0][0];
  4065. FaceRouge[0][0] = FaceVert[0][0];
  4066. FaceVert[0][0] = FaceOrange[0][0];
  4067. FaceOrange[0][0] = buffer;
  4068.  
  4069. buffer = FaceBleu[0][1];
  4070. FaceBleu[0][1] = FaceRouge[0][1];
  4071. FaceRouge[0][1] = FaceVert[0][1];
  4072. FaceVert[0][1] = FaceOrange[0][1];
  4073. FaceOrange[0][1] = buffer;
  4074.  
  4075. buffer = FaceBleu[0][2];
  4076. FaceBleu[0][2] = FaceRouge[0][2];
  4077. FaceRouge[0][2] = FaceVert[0][2];
  4078. FaceVert[0][2] = FaceOrange[0][2];
  4079. FaceOrange[0][2] = buffer;
  4080.  
  4081. buffer = FaceJaune[0][1];
  4082. FaceJaune[0][1] = FaceJaune[1][0];
  4083. FaceJaune[1][0] = FaceJaune[2][1];
  4084. FaceJaune[2][1] = FaceJaune[1][2];
  4085. FaceJaune[1][2] = buffer;
  4086.  
  4087. buffer = FaceJaune[0][0];
  4088. FaceJaune[0][0] = FaceJaune[2][0];
  4089. FaceJaune[2][0] = FaceJaune[2][2];
  4090. FaceJaune[2][2] = FaceJaune[0][2];
  4091. FaceJaune[0][2] = buffer;
  4092.  
  4093.  
  4094. buffer = FaceBleu[0][0];
  4095. FaceBleu[0][0] = FaceRouge[0][0];
  4096. FaceRouge[0][0] = FaceVert[0][0];
  4097. FaceVert[0][0] = FaceOrange[0][0];
  4098. FaceOrange[0][0] = buffer;
  4099.  
  4100. buffer = FaceBleu[0][1];
  4101. FaceBleu[0][1] = FaceRouge[0][1];
  4102. FaceRouge[0][1] = FaceVert[0][1];
  4103. FaceVert[0][1] = FaceOrange[0][1];
  4104. FaceOrange[0][1] = buffer;
  4105.  
  4106. buffer = FaceBleu[0][2];
  4107. FaceBleu[0][2] = FaceRouge[0][2];
  4108. FaceRouge[0][2] = FaceVert[0][2];
  4109. FaceVert[0][2] = FaceOrange[0][2];
  4110. FaceOrange[0][2] = buffer;
  4111.  
  4112. buffer = FaceJaune[0][1];
  4113. FaceJaune[0][1] = FaceJaune[1][0];
  4114. FaceJaune[1][0] = FaceJaune[2][1];
  4115. FaceJaune[2][1] = FaceJaune[1][2];
  4116. FaceJaune[1][2] = buffer;
  4117.  
  4118. buffer = FaceJaune[0][0];
  4119. FaceJaune[0][0] = FaceJaune[2][0];
  4120. FaceJaune[2][0] = FaceJaune[2][2];
  4121. FaceJaune[2][2] = FaceJaune[0][2];
  4122. FaceJaune[0][2] = buffer;
  4123.  
  4124. }
  4125.  
  4126. public void FMove() {
  4127.  
  4128. CouleurEnum buffer = null;
  4129.  
  4130. buffer = FaceJaune[2][0];
  4131. FaceJaune[2][0] = FaceOrange[2][2];
  4132. FaceOrange[2][2] = FaceBlanc[0][2];
  4133. FaceBlanc[0][2] = FaceRouge[0][0];
  4134. FaceRouge[0][0] = buffer;
  4135.  
  4136. buffer = FaceJaune[2][1];
  4137. FaceJaune[2][1] = FaceOrange[1][2];
  4138. FaceOrange[1][2] = FaceBlanc[0][1];
  4139. FaceBlanc[0][1] = FaceRouge[1][0];
  4140. FaceRouge[1][0] = buffer;
  4141.  
  4142. buffer = FaceJaune[2][2];
  4143. FaceJaune[2][2] = FaceOrange[0][2];
  4144. FaceOrange[0][2] = FaceBlanc[0][0];
  4145. FaceBlanc[0][0] = FaceRouge[2][0];
  4146. FaceRouge[2][0] = buffer;
  4147.  
  4148. buffer = FaceBleu[0][0];
  4149. FaceBleu[0][0] = FaceBleu[2][0];
  4150. FaceBleu[2][0] = FaceBleu[2][2];
  4151. FaceBleu[2][2] = FaceBleu[0][2];
  4152. FaceBleu[0][2] = buffer;
  4153.  
  4154. buffer = FaceBleu[0][1];
  4155. FaceBleu[0][1] = FaceBleu[1][0];
  4156. FaceBleu[1][0] = FaceBleu[2][1];
  4157. FaceBleu[2][1] = FaceBleu[1][2];
  4158. FaceBleu[1][2] = buffer;
  4159. }
  4160.  
  4161. public void FPMove() {
  4162.  
  4163. CouleurEnum buffer = null;
  4164.  
  4165. buffer = FaceJaune[2][0];
  4166. FaceJaune[2][0] = FaceRouge[0][0];
  4167. FaceRouge[0][0] = FaceBlanc[0][2];
  4168. FaceBlanc[0][2] = FaceOrange[2][2];
  4169. FaceOrange[2][2] = buffer;
  4170.  
  4171. buffer = FaceJaune[2][1];
  4172. FaceJaune[2][1] = FaceRouge[1][0];
  4173. FaceRouge[1][0] = FaceBlanc[0][1];
  4174. FaceBlanc[0][1] = FaceOrange[1][2];
  4175. FaceOrange[1][2] = buffer;
  4176.  
  4177. buffer = FaceJaune[2][2];
  4178. FaceJaune[2][2] = FaceRouge[2][0];
  4179. FaceRouge[2][0] = FaceBlanc[0][0];
  4180. FaceBlanc[0][0] = FaceOrange[0][2];
  4181. FaceOrange[0][2] = buffer;
  4182.  
  4183. buffer = FaceBleu[0][0];
  4184. FaceBleu[0][0] = FaceBleu[0][2];
  4185. FaceBleu[0][2] = FaceBleu[2][2];
  4186. FaceBleu[2][2] = FaceBleu[2][0];
  4187. FaceBleu[2][0] = buffer;
  4188.  
  4189. buffer = FaceBleu[0][1];
  4190. FaceBleu[0][1] = FaceBleu[1][2];
  4191. FaceBleu[1][2] = FaceBleu[2][1];
  4192. FaceBleu[2][1] = FaceBleu[1][0];
  4193. FaceBleu[1][0] = buffer;
  4194. }
  4195.  
  4196. public void F2Move() {
  4197.  
  4198. CouleurEnum buffer = null;
  4199.  
  4200. buffer = FaceJaune[2][0];
  4201. FaceJaune[2][0] = FaceOrange[2][2];
  4202. FaceOrange[2][2] = FaceBlanc[0][2];
  4203. FaceBlanc[0][2] = FaceRouge[0][0];
  4204. FaceRouge[0][0] = buffer;
  4205.  
  4206. buffer = FaceJaune[2][1];
  4207. FaceJaune[2][1] = FaceOrange[1][2];
  4208. FaceOrange[1][2] = FaceBlanc[0][1];
  4209. FaceBlanc[0][1] = FaceRouge[1][0];
  4210. FaceRouge[1][0] = buffer;
  4211.  
  4212. buffer = FaceJaune[2][2];
  4213. FaceJaune[2][2] = FaceOrange[0][2];
  4214. FaceOrange[0][2] = FaceBlanc[0][0];
  4215. FaceBlanc[0][0] = FaceRouge[2][0];
  4216. FaceRouge[2][0] = buffer;
  4217.  
  4218. buffer = FaceBleu[0][0];
  4219. FaceBleu[0][0] = FaceBleu[2][0];
  4220. FaceBleu[2][0] = FaceBleu[2][2];
  4221. FaceBleu[2][2] = FaceBleu[0][2];
  4222. FaceBleu[0][2] = buffer;
  4223.  
  4224. buffer = FaceBleu[0][1];
  4225. FaceBleu[0][1] = FaceBleu[1][0];
  4226. FaceBleu[1][0] = FaceBleu[2][1];
  4227. FaceBleu[2][1] = FaceBleu[1][2];
  4228. FaceBleu[1][2] = buffer;
  4229.  
  4230.  
  4231. buffer = FaceJaune[2][0];
  4232. FaceJaune[2][0] = FaceOrange[2][2];
  4233. FaceOrange[2][2] = FaceBlanc[0][2];
  4234. FaceBlanc[0][2] = FaceRouge[0][0];
  4235. FaceRouge[0][0] = buffer;
  4236.  
  4237. buffer = FaceJaune[2][1];
  4238. FaceJaune[2][1] = FaceOrange[1][2];
  4239. FaceOrange[1][2] = FaceBlanc[0][1];
  4240. FaceBlanc[0][1] = FaceRouge[1][0];
  4241. FaceRouge[1][0] = buffer;
  4242.  
  4243. buffer = FaceJaune[2][2];
  4244. FaceJaune[2][2] = FaceOrange[0][2];
  4245. FaceOrange[0][2] = FaceBlanc[0][0];
  4246. FaceBlanc[0][0] = FaceRouge[2][0];
  4247. FaceRouge[2][0] = buffer;
  4248.  
  4249. buffer = FaceBleu[0][0];
  4250. FaceBleu[0][0] = FaceBleu[2][0];
  4251. FaceBleu[2][0] = FaceBleu[2][2];
  4252. FaceBleu[2][2] = FaceBleu[0][2];
  4253. FaceBleu[0][2] = buffer;
  4254.  
  4255. buffer = FaceBleu[0][1];
  4256. FaceBleu[0][1] = FaceBleu[1][0];
  4257. FaceBleu[1][0] = FaceBleu[2][1];
  4258. FaceBleu[2][1] = FaceBleu[1][2];
  4259. FaceBleu[1][2] = buffer;
  4260. }
  4261.  
  4262. public void BMove() {
  4263.  
  4264. CouleurEnum buffer = null;
  4265.  
  4266. buffer = FaceJaune[0][2];
  4267. FaceJaune[0][2] = FaceRouge[2][2];
  4268. FaceRouge[2][2] = FaceBlanc[2][0];
  4269. FaceBlanc[2][0] = FaceOrange[0][0];
  4270. FaceOrange[0][0] = buffer;
  4271.  
  4272. buffer = FaceJaune[0][1];
  4273. FaceJaune[0][1] = FaceRouge[1][2];
  4274. FaceRouge[1][2] = FaceBlanc[2][1];
  4275. FaceBlanc[2][1] = FaceOrange[1][0];
  4276. FaceOrange[1][0] = buffer;
  4277.  
  4278. buffer = FaceJaune[0][0];
  4279. FaceJaune[0][0] = FaceRouge[0][2];
  4280. FaceRouge[0][2] = FaceBlanc[2][2];
  4281. FaceBlanc[2][2] = FaceOrange[2][0];
  4282. FaceOrange[2][0] = buffer;
  4283.  
  4284. buffer = FaceVert[0][0];
  4285. FaceVert[0][0] = FaceVert[2][0];
  4286. FaceVert[2][0] = FaceVert[2][2];
  4287. FaceVert[2][2] = FaceVert[0][2];
  4288. FaceVert[0][2] = buffer;
  4289.  
  4290. buffer = FaceVert[0][1];
  4291. FaceVert[0][1] = FaceVert[1][0];
  4292. FaceVert[1][0] = FaceVert[2][1];
  4293. FaceVert[2][1] = FaceVert[1][2];
  4294. FaceVert[1][2] = buffer;
  4295. }
  4296.  
  4297. public void BPMove() {
  4298.  
  4299. CouleurEnum buffer = null;
  4300.  
  4301. buffer = FaceJaune[0][2];
  4302. FaceJaune[0][2] = FaceOrange[0][0];
  4303. FaceOrange[0][0] = FaceBlanc[2][0];
  4304. FaceBlanc[2][0] = FaceRouge[2][2];
  4305. FaceRouge[2][2] = buffer;
  4306.  
  4307. buffer = FaceJaune[0][1];
  4308. FaceJaune[0][1] = FaceOrange[1][0];
  4309. FaceOrange[1][0] = FaceBlanc[2][1];
  4310. FaceBlanc[2][1] = FaceRouge[1][2];
  4311. FaceRouge[1][2] = buffer;
  4312.  
  4313. buffer = FaceJaune[0][0];
  4314. FaceJaune[0][0] = FaceOrange[2][0];
  4315. FaceOrange[2][0] = FaceBlanc[2][2];
  4316. FaceBlanc[2][2] = FaceRouge[0][2];
  4317. FaceRouge[0][2] = buffer;
  4318.  
  4319. buffer = FaceVert[0][0];
  4320. FaceVert[0][0] = FaceVert[0][2];
  4321. FaceVert[0][2] = FaceVert[2][2];
  4322. FaceVert[2][2] = FaceVert[2][0];
  4323. FaceVert[2][0] = buffer;
  4324.  
  4325. buffer = FaceVert[0][1];
  4326. FaceVert[0][1] = FaceVert[1][2];
  4327. FaceVert[1][2] = FaceVert[2][1];
  4328. FaceVert[2][1] = FaceVert[1][0];
  4329. FaceVert[1][0] = buffer;
  4330. }
  4331.  
  4332. public void B2Move() {
  4333.  
  4334. CouleurEnum buffer = null;
  4335.  
  4336. buffer = FaceJaune[0][2];
  4337. FaceJaune[0][2] = FaceRouge[2][2];
  4338. FaceRouge[2][2] = FaceBlanc[2][0];
  4339. FaceBlanc[2][0] = FaceOrange[0][0];
  4340. FaceOrange[0][0] = buffer;
  4341.  
  4342. buffer = FaceJaune[0][1];
  4343. FaceJaune[0][1] = FaceRouge[1][2];
  4344. FaceRouge[1][2] = FaceBlanc[2][1];
  4345. FaceBlanc[2][1] = FaceOrange[1][0];
  4346. FaceOrange[1][0] = buffer;
  4347.  
  4348. buffer = FaceJaune[0][0];
  4349. FaceJaune[0][0] = FaceRouge[0][2];
  4350. FaceRouge[0][2] = FaceBlanc[2][2];
  4351. FaceBlanc[2][2] = FaceOrange[2][0];
  4352. FaceOrange[2][0] = buffer;
  4353.  
  4354. buffer = FaceVert[0][0];
  4355. FaceVert[0][0] = FaceVert[2][0];
  4356. FaceVert[2][0] = FaceVert[2][2];
  4357. FaceVert[2][2] = FaceVert[0][2];
  4358. FaceVert[0][2] = buffer;
  4359.  
  4360. buffer = FaceVert[0][1];
  4361. FaceVert[0][1] = FaceVert[1][0];
  4362. FaceVert[1][0] = FaceVert[2][1];
  4363. FaceVert[2][1] = FaceVert[1][2];
  4364. FaceVert[1][2] = buffer;
  4365.  
  4366.  
  4367. buffer = FaceJaune[0][2];
  4368. FaceJaune[0][2] = FaceRouge[2][2];
  4369. FaceRouge[2][2] = FaceBlanc[2][0];
  4370. FaceBlanc[2][0] = FaceOrange[0][0];
  4371. FaceOrange[0][0] = buffer;
  4372.  
  4373. buffer = FaceJaune[0][1];
  4374. FaceJaune[0][1] = FaceRouge[1][2];
  4375. FaceRouge[1][2] = FaceBlanc[2][1];
  4376. FaceBlanc[2][1] = FaceOrange[1][0];
  4377. FaceOrange[1][0] = buffer;
  4378.  
  4379. buffer = FaceJaune[0][0];
  4380. FaceJaune[0][0] = FaceRouge[0][2];
  4381. FaceRouge[0][2] = FaceBlanc[2][2];
  4382. FaceBlanc[2][2] = FaceOrange[2][0];
  4383. FaceOrange[2][0] = buffer;
  4384.  
  4385. buffer = FaceVert[0][0];
  4386. FaceVert[0][0] = FaceVert[2][0];
  4387. FaceVert[2][0] = FaceVert[2][2];
  4388. FaceVert[2][2] = FaceVert[0][2];
  4389. FaceVert[0][2] = buffer;
  4390.  
  4391. buffer = FaceVert[0][1];
  4392. FaceVert[0][1] = FaceVert[1][0];
  4393. FaceVert[1][0] = FaceVert[2][1];
  4394. FaceVert[2][1] = FaceVert[1][2];
  4395. FaceVert[1][2] = buffer;
  4396.  
  4397. }
  4398.  
  4399. public void DMove() {
  4400.  
  4401. CouleurEnum buffer = null;
  4402.  
  4403. buffer = FaceBleu[2][0];
  4404. FaceBleu[2][0] = FaceOrange[2][0];
  4405. FaceOrange[2][0] = FaceVert[2][0];
  4406. FaceVert[2][0] = FaceRouge[2][0];
  4407. FaceRouge[2][0] = buffer;
  4408.  
  4409. buffer = FaceBleu[2][1];
  4410. FaceBleu[2][1] = FaceOrange[2][1];
  4411. FaceOrange[2][1] = FaceVert[2][1];
  4412. FaceVert[2][1] = FaceRouge[2][1];
  4413. FaceRouge[2][1] = buffer;
  4414.  
  4415. buffer = FaceBleu[2][2];
  4416. FaceBleu[2][2] = FaceOrange[2][2];
  4417. FaceOrange[2][2] = FaceVert[2][2];
  4418. FaceVert[2][2] = FaceRouge[2][2];
  4419. FaceRouge[2][2] = buffer;
  4420.  
  4421. buffer = FaceBlanc[0][0];
  4422. FaceBlanc[0][0] = FaceBlanc[2][0];
  4423. FaceBlanc[2][0] = FaceBlanc[2][2];
  4424. FaceBlanc[2][2] = FaceBlanc[0][2];
  4425. FaceBlanc[0][2] = buffer;
  4426.  
  4427. buffer = FaceBlanc[0][1];
  4428. FaceBlanc[0][1] = FaceBlanc[1][0];
  4429. FaceBlanc[1][0] = FaceBlanc[2][1];
  4430. FaceBlanc[2][1] = FaceBlanc[1][2];
  4431. FaceBlanc[1][2] = buffer;
  4432. }
  4433.  
  4434. public void DPMove() {
  4435.  
  4436. CouleurEnum buffer = null;
  4437.  
  4438. buffer = FaceBleu[2][0];
  4439. FaceBleu[2][0] = FaceRouge[2][0];
  4440. FaceRouge[2][0] = FaceVert[2][0];
  4441. FaceVert[2][0] = FaceOrange[2][0];
  4442. FaceOrange[2][0] = buffer;
  4443.  
  4444. buffer = FaceBleu[2][1];
  4445. FaceBleu[2][1] = FaceRouge[2][1];
  4446. FaceRouge[2][1] = FaceVert[2][1];
  4447. FaceVert[2][1] = FaceOrange[2][1];
  4448. FaceOrange[2][1] = buffer;
  4449.  
  4450. buffer = FaceBleu[2][2];
  4451. FaceBleu[2][2] = FaceRouge[2][2];
  4452. FaceRouge[2][2] = FaceVert[2][2];
  4453. FaceVert[2][2] = FaceOrange[2][2];
  4454. FaceOrange[2][2] = buffer;
  4455.  
  4456. buffer = FaceBlanc[0][0];
  4457. FaceBlanc[0][0] = FaceBlanc[0][2];
  4458. FaceBlanc[0][2] = FaceBlanc[2][2];
  4459. FaceBlanc[2][2] = FaceBlanc[2][0];
  4460. FaceBlanc[2][0] = buffer;
  4461.  
  4462. buffer = FaceBlanc[0][1];
  4463. FaceBlanc[0][1] = FaceBlanc[1][2];
  4464. FaceBlanc[1][2] = FaceBlanc[2][1];
  4465. FaceBlanc[2][1] = FaceBlanc[1][0];
  4466. FaceBlanc[1][0] = buffer;
  4467. }
  4468.  
  4469. public void D2Move() {
  4470.  
  4471. CouleurEnum buffer = null;
  4472.  
  4473. buffer = FaceBleu[2][0];
  4474. FaceBleu[2][0] = FaceOrange[2][0];
  4475. FaceOrange[2][0] = FaceVert[2][0];
  4476. FaceVert[2][0] = FaceRouge[2][0];
  4477. FaceRouge[2][0] = buffer;
  4478.  
  4479. buffer = FaceBleu[2][1];
  4480. FaceBleu[2][1] = FaceOrange[2][1];
  4481. FaceOrange[2][1] = FaceVert[2][1];
  4482. FaceVert[2][1] = FaceRouge[2][1];
  4483. FaceRouge[2][1] = buffer;
  4484.  
  4485. buffer = FaceBleu[2][2];
  4486. FaceBleu[2][2] = FaceOrange[2][2];
  4487. FaceOrange[2][2] = FaceVert[2][2];
  4488. FaceVert[2][2] = FaceRouge[2][2];
  4489. FaceRouge[2][2] = buffer;
  4490.  
  4491. buffer = FaceBlanc[0][0];
  4492. FaceBlanc[0][0] = FaceBlanc[2][0];
  4493. FaceBlanc[2][0] = FaceBlanc[2][2];
  4494. FaceBlanc[2][2] = FaceBlanc[0][2];
  4495. FaceBlanc[0][2] = buffer;
  4496.  
  4497. buffer = FaceBlanc[0][1];
  4498. FaceBlanc[0][1] = FaceBlanc[1][0];
  4499. FaceBlanc[1][0] = FaceBlanc[2][1];
  4500. FaceBlanc[2][1] = FaceBlanc[1][2];
  4501. FaceBlanc[1][2] = buffer;
  4502.  
  4503.  
  4504. buffer = FaceBleu[2][0];
  4505. FaceBleu[2][0] = FaceOrange[2][0];
  4506. FaceOrange[2][0] = FaceVert[2][0];
  4507. FaceVert[2][0] = FaceRouge[2][0];
  4508. FaceRouge[2][0] = buffer;
  4509.  
  4510. buffer = FaceBleu[2][1];
  4511. FaceBleu[2][1] = FaceOrange[2][1];
  4512. FaceOrange[2][1] = FaceVert[2][1];
  4513. FaceVert[2][1] = FaceRouge[2][1];
  4514. FaceRouge[2][1] = buffer;
  4515.  
  4516. buffer = FaceBleu[2][2];
  4517. FaceBleu[2][2] = FaceOrange[2][2];
  4518. FaceOrange[2][2] = FaceVert[2][2];
  4519. FaceVert[2][2] = FaceRouge[2][2];
  4520. FaceRouge[2][2] = buffer;
  4521.  
  4522. buffer = FaceBlanc[0][0];
  4523. FaceBlanc[0][0] = FaceBlanc[2][0];
  4524. FaceBlanc[2][0] = FaceBlanc[2][2];
  4525. FaceBlanc[2][2] = FaceBlanc[0][2];
  4526. FaceBlanc[0][2] = buffer;
  4527.  
  4528. buffer = FaceBlanc[0][1];
  4529. FaceBlanc[0][1] = FaceBlanc[1][0];
  4530. FaceBlanc[1][0] = FaceBlanc[2][1];
  4531. FaceBlanc[2][1] = FaceBlanc[1][2];
  4532. FaceBlanc[1][2] = buffer;
  4533. }
  4534.  
  4535. public String convert(String scramble) {
  4536.  
  4537. //System.out.println(scramble);
  4538.  
  4539. String melange_conv = "";
  4540.  
  4541. for(int z = 0; z < scramble.length(); z++) {
  4542.  
  4543. char c = scramble.charAt(z);
  4544. char d = ' ';
  4545.  
  4546. try{
  4547. d = scramble.charAt(z + 1);
  4548. } catch(Exception e5) {
  4549. //System.out.println(e5);
  4550. }
  4551.  
  4552. if(c == 'R') {
  4553.  
  4554. if(d == '\'') {
  4555.  
  4556. melange_conv = melange_conv + "S";
  4557. d = ' ';
  4558. }
  4559.  
  4560. else if(d == '2') {
  4561.  
  4562. melange_conv = melange_conv + "T";
  4563. d = ' ';
  4564. }
  4565.  
  4566. else {
  4567.  
  4568. melange_conv = melange_conv + "R";
  4569. }
  4570. }
  4571.  
  4572. else if(c == 'U') {
  4573.  
  4574. if(d == '\'') {
  4575.  
  4576. melange_conv = melange_conv + "V";
  4577. d = ' ';
  4578. }
  4579.  
  4580. else if(d == '2') {
  4581.  
  4582. melange_conv = melange_conv + "W";
  4583. d = ' ';
  4584. }
  4585.  
  4586. else {
  4587.  
  4588. melange_conv = melange_conv + "U";
  4589. }
  4590. }
  4591.  
  4592. else if(c == 'L') {
  4593.  
  4594. if(d == '\'') {
  4595.  
  4596. melange_conv = melange_conv + "M";
  4597. d = ' ';
  4598. }
  4599.  
  4600. else if(d == '2') {
  4601.  
  4602. melange_conv = melange_conv + "N";
  4603. d = ' ';
  4604. }
  4605.  
  4606. else {
  4607.  
  4608. melange_conv = melange_conv + "L";
  4609. }
  4610. }
  4611.  
  4612. else if(c == 'D') {
  4613.  
  4614. if(d == '\'') {
  4615.  
  4616. melange_conv = melange_conv + "E";
  4617. d = ' ';
  4618. }
  4619.  
  4620. else if(d == '2') {
  4621.  
  4622. melange_conv = melange_conv + "Z";
  4623. d = ' ';
  4624. }
  4625.  
  4626. else {
  4627.  
  4628. melange_conv = melange_conv + "D";
  4629. }
  4630. }
  4631.  
  4632. else if(c == 'B') {
  4633.  
  4634. if(d == '\'') {
  4635.  
  4636. melange_conv = melange_conv + "C";
  4637. d = ' ';
  4638. }
  4639.  
  4640. else if(d == '2') {
  4641.  
  4642. melange_conv = melange_conv + "A";
  4643. d = ' ';
  4644. }
  4645.  
  4646. else {
  4647.  
  4648. melange_conv = melange_conv + "B";
  4649. }
  4650. }
  4651.  
  4652. else if(c == 'F') {
  4653.  
  4654. if(d == '\'') {
  4655.  
  4656. melange_conv = melange_conv + "G";
  4657. d = ' ';
  4658. }
  4659.  
  4660. else if(d == '2') {
  4661.  
  4662. melange_conv = melange_conv + "H";
  4663. d = ' ';
  4664. }
  4665.  
  4666. else {
  4667.  
  4668. melange_conv = melange_conv + "F";
  4669. }
  4670. }
  4671. }
  4672.  
  4673. return melange_conv;
  4674. }
  4675.  
  4676. public String convert1(String scramble) {
  4677.  
  4678. //System.out.println(scramble);
  4679.  
  4680. String melange_conv = "";
  4681.  
  4682. for(int z = 0; z < scramble.length(); z++) {
  4683.  
  4684. char c = scramble.charAt(z);
  4685. char d = ' ';
  4686.  
  4687. try{
  4688. d = scramble.charAt(z + 1);
  4689. } catch(Exception e5) {
  4690. System.out.println(e5);
  4691. }
  4692.  
  4693. if(c == 'R') {
  4694.  
  4695. if(d == '\'') {
  4696.  
  4697. melange_conv = melange_conv + "S";
  4698. d = ' ';
  4699. }
  4700.  
  4701. else if(d == '2') {
  4702.  
  4703. melange_conv = melange_conv + "T";
  4704. d = ' ';
  4705. }
  4706.  
  4707. else {
  4708.  
  4709. melange_conv = melange_conv + "R";
  4710. }
  4711. }
  4712.  
  4713. else if(c == 'U') {
  4714.  
  4715. if(d == '\'') {
  4716.  
  4717. melange_conv = melange_conv + "E";
  4718. d = ' ';
  4719. }
  4720.  
  4721. else if(d == '2') {
  4722.  
  4723. melange_conv = melange_conv + "Z";
  4724. d = ' ';
  4725. }
  4726.  
  4727. else {
  4728.  
  4729. melange_conv = melange_conv + "D";
  4730. }
  4731. }
  4732.  
  4733. else if(c == 'L') {
  4734.  
  4735. if(d == '\'') {
  4736.  
  4737. melange_conv = melange_conv + "M";
  4738. d = ' ';
  4739. }
  4740.  
  4741. else if(d == '2') {
  4742.  
  4743. melange_conv = melange_conv + "N";
  4744. d = ' ';
  4745. }
  4746.  
  4747. else {
  4748.  
  4749. melange_conv = melange_conv + "L";
  4750. }
  4751. }
  4752.  
  4753. else if(c == 'D') {
  4754.  
  4755. if(d == '\'') {
  4756.  
  4757. melange_conv = melange_conv + "V";
  4758. d = ' ';
  4759. }
  4760.  
  4761. else if(d == '2') {
  4762.  
  4763. melange_conv = melange_conv + "W";
  4764. d = ' ';
  4765. }
  4766.  
  4767. else {
  4768.  
  4769. melange_conv = melange_conv + "U";
  4770. }
  4771. }
  4772.  
  4773. else if(c == 'B') {
  4774.  
  4775. if(d == '\'') {
  4776.  
  4777. melange_conv = melange_conv + "G";
  4778. d = ' ';
  4779. }
  4780.  
  4781. else if(d == '2') {
  4782.  
  4783. melange_conv = melange_conv + "H";
  4784. d = ' ';
  4785. }
  4786.  
  4787. else {
  4788.  
  4789. melange_conv = melange_conv + "F";
  4790. }
  4791. }
  4792.  
  4793. else if(c == 'F') {
  4794.  
  4795. if(d == '\'') {
  4796.  
  4797. melange_conv = melange_conv + "C";
  4798. d = ' ';
  4799. }
  4800.  
  4801. else if(d == '2') {
  4802.  
  4803. melange_conv = melange_conv + "A";
  4804. d = ' ';
  4805. }
  4806.  
  4807. else {
  4808.  
  4809. melange_conv = melange_conv + "B";
  4810. }
  4811. }
  4812. }
  4813.  
  4814. return melange_conv;
  4815. }
  4816.  
  4817.  
  4818. public String optimize(String scramble) {
  4819.  
  4820. String opti = "";
  4821. optiInt = 0;
  4822.  
  4823. for(int t = 0; t < scramble.length(); t++) {
  4824.  
  4825. try {
  4826.  
  4827. char c = scramble.charAt(optiInt);
  4828. char d = ' ';
  4829.  
  4830. if(!(c == scramble.charAt(scramble.length() - 1))) {
  4831. d = scramble.charAt(optiInt + 1);
  4832. }
  4833.  
  4834. if(c == d) {
  4835.  
  4836. if(c == 'R' || c == 'S') {
  4837.  
  4838. opti = opti + 'T';
  4839. d = ' ';
  4840. optiInt++;
  4841. }
  4842.  
  4843. else if(c == 'U' || c == 'V') {
  4844.  
  4845. opti = opti + 'W';
  4846. d = ' ';
  4847. optiInt++;
  4848. }
  4849.  
  4850. else if(c == 'L' || c == 'M') {
  4851.  
  4852. opti = opti + 'N';
  4853. d = ' ';
  4854. optiInt++;
  4855. }
  4856.  
  4857. else if(c == 'D' || c == 'E') {
  4858.  
  4859. opti = opti + 'Z';
  4860. d = ' ';
  4861. optiInt++;
  4862. }
  4863.  
  4864. else if(c == 'B' || c == 'C') {
  4865.  
  4866. opti = opti + 'A';
  4867. d = ' ';
  4868. optiInt++;
  4869. }
  4870.  
  4871. else if(c == 'F' || c == 'G') {
  4872.  
  4873. opti = opti + 'H';
  4874. d = ' ';
  4875. optiInt++;
  4876. }
  4877.  
  4878. else {
  4879. optiInt++;
  4880. }
  4881. }
  4882.  
  4883. else if((c == 'T' && d == 'R') || (c == 'R' && d == 'T')) {
  4884.  
  4885. opti = opti + 'S';
  4886. d = ' ';
  4887. optiInt++;
  4888. }
  4889.  
  4890. else if((c == 'T' && d == 'S') || (c == 'S' && d == 'T')) {
  4891.  
  4892. opti = opti + 'R';
  4893. d = ' ';
  4894. optiInt++;
  4895. }
  4896.  
  4897. else if((c == 'W' && d == 'U') || (c == 'U' && d == 'W')) {
  4898.  
  4899. opti = opti + 'V';
  4900. d = ' ';
  4901. optiInt++;
  4902. }
  4903.  
  4904. else if((c == 'W' && d == 'V') || (c == 'V' && d == 'W')) {
  4905.  
  4906. opti = opti + 'U';
  4907. d = ' ';
  4908. optiInt++;
  4909. }
  4910.  
  4911. else if((c == 'N' && d == 'L') || (c == 'L' && d == 'N')) {
  4912.  
  4913. opti = opti + 'M';
  4914. d = ' ';
  4915. optiInt++;
  4916. }
  4917.  
  4918. else if((c == 'N' && d == 'M') || (c == 'M' && d == 'N')) {
  4919.  
  4920. opti = opti + 'L';
  4921. d = ' ';
  4922. optiInt++;
  4923. }
  4924.  
  4925. else if((c == 'Z' && d == 'D') || (c == 'D' && d == 'Z')) {
  4926.  
  4927. opti = opti + 'E';
  4928. d = ' ';
  4929. optiInt++;
  4930. }
  4931.  
  4932. else if((c == 'Z' && d == 'E') || (c == 'E' && d == 'Z')) {
  4933.  
  4934. opti = opti + 'D';
  4935. d = ' ';
  4936. optiInt++;
  4937. }
  4938.  
  4939. else if((c == 'A' && d == 'B') || (c == 'B' && d == 'A')) {
  4940.  
  4941. opti = opti + 'C';
  4942. d = ' ';
  4943. optiInt++;
  4944. }
  4945.  
  4946. else if((c == 'A' && d == 'C') || (c == 'C' && d == 'A')) {
  4947.  
  4948. opti = opti + 'B';
  4949. d = ' ';
  4950. optiInt++;
  4951. }
  4952.  
  4953. else if((c == 'H' && d == 'F') || (c == 'F' && d == 'H')) {
  4954.  
  4955. opti = opti + 'G';
  4956. d = ' ';
  4957. optiInt++;
  4958. }
  4959.  
  4960. else if((c == 'H' && d == 'G') || (c == 'G' && d == 'H')) {
  4961.  
  4962. opti = opti + 'F';
  4963. d = ' ';
  4964. optiInt++;
  4965. }
  4966.  
  4967. else if((c != 'R' && d != 'S') ||
  4968. (c != 'S' && d != 'R') ||
  4969. (c != 'U' && d != 'V') ||
  4970. (c != 'V' && d != 'U') ||
  4971. (c != 'L' && d != 'M') ||
  4972. (c != 'M' && d != 'L') ||
  4973. (c != 'D' && d != 'E') ||
  4974. (c != 'E' && d != 'D') ||
  4975. (c != 'B' && d != 'C') ||
  4976. (c != 'C' && d != 'B') ||
  4977. (c != 'F' && d != 'G') ||
  4978. (c != 'G' && d != 'F')) {
  4979.  
  4980. opti = opti + scramble.charAt(optiInt);
  4981. d = ' ';
  4982. }
  4983.  
  4984. else {
  4985. opti = opti + scramble.charAt(optiInt);
  4986. }
  4987.  
  4988. optiInt++;
  4989. } catch(Exception excc) {
  4990. //System.out.println(excc);
  4991. }
  4992. }
  4993.  
  4994. return opti;
  4995. }
  4996.  
  4997. public void applyScramble(String scramble) {
  4998.  
  4999. String melange_conv = convert1(scramble);
  5000.  
  5001. text.appendText(melange_conv + "\n");
  5002.  
  5003. for(int imelange = 0; imelange < melange_conv.length(); imelange++) {
  5004.  
  5005. char c = melange_conv.charAt(imelange);
  5006.  
  5007. if(c == 'R') {
  5008. RMove();
  5009. }
  5010.  
  5011. else if(c == 'S') {
  5012. RPMove();
  5013. }
  5014.  
  5015. else if(c == 'T') {
  5016. R2Move();
  5017. }
  5018.  
  5019. else if(c == 'L') {
  5020. LMove();
  5021. }
  5022.  
  5023. else if(c == 'M') {
  5024. LPMove();
  5025. }
  5026.  
  5027. else if(c == 'N') {
  5028. L2Move();
  5029. }
  5030.  
  5031. else if(c == 'U') {
  5032. UMove();
  5033. }
  5034.  
  5035. else if(c == 'V') {
  5036. UPMove();
  5037. }
  5038.  
  5039. else if(c == 'W') {
  5040. U2Move();
  5041. }
  5042.  
  5043. else if(c == 'F') {
  5044. FMove();
  5045. }
  5046.  
  5047. else if(c == 'G') {
  5048. FPMove();
  5049. }
  5050.  
  5051. else if(c == 'H') {
  5052. F2Move();
  5053. }
  5054.  
  5055. else if(c == 'B') {
  5056. BMove();
  5057. }
  5058.  
  5059. else if(c == 'C') {
  5060. BPMove();
  5061. }
  5062.  
  5063. else if(c == 'A') {
  5064. B2Move();
  5065. }
  5066.  
  5067. else if(c == 'D') {
  5068. DMove();
  5069. }
  5070.  
  5071. else if(c == 'E') {
  5072. DPMove();
  5073. }
  5074.  
  5075. else if(c == 'Z') {
  5076. D2Move();
  5077. }
  5078. }
  5079.  
  5080. for(int face = 0; face < 6; face++) {
  5081.  
  5082. CouleurEnum buffer[][] = new CouleurEnum[3][3];
  5083.  
  5084. int facebut = 0;
  5085.  
  5086. if(face == 0) {
  5087. buffer = FaceJaune;
  5088. }
  5089.  
  5090. else if(face == 1) {
  5091. buffer = FaceBleu;
  5092. }
  5093.  
  5094. else if(face == 2) {
  5095. buffer = FaceRouge;
  5096. }
  5097.  
  5098. else if(face == 3) {
  5099. buffer = FaceVert;
  5100. }
  5101.  
  5102. else if(face == 4) {
  5103. buffer = FaceOrange;
  5104. }
  5105.  
  5106. else if(face == 5) {
  5107. buffer = FaceBlanc;
  5108. }
  5109.  
  5110. for(int facex = 0; facex < 3; facex++) {
  5111. for(int facey = 0; facey < 3; facey++) {
  5112.  
  5113. if(buffer[facex][facey] == CouleurEnum.JAUNE) {
  5114. button[face][facebut].setId("bouton_jaune_");
  5115. }
  5116.  
  5117. else if(buffer[facex][facey] == CouleurEnum.BLEU) {
  5118. button[face][facebut].setId("bouton_bleu__");
  5119. }
  5120.  
  5121. else if(buffer[facex][facey] == CouleurEnum.ROUGE) {
  5122. button[face][facebut].setId("bouton_rouge_");
  5123. }
  5124.  
  5125. else if(buffer[facex][facey] == CouleurEnum.VERT) {
  5126. button[face][facebut].setId("bouton_vert__");
  5127. }
  5128.  
  5129. else if(buffer[facex][facey] == CouleurEnum.ORANGE) {
  5130. button[face][facebut].setId("bouton_orange");
  5131. }
  5132.  
  5133. else if(buffer[facex][facey] == CouleurEnum.BLANC) {
  5134. button[face][facebut].setId("bouton_blanc_");
  5135. }
  5136.  
  5137. facebut++;
  5138. }
  5139. }
  5140. }
  5141. }
  5142.  
  5143. /*
  5144. * SCRAMBLE
  5145. */
  5146.  
  5147. public static String generateScramble3x3() {
  5148.  
  5149. String scramble = "";
  5150. String lastFace = " ";
  5151.  
  5152. for(int i = 0; i < 26; i++) {
  5153. scramble += (lastFace = randomFace(lastFace)).charAt(0) + randomRotation() + " ";
  5154. }
  5155.  
  5156. return scramble;
  5157. }
  5158.  
  5159. /*
  5160. * FACE N'AYANT PAAS LE MEME AXE QUE LA PRECEDENTE
  5161. */
  5162.  
  5163. public static String randomFace(String lastFace) {
  5164.  
  5165. String face = faces[rand.nextInt(6)];
  5166. if(face.charAt(1) == lastFace.charAt(1)) {
  5167. return(randomFace(lastFace));
  5168. }
  5169. else {
  5170. return face;
  5171. }
  5172. }
  5173.  
  5174. /*
  5175. * GENERE UNE ROTATION DE LA FACE
  5176. */
  5177.  
  5178. public static String randomRotation() {
  5179.  
  5180. int rotation = rand.nextInt(3);
  5181.  
  5182. if(rotation == 0)
  5183. return "";
  5184. if(rotation == 1)
  5185. return "'";
  5186. if(rotation == 2)
  5187. return "2";
  5188. return null;
  5189.  
  5190. }
  5191.  
  5192. public void resetTableau() {
  5193.  
  5194. for(int x = 0; x < 3; x++) {
  5195. for(int y = 0; y < 3; y++) {
  5196. FaceJaune[x][y] = CouleurEnum.JAUNE;
  5197. FaceBleu[x][y] = CouleurEnum.BLEU;
  5198. FaceRouge[x][y] = CouleurEnum.ROUGE;
  5199. FaceVert[x][y] = CouleurEnum.VERT;
  5200. FaceOrange[x][y] = CouleurEnum.ORANGE;
  5201. FaceBlanc[x][y] = CouleurEnum.BLANC;
  5202.  
  5203. }
  5204. }
  5205. }
  5206.  
  5207. public void resetCube() {
  5208.  
  5209. resetTableau();
  5210.  
  5211. for(int x = 0; x < 6; x++) {
  5212. for(int y = 0; y < 9; y++) {
  5213.  
  5214. if(x == 0) {
  5215. button[x][y].setId("bouton_jaune_");
  5216. }
  5217.  
  5218. else if(x == 1) {
  5219. button[x][y].setId("bouton_bleu__");
  5220. }
  5221.  
  5222. else if(x == 2) {
  5223. button[x][y].setId("bouton_rouge_");
  5224. }
  5225.  
  5226. else if(x == 3) {
  5227. button[x][y].setId("bouton_vert__");
  5228. }
  5229.  
  5230. else if(x == 4) {
  5231. button[x][y].setId("bouton_orange");
  5232. }
  5233.  
  5234. else if(x == 5) {
  5235. button[x][y].setId("bouton_blanc_");
  5236. }
  5237. }
  5238. }
  5239.  
  5240. melange_env = "";
  5241. }
  5242. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement