Advertisement
LucasSousa

Timer v2015.02

Feb 16th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 53.59 KB | None | 0 0
  1. //Classe principal
  2.  
  3. package javaapplication1;
  4.  
  5. import java.awt.*;
  6. import java.awt.event.*;
  7. import java.util.ArrayList;
  8. import javax.swing.*;
  9.  
  10. public class CRONO3 extends JFrame {
  11.  
  12.     long minutoFinal;
  13.     long centésimos;
  14.  
  15.     static JLabel tempoCorrendo;
  16.  
  17.     static boolean contador = true;
  18.     static boolean contador2 = true;
  19.     static boolean contador3 = true;
  20.  
  21.     boolean prontoParaPause = false;
  22.     boolean botãoSemUtilidadePorEnquanto = false;
  23.  
  24.     JLabel label1;
  25.     JLabel label2;
  26.     JLabel label3;
  27.     JLabel label4;
  28.  
  29.     JButton botãoStart;
  30.     JButton botãoStop;
  31.     JButton botãoStart2;
  32.  
  33.     Scramble3x3 scramble1 = new Scramble3x3();
  34.     ScrambleMegaminx scramble2 = new ScrambleMegaminx();
  35.  
  36.     public CRONO3() {
  37.  
  38.        
  39.         ArrayList<Integer> listaCents = new ArrayList<>();
  40.         ArrayList<Integer> listaSeg = new ArrayList<>();
  41.         ArrayList<Integer> listaMin = new ArrayList<>();
  42.         ArrayList<Integer> listaTotal = new ArrayList<>();
  43.  
  44.         setTitle("Lucas's Timer");
  45.         setSize(1400, 400);
  46.         setDefaultCloseOperation(3);
  47.         setLayout(new FlowLayout(1));
  48.        
  49.  
  50.         label1 = new JLabel();
  51.         //label1.setText("Scramble: " + String.valueOf(Scrambler3x3.embaralhar3x3()));
  52.         label1.setText("<html>Scramble:<br>"
  53.                 + scramble2.embaralharMegaminx() + "<br>"
  54.                 + scramble2.embaralharMegaminx() + "<br>"
  55.                 + scramble2.embaralharMegaminx() + "<br>"
  56.                 + scramble2.embaralharMegaminx() + "<br>"
  57.                 + scramble2.embaralharMegaminx() + "<br>"
  58.                 + scramble2.embaralharMegaminx() + "<br>"
  59.                 + scramble2.embaralharMegaminx() + "<br>"
  60.                 );
  61.         label1.setFont(new Font(null, 0, 20));
  62.         label1.setLayout(new FlowLayout((int) JFrame.TOP_ALIGNMENT));
  63.         add(label1);
  64.  
  65.         tempoCorrendo = new JLabel();
  66.         tempoCorrendo.setText("00:00.00");
  67.         tempoCorrendo.setFont(new Font("Times New Roman", 1, 200));
  68.         add(tempoCorrendo);
  69.  
  70.         label3 = new JLabel("Media: 00:00.00");
  71.         label3.setFont(new Font(null, 1, 20));
  72.         add(label3);
  73.  
  74.         label4 = new JLabel();
  75.         add(label4);
  76.  
  77.         Cronometragem timing = new Cronometragem(tempoCorrendo);
  78.         InspTime inspeção = new InspTime(tempoCorrendo);
  79.         //LongMedia media = new LongMedia();
  80.  
  81.         botãoStart = new JButton("Start");
  82.         botãoStart.setVisible(false);
  83.         botãoStart.setForeground(Color.red);
  84.         botãoStart.setToolTipText("Press Space to start");
  85.         botãoStop = new JButton("Stop");
  86.         botãoStop.setForeground(Color.red);
  87.         botãoStop.setToolTipText("Press Space to stop");
  88.         botãoStop.setEnabled(false);
  89.         botãoStart2 = new JButton("Start Insp");
  90.  
  91.         botãoStart2.addActionListener(new ActionListener() {
  92.             public void actionPerformed(ActionEvent eventoDoBotão) {
  93.                 if (inspeção.inspeçãoAtivada == false) {
  94.                     inspeção.start();
  95.                     tempoCorrendo.setText("15");
  96.                     label1.setText("");
  97.                     label3.setText("");
  98.                     tempoCorrendo.setFont(new Font("Times New Roman", 1, 300));
  99.                     setSize(800, 400);
  100.                     setLocationRelativeTo(null);
  101.                     botãoStart2.setVisible(false);
  102.                     botãoStart.setVisible(true);
  103.                 }
  104.  
  105.                 iniciarInspeção(eventoDoBotão);
  106.                 tempoCorrendo.setText("15");
  107.  
  108.                 botãoStart2.setVisible(false);
  109.                 botãoStart.setVisible(true);
  110.  
  111.                 label1.setText("");
  112.                 label3.setText("");
  113.                 tempoCorrendo.setFont(new Font("Times New Roman", 1, 300));
  114.                 setSize(800, 400);
  115.                 setLocationRelativeTo(null);
  116.                 botãoStart2.setVisible(false);
  117.                 botãoStart.setVisible(true);
  118.  
  119.             }
  120.         });
  121.  
  122.         botãoStart.addActionListener(new ActionListener() {
  123.             public void actionPerformed(ActionEvent eventoDoBotão) {
  124.  
  125.                 if (timing.threadCronoON == false) {
  126.                     timing.start();
  127.                     //media.start();
  128.  
  129.                     tempoCorrendo.setForeground(Color.BLACK);
  130.                     botãoStart.setEnabled(false);
  131.                     botãoStop.setEnabled(true);
  132.                     pausarInspeção(eventoDoBotão);
  133.                     inspeção.segInsp = 15;
  134.                     tempoCorrendo.setText("15");
  135.                     tempoCorrendo.setFont(new Font("Times New Roman", 1, 200));
  136.                     setSize(800, 340);
  137.                     setLocationRelativeTo(null);
  138.  
  139.                 }
  140.  
  141.                 if ((timing.centésimo > 0) || (timing.minuto > 0) || (timing.segundo > 0)) {
  142.                     timing.centésimo = 0;
  143.                     timing.minuto = 0;
  144.                     timing.segundo = 0;
  145.                     botãoStart.setEnabled(false);
  146.                     botãoStop.setEnabled(true);
  147.                     iniciarInspeção(eventoDoBotão);
  148.                     inspeção.segInsp = 15;
  149.                     tempoCorrendo.setText("15");
  150.                     tempoCorrendo.setFont(new Font("Times New Roman", 1, 200));
  151.                     setSize(800, 340);
  152.                     setLocationRelativeTo(null);
  153.                 }
  154.  
  155.                 iniciarTimer(eventoDoBotão);
  156.                 iniciarLongMedia(eventoDoBotão);
  157.                 pausarInspeção(eventoDoBotão);
  158.  
  159.                 tempoCorrendo.setForeground(Color.BLACK);
  160.                 tempoCorrendo.setFont(new Font("Times New Roman", 1, 200));
  161.                 setSize(800, 340);
  162.                 setLocationRelativeTo(null);
  163.             }
  164.         });
  165.  
  166.         botãoStop.addActionListener(new ActionListener() {
  167.             public void actionPerformed(ActionEvent eventoDoBotão) {
  168.  
  169.                 pausarTimer(eventoDoBotão);
  170.                 pausarLongMedia(eventoDoBotão);
  171.  
  172.                 int totalCents = 0;
  173.                 int totalSeg = 0;
  174.                 int totalMin = 0;
  175.  
  176.                 listaCents.add(timing.centésimo);
  177.                 listaSeg.add(timing.segundo);
  178.                 listaMin.add(timing.minuto);
  179.                
  180.                 listaTotal.add(timing.minuto);
  181.                 listaTotal.add(timing.segundo);
  182.                 listaTotal.add(timing.centésimo);
  183.                
  184.                 //System.out.println("Lista: " + listaTotal);
  185.                
  186.                 for (int i : listaSeg) {
  187.                     totalSeg += i;
  188.                 }
  189.                 for (int i : listaCents) {
  190.                     totalCents += i;
  191.                 }                
  192.                 for (int i : listaMin) {
  193.                     totalMin += i;
  194.                 }
  195.                
  196.                 //label1.setText("Scramble: " + String.valueOf(Scrambler3x3.embaralhar3x3()));
  197.                 label1.setText("<html>Scramble:<br>"
  198.                 + scramble2.embaralharMegaminx() + "<br>"
  199.                 + scramble2.embaralharMegaminx() + "<br>"
  200.                 + scramble2.embaralharMegaminx() + "<br>"
  201.                 + scramble2.embaralharMegaminx() + "<br>"
  202.                 + scramble2.embaralharMegaminx() + "<br>"
  203.                 + scramble2.embaralharMegaminx() + "<br>"
  204.                 + scramble2.embaralharMegaminx() + "<br>"
  205.                 );
  206.                 setSize(1400, 310);
  207.                 setLocationRelativeTo(null);
  208.                
  209. //                if (timing.minuto < 10) {
  210. //                    label4.setText("TimeList: 0"+ timing.minuto + ":" +timing.segundo + "." +timing.centésimo);
  211. //                }
  212. //                if (timing.segundo < 10) {
  213. //                    label4.setText("TimeList: 0"+timing.minuto + ":0" +timing.segundo + "." +timing.centésimo);
  214. //                }
  215. //                if (timing.centésimo < 10) {
  216. //                    label4.setText("TimeList: 0"+timing.minuto + ":0" +timing.segundo + ".0" +timing.centésimo);
  217. //                }
  218.                
  219.                
  220.  
  221.                 if (timing.minuto < 10) {
  222.                     label3.setText("Média: 0"+(totalMin/listaMin.size()) + ":" +(totalSeg/listaSeg.size()) + "." +(totalCents/listaCents.size()));
  223.                 }
  224.                 if (timing.segundo < 10) {
  225.                     label3.setText("Média: 0"+(totalMin/listaMin.size()) + ":0" +(totalSeg/listaSeg.size()) + "." +(totalCents/listaCents.size()));
  226.                 }
  227.                 if (timing.centésimo < 10) {
  228.                     label3.setText("Média: 0"+(totalMin/listaMin.size()) + ":0" +(totalSeg/listaSeg.size()) + ".0" +(totalCents/listaCents.size()));
  229.                 }
  230.  
  231.                 botãoStop.setEnabled(false);
  232.                 botãoStart.setEnabled(true);
  233.  
  234.                 pausarInspeção(eventoDoBotão);
  235.  
  236.                 botãoStart2.setVisible(true);
  237.                 botãoStart.setVisible(false);
  238.             }
  239.         });
  240.  
  241.         add(botãoStart2);
  242.         reagirSpace(botãoStart2);
  243.  
  244.         add(botãoStart);
  245.         reagirSpace(botãoStart);
  246.  
  247.         add(botãoStop);
  248.         reagirSpace(botãoStop);
  249.     }
  250.  
  251.     public static void reagirSpace(JButton botão) {
  252.         botão.registerKeyboardAction(botão.getActionForKeyStroke(KeyStroke.getKeyStroke(32, 0, false)), KeyStroke.getKeyStroke(32, 0, false), 2);
  253.  
  254.         botão.registerKeyboardAction(botão.getActionForKeyStroke(KeyStroke.getKeyStroke(32, 0, true)), KeyStroke.getKeyStroke(32, 0, true), 2);
  255.     }
  256.  
  257.     void pausarTimer(ActionEvent evt) {
  258.         contador = false;
  259.     }
  260.  
  261.     void pausarInspeção(ActionEvent evt) {
  262.         contador2 = false;
  263.     }
  264.  
  265.     void pausarLongMedia(ActionEvent evt) {
  266.         contador3 = false;
  267.     }
  268.  
  269.     public static boolean isContador() {
  270.         return contador;
  271.     }
  272.  
  273.     public static boolean isContadorInsp() {
  274.         return contador2;
  275.     }
  276.  
  277.     public static boolean isContadorLongMedia() {
  278.         return contador3;
  279.     }
  280.  
  281.     void iniciarTimer(ActionEvent evt) {
  282.         tempoCorrendo.revalidate();
  283.         contador = true;
  284.     }
  285.  
  286.     void iniciarInspeção(ActionEvent evt) {
  287.         tempoCorrendo.revalidate();
  288.         contador2 = true;
  289.     }
  290.  
  291.     void iniciarLongMedia(ActionEvent evt) {
  292.         contador3 = true;
  293.     }
  294.  
  295.     public static void main(String[] args) {
  296.         CRONO3 tela = new CRONO3();
  297.         Panel meuPainel = new Panel();
  298.        
  299.         tela.setVisible(true);
  300.         tela.setLocationRelativeTo(null);
  301.         //tela.setResizable(false);
  302.        
  303.         tela.add(meuPainel);
  304.  
  305.     }
  306. }
  307.  
  308.  
  309. ////////////CRONOMETRAGEM
  310.  
  311. package javaapplication1;
  312.  
  313. import javax.swing.JLabel;
  314.  
  315. public class Cronometragem extends Thread {
  316.  
  317.     private JLabel label;
  318.     boolean threadCronoON = false;
  319.     boolean threadCronoOFF = true;
  320.     int centésimo = 0;
  321.     int segundo = 0;
  322.     int minuto = 0;
  323.  
  324.     public Cronometragem(JLabel stringTempo) {
  325.         label = stringTempo;
  326.     }
  327.  
  328.     public void run() {
  329.  
  330.         try {
  331.             while(true) {
  332.                 Thread.sleep((long) 9,6737);
  333.  
  334.                 threadCronoON = true;
  335.                
  336.                 if (CRONO3.isContador()) {
  337.                     centésimo++;
  338.                     if (centésimo == 100) {
  339.                         centésimo = 0;
  340.                         segundo++;
  341.                     }
  342.                     if (segundo == 60) {
  343.                         segundo = 0;
  344.                         minuto += 1;
  345.                     }
  346.                     String timerMinuto = "";
  347.                     String timerSegundo = "";
  348.                     String timerCentésimo = "";
  349.                     if (minuto < 10) {
  350.                         timerMinuto = "0" + minuto;
  351.                     } else {
  352.                         timerMinuto = String.valueOf(minuto);
  353.                     }
  354.                     if (segundo < 10) {
  355.                         timerSegundo = "0" + segundo;
  356.                     } else {
  357.                         timerSegundo = String.valueOf(segundo);
  358.                     }
  359.                     if (centésimo < 10) {
  360.                         timerCentésimo = "0" + centésimo;
  361.                     } else {
  362.                         timerCentésimo = String.valueOf(centésimo);
  363.                     }
  364.                     label.setText(timerMinuto + ":" + timerSegundo + "." + timerCentésimo);
  365.                     label.revalidate();
  366.                 }
  367.             }
  368.         } catch (InterruptedException e) {
  369.            
  370.             stop();
  371.             threadCronoON = false;
  372.             System.out.println("Bugou" + "\tValor de threadCronoON: " + threadCronoON);
  373.         }
  374.     }
  375. }
  376.  
  377. /////////////////////////////INSP TIME
  378.  
  379. package javaapplication1;
  380.  
  381. import java.awt.Color;
  382. import javax.swing.JLabel;
  383.  
  384. public class InspTime extends Thread {
  385.  
  386.     private JLabel labelInsp;
  387.     boolean inspeçãoAtivada = false;
  388.     boolean inspeçãoDesativada = false;
  389.     boolean ganhouDNF = false;
  390.     int segInsp = 15;
  391.  
  392.     public InspTime(JLabel stringInsp) {
  393.         labelInsp = stringInsp;
  394.     }
  395.  
  396.     public void run() {
  397.         for (;;) {
  398.             try {
  399.                 inspeçãoAtivada = true;
  400.  
  401.                 Thread.sleep(1000L);
  402.                 if (CRONO3.isContadorInsp()) {
  403.                     segInsp--;
  404.  
  405.                     labelInsp.setText(String.valueOf(this.segInsp));
  406.                     labelInsp.revalidate();
  407.                    
  408.                     if(segInsp <= 3){
  409.                        
  410.                         labelInsp.setForeground(Color.RED);
  411.                     }
  412.                    
  413.                     if (segInsp <= 0) {
  414.                         labelInsp.setForeground(Color.BLACK);
  415.                         labelInsp.setText("DNF");
  416.                         labelInsp.revalidate();
  417.                         ganhouDNF = true;
  418.                     }
  419.                 }
  420.             } catch (InterruptedException e) {
  421.             }
  422.         }
  423.     }
  424. }
  425.  
  426. ///////////////2x2 SCR
  427.  
  428. package javaapplication1;
  429.  
  430. import java.util.ArrayList;
  431. import java.util.Random;
  432.  
  433. public class Scramble2x2 {
  434.  
  435.     public ArrayList embaralhar2x2() {
  436.        
  437.         ArrayList<String> lista = new ArrayList<>();
  438.        
  439.         Random r = new Random();
  440.        
  441.         String[] moves1 = {"F", "U", "R"};
  442.         String[] moves2 = {" ", "' ", "2 "};
  443.        
  444.         String s = "";
  445.         String f = "";
  446.        
  447.         for (int i = 0; i < 8; i++) {
  448.             do {
  449.                 f = moves1[r.nextInt(3)];
  450.             } while (f == s);
  451.             s = f;
  452.             String u = moves2[r.nextInt(3)];
  453.             lista.add(s + u);
  454.         }
  455.        
  456.         return lista;
  457.        
  458.     }
  459. }
  460.  
  461. ////////////////////////////3X3 SCR
  462.  
  463. package javaapplication1;
  464.  
  465. import java.util.ArrayList;
  466. import java.util.Arrays;
  467. import java.util.Random;
  468.  
  469. public class Scramble3x3{
  470.    
  471.   public static String embaralhar3x3()  {
  472.      
  473.     Random r = new Random();
  474.    
  475.    
  476.    
  477.     String[] globalMoves = { "F", "B", "U", "D", "R", "L" };
  478.    
  479.     String[] globalMovesMenosMoves1 = { "U", "D", "R", "L" };
  480.     String[] globalMovesMenosMoves2 = { "B", "F", "L", "R" };
  481.     String[] globalMovesMenosMoves3 = { "F", "B", "U", "D" };
  482.    
  483.     String[] sentido = { " ", "' ", "2 " };
  484.    
  485.     String[] moves1 = { "B", "F" };
  486.     String[] moves2 = { "D", "U" };
  487.     String[] moves3 = { "L", "R" };
  488.    
  489.     String mm1 = sentido[r.nextInt(3)];
  490.     String mm2 = sentido[r.nextInt(3)];
  491.     String mm3 = sentido[r.nextInt(3)];
  492.     String mm4 = sentido[r.nextInt(3)];
  493.     String mm5 = sentido[r.nextInt(3)];
  494.     String mm6 = sentido[r.nextInt(3)];
  495.     String mm7 = sentido[r.nextInt(3)];
  496.     String mm8 = sentido[r.nextInt(3)];
  497.     String mm9 = sentido[r.nextInt(3)];
  498.     String mm10 = sentido[r.nextInt(3)];
  499.     String mm11 = sentido[r.nextInt(3)];
  500.     String mm12 = sentido[r.nextInt(3)];
  501.     String mm13 = sentido[r.nextInt(3)];
  502.     String mm14 = sentido[r.nextInt(3)];
  503.     String mm15 = sentido[r.nextInt(3)];
  504.     String mm16 = sentido[r.nextInt(3)];
  505.     String mm17 = sentido[r.nextInt(3)];
  506.     String mm18 = sentido[r.nextInt(3)];
  507.     String mm19 = sentido[r.nextInt(3)];
  508.     String mm20 = sentido[r.nextInt(3)];
  509.     String mm21 = sentido[r.nextInt(3)];
  510.     String mm22 = sentido[r.nextInt(3)];
  511.     String mm23 = sentido[r.nextInt(3)];
  512.     String mm24 = sentido[r.nextInt(3)];
  513.     String mm25 = sentido[r.nextInt(3)];
  514.    
  515.     String m1 = globalMoves[r.nextInt(6)];
  516.    
  517.     String m2 = "";
  518.     do
  519.     {
  520.       m2 = globalMoves[r.nextInt(6)];
  521.     } while (m2 == m1);
  522.    
  523.     boolean opostosOk = false;
  524.     int testeA = Arrays.binarySearch(moves1, m1);
  525.     int testeB = Arrays.binarySearch(moves1, m2);
  526.     int testeC = Arrays.binarySearch(moves2, m1);
  527.     int testeD = Arrays.binarySearch(moves2, m2);
  528.     int testeE = Arrays.binarySearch(moves3, m1);
  529.     int testeF = Arrays.binarySearch(moves3, m2);
  530.     if (((testeA >= 0) && (testeB >= 0)) || ((testeC >= 0) && (testeD >= 0)) || ((testeE >= 0) && (testeF >= 0))) {
  531.       opostosOk = true;
  532.     }
  533.     String m3 = "";
  534.     if (opostosOk)
  535.     {
  536.       int buscaM11 = Arrays.binarySearch(moves1, m1);
  537.       int buscaM12 = Arrays.binarySearch(moves2, m1);
  538.       int buscaM13 = Arrays.binarySearch(moves3, m1);
  539.       if (buscaM11 >= 0) {
  540.         do
  541.         {
  542.           m3 = globalMovesMenosMoves1[r.nextInt(4)];
  543.         } while (m3 == m2);
  544.       } else if (buscaM12 >= 0) {
  545.         do
  546.         {
  547.           m3 = globalMovesMenosMoves2[r.nextInt(4)];
  548.         } while (m3 == m2);
  549.       } else if (buscaM13 >= 0) {
  550.         do
  551.         {
  552.           m3 = globalMovesMenosMoves3[r.nextInt(4)];
  553.         } while (m3 == m2);
  554.       }
  555.     }
  556.     else
  557.     {
  558.       do
  559.       {
  560.         m3 = globalMoves[r.nextInt(6)];
  561.       } while (m3 == m2);
  562.     }
  563.     boolean opostosOk2 = false;
  564.     int testeA2 = Arrays.binarySearch(moves1, m2);
  565.     int testeB2 = Arrays.binarySearch(moves1, m3);
  566.     int testeC2 = Arrays.binarySearch(moves2, m2);
  567.     int testeD2 = Arrays.binarySearch(moves2, m3);
  568.     int testeE2 = Arrays.binarySearch(moves3, m2);
  569.     int testeF2 = Arrays.binarySearch(moves3, m3);
  570.     if (((testeA2 >= 0) && (testeB2 >= 0)) || ((testeC2 >= 0) && (testeD2 >= 0)) || ((testeE2 >= 0) && (testeF2 >= 0))) {
  571.       opostosOk2 = true;
  572.     }
  573.     String m4 = "";
  574.     if (opostosOk2)
  575.     {
  576.       int buscaM11 = Arrays.binarySearch(moves1, m2);
  577.       int buscaM12 = Arrays.binarySearch(moves2, m2);
  578.       int buscaM13 = Arrays.binarySearch(moves3, m2);
  579.       if (buscaM11 >= 0) {
  580.         m4 = globalMovesMenosMoves1[r.nextInt(4)];
  581.       } else if (buscaM12 >= 0) {
  582.         m4 = globalMovesMenosMoves2[r.nextInt(4)];
  583.       } else if (buscaM13 >= 0) {
  584.         m4 = globalMovesMenosMoves3[r.nextInt(4)];
  585.       }
  586.     }
  587.     else
  588.     {
  589.       do
  590.       {
  591.         m4 = globalMoves[r.nextInt(6)];
  592.       } while (m4 == m3);
  593.     }
  594.     boolean opostosOk3 = false;
  595.     int testeA3 = Arrays.binarySearch(moves1, m3);
  596.     int testeB3 = Arrays.binarySearch(moves1, m4);
  597.     int testeC3 = Arrays.binarySearch(moves2, m3);
  598.     int testeD3 = Arrays.binarySearch(moves2, m4);
  599.     int testeE3 = Arrays.binarySearch(moves3, m3);
  600.     int testeF3 = Arrays.binarySearch(moves3, m4);
  601.     if (((testeA3 >= 0) && (testeB3 >= 0)) || ((testeC3 >= 0) && (testeD3 >= 0)) || ((testeE3 >= 0) && (testeF3 >= 0))) {
  602.       opostosOk3 = true;
  603.     }
  604.     String m5 = "";
  605.     if (opostosOk3)
  606.     {
  607.       int buscaM11 = Arrays.binarySearch(moves1, m3);
  608.       int buscaM12 = Arrays.binarySearch(moves2, m3);
  609.       int buscaM13 = Arrays.binarySearch(moves3, m3);
  610.       if (buscaM11 >= 0) {
  611.         m5 = globalMovesMenosMoves1[r.nextInt(4)];
  612.       } else if (buscaM12 >= 0) {
  613.         m5 = globalMovesMenosMoves2[r.nextInt(4)];
  614.       } else if (buscaM13 >= 0) {
  615.         m5 = globalMovesMenosMoves3[r.nextInt(4)];
  616.       }
  617.     }
  618.     else
  619.     {
  620.       do
  621.       {
  622.         m5 = globalMoves[r.nextInt(6)];
  623.       } while (m5 == m4);
  624.     }
  625.     boolean opostosOk4 = false;
  626.     int testeA4 = Arrays.binarySearch(moves1, m4);
  627.     int testeB4 = Arrays.binarySearch(moves1, m5);
  628.     int testeC4 = Arrays.binarySearch(moves2, m4);
  629.     int testeD4 = Arrays.binarySearch(moves2, m5);
  630.     int testeE4 = Arrays.binarySearch(moves3, m4);
  631.     int testeF4 = Arrays.binarySearch(moves3, m5);
  632.     if (((testeA4 >= 0) && (testeB4 >= 0)) || ((testeC4 >= 0) && (testeD4 >= 0)) || ((testeE4 >= 0) && (testeF4 >= 0))) {
  633.       opostosOk4 = true;
  634.     }
  635.     String m6 = "";
  636.     if (opostosOk4)
  637.     {
  638.       int buscaM11 = Arrays.binarySearch(moves1, m4);
  639.       int buscaM12 = Arrays.binarySearch(moves2, m4);
  640.       int buscaM13 = Arrays.binarySearch(moves3, m4);
  641.       if (buscaM11 >= 0) {
  642.         m6 = globalMovesMenosMoves1[r.nextInt(4)];
  643.       } else if (buscaM12 >= 0) {
  644.         m6 = globalMovesMenosMoves2[r.nextInt(4)];
  645.       } else if (buscaM13 >= 0) {
  646.         m6 = globalMovesMenosMoves3[r.nextInt(4)];
  647.       }
  648.     }
  649.     else
  650.     {
  651.       do
  652.       {
  653.         m6 = globalMoves[r.nextInt(6)];
  654.       } while (m6 == m5);
  655.     }
  656.     boolean opostosOk5 = false;
  657.     int testeA5 = Arrays.binarySearch(moves1, m5);
  658.     int testeB5 = Arrays.binarySearch(moves1, m6);
  659.     int testeC5 = Arrays.binarySearch(moves2, m5);
  660.     int testeD5 = Arrays.binarySearch(moves2, m6);
  661.     int testeE5 = Arrays.binarySearch(moves3, m4);
  662.     int testeF5 = Arrays.binarySearch(moves3, m5);
  663.     if (((testeA5 >= 0) && (testeB5 >= 0)) || ((testeC5 >= 0) && (testeD5 >= 0)) || ((testeE5 >= 0) && (testeF5 >= 0))) {
  664.       opostosOk5 = true;
  665.     }
  666.     String m7 = "";
  667.     if (opostosOk5)
  668.     {
  669.       int buscaM11 = Arrays.binarySearch(moves1, m5);
  670.       int buscaM12 = Arrays.binarySearch(moves2, m5);
  671.       int buscaM13 = Arrays.binarySearch(moves3, m5);
  672.       if (buscaM11 >= 0) {
  673.         do
  674.         {
  675.           m7 = globalMovesMenosMoves1[r.nextInt(4)];
  676.         } while (m7 == m6);
  677.       } else if (buscaM12 >= 0) {
  678.         do
  679.         {
  680.           m7 = globalMovesMenosMoves2[r.nextInt(4)];
  681.         } while (m7 == m6);
  682.       } else if (buscaM13 >= 0) {
  683.         do
  684.         {
  685.           m7 = globalMovesMenosMoves3[r.nextInt(4)];
  686.         } while (m7 == m6);
  687.       }
  688.     }
  689.     else
  690.     {
  691.       do
  692.       {
  693.         m7 = globalMoves[r.nextInt(6)];
  694.       } while (m7 == m6);
  695.     }
  696.     boolean opostosOk6 = false;
  697.     int testeA6 = Arrays.binarySearch(moves1, m6);
  698.     int testeB6 = Arrays.binarySearch(moves1, m7);
  699.     int testeC6 = Arrays.binarySearch(moves2, m6);
  700.     int testeD6 = Arrays.binarySearch(moves2, m7);
  701.     int testeE6 = Arrays.binarySearch(moves3, m6);
  702.     int testeF6 = Arrays.binarySearch(moves3, m7);
  703.     if (((testeA6 >= 0) && (testeB6 >= 0)) || ((testeC6 >= 0) && (testeD6 >= 0)) || ((testeE6 >= 0) && (testeF6 >= 0))) {
  704.       opostosOk6 = true;
  705.     }
  706.     String m8 = "";
  707.     if (opostosOk6)
  708.     {
  709.       int buscaM11 = Arrays.binarySearch(moves1, m6);
  710.       int buscaM12 = Arrays.binarySearch(moves2, m6);
  711.       int buscaM13 = Arrays.binarySearch(moves3, m6);
  712.       if (buscaM11 >= 0) {
  713.         m8 = globalMovesMenosMoves1[r.nextInt(4)];
  714.       } else if (buscaM12 >= 0) {
  715.         m8 = globalMovesMenosMoves2[r.nextInt(4)];
  716.       } else if (buscaM13 >= 0) {
  717.         m8 = globalMovesMenosMoves3[r.nextInt(4)];
  718.       }
  719.     }
  720.     else
  721.     {
  722.       do
  723.       {
  724.         m8 = globalMoves[r.nextInt(6)];
  725.       } while (m8 == m7);
  726.     }
  727.     boolean opostosOk7 = false;
  728.     int testeA7 = Arrays.binarySearch(moves1, m7);
  729.     int testeB7 = Arrays.binarySearch(moves1, m8);
  730.     int testeC7 = Arrays.binarySearch(moves2, m7);
  731.     int testeD7 = Arrays.binarySearch(moves2, m8);
  732.     int testeE7 = Arrays.binarySearch(moves3, m7);
  733.     int testeF7 = Arrays.binarySearch(moves3, m8);
  734.     if (((testeA7 >= 0) && (testeB7 >= 0)) || ((testeC7 >= 0) && (testeD7 >= 0)) || ((testeE7 >= 0) && (testeF7 >= 0))) {
  735.       opostosOk7 = true;
  736.     }
  737.     String m9 = "";
  738.     if (opostosOk7)
  739.     {
  740.       int buscaM11 = Arrays.binarySearch(moves1, m7);
  741.       int buscaM12 = Arrays.binarySearch(moves2, m7);
  742.       int buscaM13 = Arrays.binarySearch(moves3, m7);
  743.       if (buscaM11 >= 0) {
  744.         m9 = globalMovesMenosMoves1[r.nextInt(4)];
  745.       } else if (buscaM12 >= 0) {
  746.         m9 = globalMovesMenosMoves2[r.nextInt(4)];
  747.       } else if (buscaM13 >= 0) {
  748.         m9 = globalMovesMenosMoves3[r.nextInt(4)];
  749.       }
  750.     }
  751.     else
  752.     {
  753.       do
  754.       {
  755.         m9 = globalMoves[r.nextInt(6)];
  756.       } while (m9 == m8);
  757.     }
  758.     boolean opostosOk8 = false;
  759.     int testeA8 = Arrays.binarySearch(moves1, m8);
  760.     int testeB8 = Arrays.binarySearch(moves1, m9);
  761.     int testeC8 = Arrays.binarySearch(moves2, m8);
  762.     int testeD8 = Arrays.binarySearch(moves2, m9);
  763.     int testeE8 = Arrays.binarySearch(moves3, m8);
  764.     int testeF8 = Arrays.binarySearch(moves3, m9);
  765.     if (((testeA8 >= 0) && (testeB8 >= 0)) || ((testeC8 >= 0) && (testeD8 >= 0)) || ((testeE8 >= 0) && (testeF8 >= 0))) {
  766.       opostosOk8 = true;
  767.     }
  768.     String m10 = "";
  769.     if (opostosOk8)
  770.     {
  771.       int buscaM11 = Arrays.binarySearch(moves1, m8);
  772.       int buscaM12 = Arrays.binarySearch(moves2, m8);
  773.       int buscaM13 = Arrays.binarySearch(moves3, m8);
  774.       if (buscaM11 >= 0) {
  775.         m10 = globalMovesMenosMoves1[r.nextInt(4)];
  776.       } else if (buscaM12 >= 0) {
  777.         m10 = globalMovesMenosMoves2[r.nextInt(4)];
  778.       } else if (buscaM13 >= 0) {
  779.         m10 = globalMovesMenosMoves3[r.nextInt(4)];
  780.       }
  781.     }
  782.     else
  783.     {
  784.       do
  785.       {
  786.         m10 = globalMoves[r.nextInt(6)];
  787.       } while (m10 == m9);
  788.     }
  789.     boolean opostosOk9 = false;
  790.     int testeA9 = Arrays.binarySearch(moves1, m9);
  791.     int testeB9 = Arrays.binarySearch(moves1, m10);
  792.     int testeC9 = Arrays.binarySearch(moves2, m9);
  793.     int testeD9 = Arrays.binarySearch(moves2, m10);
  794.     int testeE9 = Arrays.binarySearch(moves3, m9);
  795.     int testeF9 = Arrays.binarySearch(moves3, m10);
  796.     if (((testeA9 >= 0) && (testeB9 >= 0)) || ((testeC9 >= 0) && (testeD9 >= 0)) || ((testeE9 >= 0) && (testeF9 >= 0))) {
  797.       opostosOk9 = true;
  798.     }
  799.     String m11 = "";
  800.     if (opostosOk9)
  801.     {
  802.       int buscaM11 = Arrays.binarySearch(moves1, m9);
  803.       int buscaM12 = Arrays.binarySearch(moves2, m9);
  804.       int buscaM13 = Arrays.binarySearch(moves3, m9);
  805.       if (buscaM11 >= 0) {
  806.         m11 = globalMovesMenosMoves1[r.nextInt(4)];
  807.       } else if (buscaM12 >= 0) {
  808.         m11 = globalMovesMenosMoves2[r.nextInt(4)];
  809.       } else if (buscaM13 >= 0) {
  810.         m11 = globalMovesMenosMoves3[r.nextInt(4)];
  811.       }
  812.     }
  813.     else
  814.     {
  815.       do
  816.       {
  817.         m11 = globalMoves[r.nextInt(6)];
  818.       } while (m11 == m10);
  819.     }
  820.     boolean opostosOk10 = false;
  821.     int testeA10 = Arrays.binarySearch(moves1, m10);
  822.     int testeB10 = Arrays.binarySearch(moves1, m11);
  823.     int testeC10 = Arrays.binarySearch(moves2, m10);
  824.     int testeD10 = Arrays.binarySearch(moves2, m11);
  825.     int testeE10 = Arrays.binarySearch(moves3, m10);
  826.     int testeF10 = Arrays.binarySearch(moves3, m11);
  827.     if (((testeA10 >= 0) && (testeB10 >= 0)) || ((testeC10 >= 0) && (testeD10 >= 0)) || ((testeE10 >= 0) && (testeF10 >= 0))) {
  828.       opostosOk10 = true;
  829.     }
  830.     String m12 = "";
  831.     if (opostosOk10)
  832.     {
  833.       int buscaM11 = Arrays.binarySearch(moves1, m10);
  834.       int buscaM12 = Arrays.binarySearch(moves2, m10);
  835.       int buscaM13 = Arrays.binarySearch(moves3, m10);
  836.       if (buscaM11 >= 0) {
  837.         m12 = globalMovesMenosMoves1[r.nextInt(4)];
  838.       } else if (buscaM12 >= 0) {
  839.         m12 = globalMovesMenosMoves2[r.nextInt(4)];
  840.       } else if (buscaM13 >= 0) {
  841.         m12 = globalMovesMenosMoves3[r.nextInt(4)];
  842.       }
  843.     }
  844.     else
  845.     {
  846.       do
  847.       {
  848.         m12 = globalMoves[r.nextInt(6)];
  849.       } while (m12 == m11);
  850.     }
  851.     boolean opostosOk11 = false;
  852.     int testeA11 = Arrays.binarySearch(moves1, m11);
  853.     int testeB11 = Arrays.binarySearch(moves1, m12);
  854.     int testeC11 = Arrays.binarySearch(moves2, m11);
  855.     int testeD11 = Arrays.binarySearch(moves2, m12);
  856.     int testeE11 = Arrays.binarySearch(moves3, m11);
  857.     int testeF11 = Arrays.binarySearch(moves3, m12);
  858.     if (((testeA11 >= 0) && (testeB11 >= 0)) || ((testeC11 >= 0) && (testeD11 >= 0)) || ((testeE11 >= 0) && (testeF11 >= 0))) {
  859.       opostosOk11 = true;
  860.     }
  861.     String m13 = "";
  862.     if (opostosOk11)
  863.     {
  864.       int buscaM11 = Arrays.binarySearch(moves1, m11);
  865.       int buscaM12 = Arrays.binarySearch(moves2, m11);
  866.       int buscaM13 = Arrays.binarySearch(moves3, m11);
  867.       if (buscaM11 >= 0) {
  868.         m13 = globalMovesMenosMoves1[r.nextInt(4)];
  869.       } else if (buscaM12 >= 0) {
  870.         m13 = globalMovesMenosMoves2[r.nextInt(4)];
  871.       } else if (buscaM13 >= 0) {
  872.         m13 = globalMovesMenosMoves3[r.nextInt(4)];
  873.       }
  874.     }
  875.     else
  876.     {
  877.       do
  878.       {
  879.         m13 = globalMoves[r.nextInt(6)];
  880.       } while (m13 == m12);
  881.     }
  882.     boolean opostosOk12 = false;
  883.     int testeA12 = Arrays.binarySearch(moves1, m12);
  884.     int testeB12 = Arrays.binarySearch(moves1, m13);
  885.     int testeC12 = Arrays.binarySearch(moves2, m12);
  886.     int testeD12 = Arrays.binarySearch(moves2, m13);
  887.     int testeE12 = Arrays.binarySearch(moves3, m12);
  888.     int testeF12 = Arrays.binarySearch(moves3, m13);
  889.     if (((testeA12 >= 0) && (testeB12 >= 0)) || ((testeC12 >= 0) && (testeD12 >= 0)) || ((testeE12 >= 0) && (testeF12 >= 0))) {
  890.       opostosOk12 = true;
  891.     }
  892.     String m14 = "";
  893.     if (opostosOk12)
  894.     {
  895.       int buscaM11 = Arrays.binarySearch(moves1, m12);
  896.       int buscaM12 = Arrays.binarySearch(moves2, m12);
  897.       int buscaM13 = Arrays.binarySearch(moves3, m12);
  898.       if (buscaM11 >= 0) {
  899.         m14 = globalMovesMenosMoves1[r.nextInt(4)];
  900.       } else if (buscaM12 >= 0) {
  901.         m14 = globalMovesMenosMoves2[r.nextInt(4)];
  902.       } else if (buscaM13 >= 0) {
  903.         m14 = globalMovesMenosMoves3[r.nextInt(4)];
  904.       }
  905.     }
  906.     else
  907.     {
  908.       do
  909.       {
  910.         m14 = globalMoves[r.nextInt(6)];
  911.       } while (m14 == m13);
  912.     }
  913.     boolean opostosOk13 = false;
  914.     int testeA13 = Arrays.binarySearch(moves1, m13);
  915.     int testeB13 = Arrays.binarySearch(moves1, m14);
  916.     int testeC13 = Arrays.binarySearch(moves2, m13);
  917.     int testeD13 = Arrays.binarySearch(moves2, m14);
  918.     int testeE13 = Arrays.binarySearch(moves3, m13);
  919.     int testeF13 = Arrays.binarySearch(moves3, m14);
  920.     if (((testeA13 >= 0) && (testeB13 >= 0)) || ((testeC13 >= 0) && (testeD13 >= 0)) || ((testeE13 >= 0) && (testeF13 >= 0))) {
  921.       opostosOk13 = true;
  922.     }
  923.     String m15 = "";
  924.     if (opostosOk13)
  925.     {
  926.       int buscaM11 = Arrays.binarySearch(moves1, m13);
  927.       int buscaM12 = Arrays.binarySearch(moves2, m13);
  928.       int buscaM13 = Arrays.binarySearch(moves3, m13);
  929.       if (buscaM11 >= 0) {
  930.         m15 = globalMovesMenosMoves1[r.nextInt(4)];
  931.       } else if (buscaM12 >= 0) {
  932.         m15 = globalMovesMenosMoves2[r.nextInt(4)];
  933.       } else if (buscaM13 >= 0) {
  934.         m15 = globalMovesMenosMoves3[r.nextInt(4)];
  935.       }
  936.     }
  937.     else
  938.     {
  939.       do
  940.       {
  941.         m15 = globalMoves[r.nextInt(6)];
  942.       } while (m15 == m14);
  943.     }
  944.     boolean opostosOk14 = false;
  945.     int testeA14 = Arrays.binarySearch(moves1, m14);
  946.     int testeB14 = Arrays.binarySearch(moves1, m15);
  947.     int testeC14 = Arrays.binarySearch(moves2, m14);
  948.     int testeD14 = Arrays.binarySearch(moves2, m15);
  949.     int testeE14 = Arrays.binarySearch(moves3, m14);
  950.     int testeF14 = Arrays.binarySearch(moves3, m15);
  951.     if (((testeA14 >= 0) && (testeB14 >= 0)) || ((testeC14 >= 0) && (testeD14 >= 0)) || ((testeE14 >= 0) && (testeF14 >= 0))) {
  952.       opostosOk14 = true;
  953.     }
  954.     String m16 = "";
  955.     if (opostosOk14)
  956.     {
  957.       int buscaM11 = Arrays.binarySearch(moves1, m14);
  958.       int buscaM12 = Arrays.binarySearch(moves2, m14);
  959.       int buscaM13 = Arrays.binarySearch(moves3, m14);
  960.       if (buscaM11 >= 0) {
  961.         m16 = globalMovesMenosMoves1[r.nextInt(4)];
  962.       } else if (buscaM12 >= 0) {
  963.         m16 = globalMovesMenosMoves2[r.nextInt(4)];
  964.       } else if (buscaM13 >= 0) {
  965.         m16 = globalMovesMenosMoves3[r.nextInt(4)];
  966.       }
  967.     }
  968.     else
  969.     {
  970.       do
  971.       {
  972.         m16 = globalMoves[r.nextInt(6)];
  973.       } while (m16 == m15);
  974.     }
  975.     boolean opostosOk15 = false;
  976.     int testeA15 = Arrays.binarySearch(moves1, m15);
  977.     int testeB15 = Arrays.binarySearch(moves1, m16);
  978.     int testeC15 = Arrays.binarySearch(moves2, m15);
  979.     int testeD15 = Arrays.binarySearch(moves2, m16);
  980.     int testeE15 = Arrays.binarySearch(moves3, m15);
  981.     int testeF15 = Arrays.binarySearch(moves3, m16);
  982.     if (((testeA15 >= 0) && (testeB15 >= 0)) || ((testeC15 >= 0) && (testeD15 >= 0)) || ((testeE15 >= 0) && (testeF15 >= 0))) {
  983.       opostosOk15 = true;
  984.     }
  985.     String m17 = "";
  986.     if (opostosOk15)
  987.     {
  988.       int buscaM11 = Arrays.binarySearch(moves1, m15);
  989.       int buscaM12 = Arrays.binarySearch(moves2, m15);
  990.       int buscaM13 = Arrays.binarySearch(moves3, m15);
  991.       if (buscaM11 >= 0) {
  992.         m17 = globalMovesMenosMoves1[r.nextInt(4)];
  993.       } else if (buscaM12 >= 0) {
  994.         m17 = globalMovesMenosMoves2[r.nextInt(4)];
  995.       } else if (buscaM13 >= 0) {
  996.         m17 = globalMovesMenosMoves3[r.nextInt(4)];
  997.       }
  998.     }
  999.     else
  1000.     {
  1001.       do
  1002.       {
  1003.         m17 = globalMoves[r.nextInt(6)];
  1004.       } while (m17 == m16);
  1005.     }
  1006.     boolean opostosOk16 = false;
  1007.     int testeA16 = Arrays.binarySearch(moves1, m16);
  1008.     int testeB16 = Arrays.binarySearch(moves1, m17);
  1009.     int testeC16 = Arrays.binarySearch(moves2, m16);
  1010.     int testeD16 = Arrays.binarySearch(moves2, m17);
  1011.     int testeE16 = Arrays.binarySearch(moves3, m16);
  1012.     int testeF16 = Arrays.binarySearch(moves3, m17);
  1013.     if (((testeA16 >= 0) && (testeB16 >= 0)) || ((testeC16 >= 0) && (testeD16 >= 0)) || ((testeE16 >= 0) && (testeF16 >= 0))) {
  1014.       opostosOk16 = true;
  1015.     }
  1016.     String m18 = "";
  1017.     if (opostosOk16)
  1018.     {
  1019.       int buscaM11 = Arrays.binarySearch(moves1, m16);
  1020.       int buscaM12 = Arrays.binarySearch(moves2, m16);
  1021.       int buscaM13 = Arrays.binarySearch(moves3, m16);
  1022.       if (buscaM11 >= 0) {
  1023.         m18 = globalMovesMenosMoves1[r.nextInt(4)];
  1024.       } else if (buscaM12 >= 0) {
  1025.         m18 = globalMovesMenosMoves2[r.nextInt(4)];
  1026.       } else if (buscaM13 >= 0) {
  1027.         m18 = globalMovesMenosMoves3[r.nextInt(4)];
  1028.       }
  1029.     }
  1030.     else
  1031.     {
  1032.       do
  1033.       {
  1034.         m18 = globalMoves[r.nextInt(6)];
  1035.       } while (m18 == m17);
  1036.     }
  1037.     boolean opostosOk17 = false;
  1038.     int testeA17 = Arrays.binarySearch(moves1, m17);
  1039.     int testeB17 = Arrays.binarySearch(moves1, m18);
  1040.     int testeC17 = Arrays.binarySearch(moves2, m17);
  1041.     int testeD17 = Arrays.binarySearch(moves2, m18);
  1042.     int testeE17 = Arrays.binarySearch(moves3, m17);
  1043.     int testeF17 = Arrays.binarySearch(moves3, m18);
  1044.     if (((testeA17 >= 0) && (testeB17 >= 0)) || ((testeC17 >= 0) && (testeD17 >= 0)) || ((testeE17 >= 0) && (testeF17 >= 0))) {
  1045.       opostosOk17 = true;
  1046.     }
  1047.     String m19 = "";
  1048.     if (opostosOk17)
  1049.     {
  1050.       int buscaM11 = Arrays.binarySearch(moves1, m17);
  1051.       int buscaM12 = Arrays.binarySearch(moves2, m17);
  1052.       int buscaM13 = Arrays.binarySearch(moves3, m17);
  1053.       if (buscaM11 >= 0) {
  1054.         m19 = globalMovesMenosMoves1[r.nextInt(4)];
  1055.       } else if (buscaM12 >= 0) {
  1056.         m19 = globalMovesMenosMoves2[r.nextInt(4)];
  1057.       } else if (buscaM13 >= 0) {
  1058.         m19 = globalMovesMenosMoves3[r.nextInt(4)];
  1059.       }
  1060.     }
  1061.     else
  1062.     {
  1063.       do
  1064.       {
  1065.         m19 = globalMoves[r.nextInt(6)];
  1066.       } while (m19 == m18);
  1067.     }
  1068.     boolean opostosOk18 = false;
  1069.     int testeA18 = Arrays.binarySearch(moves1, m18);
  1070.     int testeB18 = Arrays.binarySearch(moves1, m19);
  1071.     int testeC18 = Arrays.binarySearch(moves2, m18);
  1072.     int testeD18 = Arrays.binarySearch(moves2, m19);
  1073.     int testeE18 = Arrays.binarySearch(moves3, m18);
  1074.     int testeF18 = Arrays.binarySearch(moves3, m19);
  1075.     if (((testeA18 >= 0) && (testeB18 >= 0)) || ((testeC18 >= 0) && (testeD18 >= 0)) || ((testeE18 >= 0) && (testeF18 >= 0))) {
  1076.       opostosOk18 = true;
  1077.     }
  1078.     String m20 = "";
  1079.     if (opostosOk18)
  1080.     {
  1081.       int buscaM11 = Arrays.binarySearch(moves1, m18);
  1082.       int buscaM12 = Arrays.binarySearch(moves2, m18);
  1083.       int buscaM13 = Arrays.binarySearch(moves3, m18);
  1084.       if (buscaM11 >= 0) {
  1085.         m20 = globalMovesMenosMoves1[r.nextInt(4)];
  1086.       } else if (buscaM12 >= 0) {
  1087.         m20 = globalMovesMenosMoves2[r.nextInt(4)];
  1088.       } else if (buscaM13 >= 0) {
  1089.         m20 = globalMovesMenosMoves3[r.nextInt(4)];
  1090.       }
  1091.     }
  1092.     else
  1093.     {
  1094.       do
  1095.       {
  1096.         m20 = globalMoves[r.nextInt(6)];
  1097.       } while (m20 == m19);
  1098.     }
  1099.     boolean opostosOk19 = false;
  1100.     int testeA19 = Arrays.binarySearch(moves1, m19);
  1101.     int testeB19 = Arrays.binarySearch(moves1, m20);
  1102.     int testeC19 = Arrays.binarySearch(moves2, m19);
  1103.     int testeD19 = Arrays.binarySearch(moves2, m20);
  1104.     int testeE19 = Arrays.binarySearch(moves3, m19);
  1105.     int testeF19 = Arrays.binarySearch(moves3, m20);
  1106.     if (((testeA19 >= 0) && (testeB19 >= 0)) || ((testeC19 >= 0) && (testeD19 >= 0)) || ((testeE19 >= 0) && (testeF19 >= 0))) {
  1107.       opostosOk19 = true;
  1108.     }
  1109.     String m21 = "";
  1110.     if (opostosOk19)
  1111.     {
  1112.       int buscaM11 = Arrays.binarySearch(moves1, m19);
  1113.       int buscaM12 = Arrays.binarySearch(moves2, m19);
  1114.       int buscaM13 = Arrays.binarySearch(moves3, m19);
  1115.       if (buscaM11 >= 0) {
  1116.         m21 = globalMovesMenosMoves1[r.nextInt(4)];
  1117.       } else if (buscaM12 >= 0) {
  1118.         m21 = globalMovesMenosMoves2[r.nextInt(4)];
  1119.       } else if (buscaM13 >= 0) {
  1120.         m21 = globalMovesMenosMoves3[r.nextInt(4)];
  1121.       }
  1122.     }
  1123.     else
  1124.     {
  1125.       do
  1126.       {
  1127.         m21 = globalMoves[r.nextInt(6)];
  1128.       } while (m21 == m20);
  1129.     }
  1130.     boolean opostosOk20 = false;
  1131.     int testeA20 = Arrays.binarySearch(moves1, m20);
  1132.     int testeB20 = Arrays.binarySearch(moves1, m21);
  1133.     int testeC20 = Arrays.binarySearch(moves2, m20);
  1134.     int testeD20 = Arrays.binarySearch(moves2, m21);
  1135.     int testeE20 = Arrays.binarySearch(moves3, m20);
  1136.     int testeF20 = Arrays.binarySearch(moves3, m21);
  1137.     if (((testeA20 >= 0) && (testeB20 >= 0)) || ((testeC20 >= 0) && (testeD20 >= 0)) || ((testeE20 >= 0) && (testeF20 >= 0))) {
  1138.       opostosOk20 = true;
  1139.     }
  1140.     String m22 = "";
  1141.     if (opostosOk20)
  1142.     {
  1143.       int buscaM11 = Arrays.binarySearch(moves1, m20);
  1144.       int buscaM12 = Arrays.binarySearch(moves2, m20);
  1145.       int buscaM13 = Arrays.binarySearch(moves3, m20);
  1146.       if (buscaM11 >= 0) {
  1147.         m22 = globalMovesMenosMoves1[r.nextInt(4)];
  1148.       } else if (buscaM12 >= 0) {
  1149.         m22 = globalMovesMenosMoves2[r.nextInt(4)];
  1150.       } else if (buscaM13 >= 0) {
  1151.         m22 = globalMovesMenosMoves3[r.nextInt(4)];
  1152.       }
  1153.     }
  1154.     else
  1155.     {
  1156.       do
  1157.       {
  1158.         m22 = globalMoves[r.nextInt(6)];
  1159.       } while (m22 == m21);
  1160.     }
  1161.     boolean opostosOk21 = false;
  1162.     int testeA21 = Arrays.binarySearch(moves1, m21);
  1163.     int testeB21 = Arrays.binarySearch(moves1, m22);
  1164.     int testeC21 = Arrays.binarySearch(moves2, m21);
  1165.     int testeD21 = Arrays.binarySearch(moves2, m22);
  1166.     int testeE21 = Arrays.binarySearch(moves3, m21);
  1167.     int testeF21 = Arrays.binarySearch(moves3, m22);
  1168.     if (((testeA21 >= 0) && (testeB21 >= 0)) || ((testeC21 >= 0) && (testeD21 >= 0)) || ((testeE21 >= 0) && (testeF21 >= 0))) {
  1169.       opostosOk21 = true;
  1170.     }
  1171.     String m23 = "";
  1172.     if (opostosOk21)
  1173.     {
  1174.       int buscaM11 = Arrays.binarySearch(moves1, m21);
  1175.       int buscaM12 = Arrays.binarySearch(moves2, m21);
  1176.       int buscaM13 = Arrays.binarySearch(moves3, m21);
  1177.       if (buscaM11 >= 0) {
  1178.         m23 = globalMovesMenosMoves1[r.nextInt(4)];
  1179.       } else if (buscaM12 >= 0) {
  1180.         m23 = globalMovesMenosMoves2[r.nextInt(4)];
  1181.       } else if (buscaM13 >= 0) {
  1182.         m23 = globalMovesMenosMoves3[r.nextInt(4)];
  1183.       }
  1184.     }
  1185.     else
  1186.     {
  1187.       do
  1188.       {
  1189.         m23 = globalMoves[r.nextInt(6)];
  1190.       } while (m23 == m22);
  1191.     }
  1192.     boolean opostosOk22 = false;
  1193.     int testeA22 = Arrays.binarySearch(moves1, m22);
  1194.     int testeB22 = Arrays.binarySearch(moves1, m23);
  1195.     int testeC22 = Arrays.binarySearch(moves2, m22);
  1196.     int testeD22 = Arrays.binarySearch(moves2, m23);
  1197.     int testeE22 = Arrays.binarySearch(moves3, m22);
  1198.     int testeF22 = Arrays.binarySearch(moves3, m23);
  1199.     if (((testeA22 >= 0) && (testeB22 >= 0)) || ((testeC22 >= 0) && (testeD22 >= 0)) || ((testeE22 >= 0) && (testeF22 >= 0))) {
  1200.       opostosOk22 = true;
  1201.     }
  1202.     String m24 = "";
  1203.     if (opostosOk22)
  1204.     {
  1205.       int buscaM11 = Arrays.binarySearch(moves1, m22);
  1206.       int buscaM12 = Arrays.binarySearch(moves2, m22);
  1207.       int buscaM13 = Arrays.binarySearch(moves3, m22);
  1208.       if (buscaM11 >= 0) {
  1209.         m24 = globalMovesMenosMoves1[r.nextInt(4)];
  1210.       } else if (buscaM12 >= 0) {
  1211.         m24 = globalMovesMenosMoves2[r.nextInt(4)];
  1212.       } else if (buscaM13 >= 0) {
  1213.         m24 = globalMovesMenosMoves3[r.nextInt(4)];
  1214.       }
  1215.     }
  1216.     else
  1217.     {
  1218.       do
  1219.       {
  1220.         m24 = globalMoves[r.nextInt(6)];
  1221.       } while (m24 == m23);
  1222.     }
  1223.     boolean opostosOk23 = false;
  1224.     int testeA23 = Arrays.binarySearch(moves1, m23);
  1225.     int testeB23 = Arrays.binarySearch(moves1, m24);
  1226.     int testeC23 = Arrays.binarySearch(moves2, m23);
  1227.     int testeD23 = Arrays.binarySearch(moves2, m24);
  1228.     int testeE23 = Arrays.binarySearch(moves3, m23);
  1229.     int testeF23 = Arrays.binarySearch(moves3, m24);
  1230.     if (((testeA23 >= 0) && (testeB23 >= 0)) || ((testeC23 >= 0) && (testeD23 >= 0)) || ((testeE23 >= 0) && (testeF23 >= 0))) {
  1231.       opostosOk23 = true;
  1232.     }
  1233.     String m25 = "";
  1234.     if (opostosOk23)
  1235.     {
  1236.       int buscaM11 = Arrays.binarySearch(moves1, m23);
  1237.       int buscaM12 = Arrays.binarySearch(moves2, m23);
  1238.       int buscaM13 = Arrays.binarySearch(moves3, m23);
  1239.       if (buscaM11 >= 0) {
  1240.         do
  1241.         {
  1242.           m25 = globalMovesMenosMoves1[r.nextInt(4)];
  1243.         } while (m25 == m24);
  1244.       } else if (buscaM12 >= 0) {
  1245.         do
  1246.         {
  1247.           m25 = globalMovesMenosMoves2[r.nextInt(4)];
  1248.         } while (m25 == m24);
  1249.       } else if (buscaM13 >= 0) {
  1250.         do
  1251.         {
  1252.           m25 = globalMovesMenosMoves3[r.nextInt(4)];
  1253.         } while (m25 == m24);
  1254.       }
  1255.     }
  1256.     else
  1257.     {
  1258.       do
  1259.       {
  1260.         m25 = globalMoves[r.nextInt(6)];
  1261.       } while (m25 == m24);
  1262.     }
  1263.     String moves = m1 + mm1 + m2 + mm2 + m3 + mm3 + m4 + mm4 + m5 + mm5 + m6 +
  1264.             mm6 + m7 + mm7 + m8 + mm8 + m9 + mm9 + m10 + mm10 + m11 + mm11 +
  1265.             m12 + mm12 + m13 + mm13 + m14 + mm14 + m15 + mm15 + m16 + mm16 + m17
  1266.             + mm17 + m18 + mm18 + m19 + mm19 + m20 + mm20 + m21 + mm21 + m22 +
  1267.             mm22 + m23 + mm23 + m24 + mm24 + m25 + mm25;
  1268.    
  1269.    
  1270.    
  1271.    
  1272.    
  1273.     return moves;
  1274.   }
  1275. }
  1276.  
  1277. //////////////////////////////////CLOCK SCR
  1278.  
  1279. package javaapplication1;
  1280.  
  1281. import java.util.Random;
  1282.  
  1283. public class ScrambleClock {
  1284.  
  1285.     public String embaralharClock() {
  1286.  
  1287.         Random r = new Random();
  1288.  
  1289.         String[] sentidos = {"5- ", "4- ", "3- ", "2- ", "1- ", "0 ",
  1290.                              "1+ ", "2+ ", "3+ ", "4+ ", "5+ ", "6+ "};
  1291.  
  1292.         String[] pinos = {"UR ", "DR ", "DL ", "UL "};
  1293.  
  1294.         int[] decisão = {1, 2, 3, 4};
  1295.  
  1296.         int valor = decisão[r.nextInt(4)];
  1297.  
  1298.         String scramble = "UR" + sentidos[r.nextInt(12)]
  1299.                 + "DR" + sentidos[r.nextInt(12)]
  1300.                 + "DL" + sentidos[r.nextInt(12)]
  1301.                 + "UL" + sentidos[r.nextInt(12)]
  1302.                 + "U" + sentidos[r.nextInt(12)]
  1303.                 + "R" + sentidos[r.nextInt(12)]
  1304.                 + "D" + sentidos[r.nextInt(12)]
  1305.                 + "L" + sentidos[r.nextInt(12)]
  1306.                 + "ALL" + sentidos[r.nextInt(12)]
  1307.                 + "y2 "
  1308.                 + "U" + sentidos[r.nextInt(12)]
  1309.                 + "R" + sentidos[r.nextInt(12)]
  1310.                 + "D" + sentidos[r.nextInt(12)]
  1311.                 + "L" + sentidos[r.nextInt(12)]
  1312.                 + "ALL" + sentidos[r.nextInt(12)];
  1313.  
  1314.         String pinoss1 = "";
  1315.         String pinoss2 = "";
  1316.         String pinoss3 = "";
  1317.         String pinoss4 = "";
  1318.        
  1319.         if (valor == 1) {
  1320.             pinoss1 = pinos[r.nextInt(4)];
  1321.         } else if (valor == 2) {
  1322.             pinoss1 = pinos[r.nextInt(4)];
  1323.             do {
  1324.                 pinoss2 = pinos[r.nextInt(4)];
  1325.             } while (pinoss2 == pinoss1);
  1326.         } else if (valor == 3) {
  1327.             pinoss1 = pinos[r.nextInt(4)];
  1328.             do {
  1329.                 pinoss2 = pinos[r.nextInt(4)];
  1330.             } while (pinoss2 == pinoss1);
  1331.             do {
  1332.                 do{
  1333.                 pinoss3 = pinos[r.nextInt(4)];
  1334.                 }while(pinoss3 == pinoss1);
  1335.             } while (pinoss3 == pinoss2);
  1336.         } else {
  1337.             pinoss4 = "UR DR DL UL";
  1338.         }
  1339.        
  1340.         String pinoFinal = pinoss1 + pinoss2 + pinoss3 + pinoss4;
  1341.        
  1342.         String scrambleFinal = scramble + pinoFinal;
  1343.        
  1344.         return scrambleFinal;
  1345.     }
  1346.  
  1347. }
  1348.  
  1349. ////////////////////////////MEGA SCR
  1350.  
  1351. package javaapplication1;
  1352.  
  1353. import java.util.ArrayList;
  1354. import java.util.Arrays;
  1355. import java.util.Random;
  1356.  
  1357. public class ScrambleMegaminx {
  1358.  
  1359.     public ArrayList embaralharMegaminx() {
  1360.  
  1361.         Random r = new Random();
  1362.         ArrayList<String> lista = new ArrayList<>();
  1363.  
  1364.         String[] moves1 = {"R++ ", "R-- "};
  1365.         String[] moves2 = {"D++ ", "D-- "};
  1366.         String[] moves3 = {"U\n", "U'\n"};
  1367.  
  1368.         String[] m1 = new String[3];
  1369.         String[] m2 = new String[3];
  1370.         String[] m3 = new String[3];
  1371.  
  1372.         //for (int j = 0; j < 8; j++) {
  1373.             for (int i = 0; i < 3; i++) {
  1374.  
  1375.                 m1[i] = moves1[r.nextInt(2)];
  1376.                 m2[i] = moves2[r.nextInt(2)];
  1377.                 lista.add(m1[i]);
  1378.                 lista.add(m2[i]);
  1379.  
  1380.                 if (i == 2) {
  1381.                     m1[i] = moves1[r.nextInt(2)];
  1382.                     m2[i] = moves2[r.nextInt(2)];
  1383.                     m1[i] = moves1[r.nextInt(2)];
  1384.                     m2[i] = moves2[r.nextInt(2)];
  1385.                     m1[i] = moves1[r.nextInt(2)];
  1386.                     m3[i] = moves3[r.nextInt(2)];
  1387.                     lista.add(m1[i]);
  1388.                     lista.add(m2[i]);
  1389.                     lista.add(m1[i]);
  1390.                     lista.add(m2[i]);
  1391.                     lista.add(m1[i]);
  1392.                     lista.add(m3[i]);
  1393.                 }
  1394.  
  1395.             }
  1396.         //}
  1397.  
  1398.         return lista;
  1399.  
  1400.     }
  1401.  
  1402. }
  1403.  
  1404. //////////////////////////////////SKEWB SCR
  1405.  
  1406. package javaapplication1;
  1407.  
  1408. import java.util.ArrayList;
  1409. import java.util.Random;
  1410.  
  1411. public class ScrambleSkewb {
  1412.  
  1413.     public ArrayList embaralhar2x2() {
  1414.        
  1415.         ArrayList<String> lista = new ArrayList<>();
  1416.        
  1417.         Random r = new Random();
  1418.        
  1419.         String[] moves1 = {"B", "U", "R", "L"};
  1420.         String[] moves2 = {" ", "' "};
  1421.        
  1422.         String s = "";
  1423.         String f = "";
  1424.        
  1425.         for (int i = 0; i < 8; i++) {
  1426.             do {
  1427.                 f = moves1[r.nextInt(4)];
  1428.             } while (f == s);
  1429.             s = f;
  1430.             String u = moves2[r.nextInt(2)];
  1431.             lista.add(s + u);
  1432.         }
  1433.        
  1434.         return lista;
  1435.        
  1436.     }
  1437. }
  1438.  
  1439. /////////////////////////////////////SQR SCR (N FINALIZADO)
  1440.  
  1441. package javaapplication2;
  1442.  
  1443. import java.util.Random;
  1444.  
  1445. public class SqScr {
  1446.  
  1447.     public static void main(String[] args) {
  1448.  
  1449.         Random r = new Random();
  1450.  
  1451.         String[] startUpMove = {"-5", "-3", "-2", "0", "1", "3", "4", "6"};
  1452.         String[] movimentoInicialB_a1 = {"-5", "-2", "1", "4"};
  1453.         String[] movimentoInicialB_a2 = {"-3", "0", "3", "6"};
  1454.         String[] movimentoInicialB_b = {"-4", "-1", "2", "5"};
  1455.         String[] movimentosEquivalentesAMenos1Cima = {"-4", "-1", "2", "5"};        
  1456.         String[] cubeShapeCases = {                                  
  1457.                                     "(3,0)/(1,-4)/(0,2)/(4,6)/(2,1)/(-3,-1)",
  1458.            
  1459.                                     "(0,-3)/(-2,-1)/(-3,4)/(3,2)/(2,-2)",
  1460.            
  1461.                                     "(0,-3)/(-2,-1)/(-3,2)/(-1,-2)/(-4,0)",
  1462.                                    
  1463.                                     "(3,0)/(1,2)/(2,6)/(4,-4)/(1,2)",
  1464.                                    
  1465.                                     "(0,-3)/(-2,-1)/(-3,4)/(-5,2)/(1,2)",
  1466.                                    
  1467.                                     "(0,-3)/(-2,-1)/(-3,4)/(3,6)/(-2,3)",
  1468.                                    
  1469.                                     "(3,0)/(1,-4)/(0,2)/(4,6)/(-4,1)",
  1470.                                    
  1471.                                     "(0,-3)/(-2,-1)/(-3,4)/(6,4)/(2,0)",
  1472.                                    
  1473.                                     "(0,-3)/(-2,-1)/(-3,4)/(3,-4/)(4,-5)",
  1474.                                    
  1475.                                     "(3,0)/(1,2)/(2,0)/(-1,0)/(-2,0)",
  1476.                                    
  1477.                                     "(0,-3)/(-2,-1)/(-3,4)/(1,2)/(0,-4)",
  1478.                                    
  1479.                                     "(3,0)/(1,-4)/(0,2/)(4,6)/(2,1)",
  1480.                                    
  1481.                                     "(3,3)/(-1,-2)/(0,-2)/(-5,-4)/(-4,3)",
  1482.                                    
  1483.                                     "(3,3)/(-1,-2)/(0,-2)/(-5,-4)/(-4,3)",
  1484.  
  1485.                                     //14°
  1486.                                     };
  1487.        
  1488.         String shape = "";
  1489.  
  1490.         while (true) {
  1491.             boolean cimaEstáDesalinhado = false;
  1492.             boolean baixoEstáDesalinhado = false;
  1493.  
  1494.             String move1 = "";
  1495.             String move2 = "";
  1496.             String move3 = "";
  1497.             String move4 = "";
  1498.             String move5 = "";
  1499.             String move6 = "";
  1500.             String move7 = "";
  1501.             String move8 = "";
  1502.             String move9 = "";
  1503.             String move10 = "";
  1504.             String move11 = "";
  1505.             String move12 = "";
  1506.  
  1507.             if (cimaEstáDesalinhado == false && baixoEstáDesalinhado == false) {
  1508.                 move1 = startUpMove[r.nextInt(8)];
  1509.             }
  1510.  
  1511.             if (move1.contains("-5") || move1.contains("-2") || move1.contains("1") || move1.contains("4")) {
  1512.                 cimaEstáDesalinhado = true;
  1513.                 baixoEstáDesalinhado = false;
  1514.                 move2 = movimentoInicialB_a2[r.nextInt(4)];
  1515.             } else {
  1516.                 cimaEstáDesalinhado = false;
  1517.                 baixoEstáDesalinhado = true;
  1518.                 move2 = movimentoInicialB_b[r.nextInt(4)];
  1519.             }
  1520.  
  1521.             if (cimaEstáDesalinhado == true && baixoEstáDesalinhado == false) {
  1522.                 cimaEstáDesalinhado = false;
  1523.                 baixoEstáDesalinhado = true;
  1524.                 move3 = movimentosEquivalentesAMenos1Cima[r.nextInt(4)];
  1525.                 move4 = movimentoInicialB_b[r.nextInt(4)];
  1526.             } else if (cimaEstáDesalinhado == false && baixoEstáDesalinhado == true) {
  1527.                 move3 = startUpMove[r.nextInt(8)];
  1528.  
  1529.                 if (move3.contains("-5") || move3.contains("-2") || move3.contains("1") || move3.contains("4")) {
  1530.                     cimaEstáDesalinhado = true;
  1531.                     baixoEstáDesalinhado = false;
  1532.                     move4 = movimentoInicialB_a1[r.nextInt(4)];
  1533.                 } else {
  1534.                     cimaEstáDesalinhado = false;
  1535.                     baixoEstáDesalinhado = true;
  1536.                     move4 = movimentoInicialB_a2[r.nextInt(4)];
  1537.                 }
  1538.             }
  1539.  
  1540.             if (cimaEstáDesalinhado == false && baixoEstáDesalinhado == true) {
  1541.                 move5 = startUpMove[r.nextInt(4)];
  1542.  
  1543.                 if (move5.contains("-5") || move5.contains("-2") || move5.contains("1") || move5.contains("4")) {
  1544.                     cimaEstáDesalinhado = true;
  1545.                     baixoEstáDesalinhado = false;
  1546.                     move6 = movimentoInicialB_a1[r.nextInt(4)];
  1547.                 } else {
  1548.                     cimaEstáDesalinhado = false;
  1549.                     baixoEstáDesalinhado = true;
  1550.                     move6 = movimentoInicialB_a2[r.nextInt(4)];
  1551.                 }
  1552.             } else if (cimaEstáDesalinhado == true && baixoEstáDesalinhado == false) {
  1553.                 cimaEstáDesalinhado = false;
  1554.                 baixoEstáDesalinhado = true;
  1555.                 move5 = movimentosEquivalentesAMenos1Cima[r.nextInt(4)];
  1556.                 move6 = movimentoInicialB_b[r.nextInt(4)];
  1557.             }
  1558.  
  1559.             if (cimaEstáDesalinhado == true && baixoEstáDesalinhado == false) {
  1560.                 move7 = movimentosEquivalentesAMenos1Cima[r.nextInt(4)];
  1561.                 move8 = movimentoInicialB_b[r.nextInt(4)];
  1562.                 move9 = startUpMove[r.nextInt(8)];
  1563.  
  1564.                 if (move9.contains("-5") || move9.contains("-2") || move9.contains("1") || move9.contains("4")) {
  1565.                     move10 = movimentoInicialB_a1[r.nextInt(4)];
  1566.                     move11 = movimentosEquivalentesAMenos1Cima[r.nextInt(4)];
  1567.                     move12 = movimentoInicialB_a2[r.nextInt(4)];
  1568.                     System.out.print("(" + move1 + "," + move2 + ")/" + "(" + move3 + "," + move4 + ")/("
  1569.                             + move5 + "," + move6 + ")/(" + move7 + "," + move8 + ")/(" + move9 + "," + move10 + ")/("
  1570.                             + move11 + "," + move12 + ")/");
  1571.                     break;
  1572.                 } else {
  1573.                     move10 = movimentoInicialB_a1[r.nextInt(4)];
  1574.                     System.out.print("(" + move1 + "," + move2 + ")/" + "(" + move3 + "," + move4 + ")/("
  1575.                             + move5 + "," + move6 + ")/(" + move7 + "," + move8 + ")/(" + move9 + "," + move10 + ")/");
  1576.                     break;
  1577.                 }
  1578.             }
  1579.         }
  1580.         //shape = cubeShapeCases[r.nextInt(14)];
  1581.        
  1582.         System.out.println(cubeShapeCases[r.nextInt(14)]);
  1583.        
  1584.     }
  1585. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement