Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Classe principal
- package javaapplication1;
- import java.awt.*;
- import java.awt.event.*;
- import java.util.ArrayList;
- import javax.swing.*;
- public class CRONO3 extends JFrame {
- long minutoFinal;
- long centésimos;
- static JLabel tempoCorrendo;
- static boolean contador = true;
- static boolean contador2 = true;
- static boolean contador3 = true;
- boolean prontoParaPause = false;
- boolean botãoSemUtilidadePorEnquanto = false;
- JLabel label1;
- JLabel label2;
- JLabel label3;
- JLabel label4;
- JButton botãoStart;
- JButton botãoStop;
- JButton botãoStart2;
- Scramble3x3 scramble1 = new Scramble3x3();
- ScrambleMegaminx scramble2 = new ScrambleMegaminx();
- public CRONO3() {
- ArrayList<Integer> listaCents = new ArrayList<>();
- ArrayList<Integer> listaSeg = new ArrayList<>();
- ArrayList<Integer> listaMin = new ArrayList<>();
- ArrayList<Integer> listaTotal = new ArrayList<>();
- setTitle("Lucas's Timer");
- setSize(1400, 400);
- setDefaultCloseOperation(3);
- setLayout(new FlowLayout(1));
- label1 = new JLabel();
- //label1.setText("Scramble: " + String.valueOf(Scrambler3x3.embaralhar3x3()));
- label1.setText("<html>Scramble:<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- );
- label1.setFont(new Font(null, 0, 20));
- label1.setLayout(new FlowLayout((int) JFrame.TOP_ALIGNMENT));
- add(label1);
- tempoCorrendo = new JLabel();
- tempoCorrendo.setText("00:00.00");
- tempoCorrendo.setFont(new Font("Times New Roman", 1, 200));
- add(tempoCorrendo);
- label3 = new JLabel("Media: 00:00.00");
- label3.setFont(new Font(null, 1, 20));
- add(label3);
- label4 = new JLabel();
- add(label4);
- Cronometragem timing = new Cronometragem(tempoCorrendo);
- InspTime inspeção = new InspTime(tempoCorrendo);
- //LongMedia media = new LongMedia();
- botãoStart = new JButton("Start");
- botãoStart.setVisible(false);
- botãoStart.setForeground(Color.red);
- botãoStart.setToolTipText("Press Space to start");
- botãoStop = new JButton("Stop");
- botãoStop.setForeground(Color.red);
- botãoStop.setToolTipText("Press Space to stop");
- botãoStop.setEnabled(false);
- botãoStart2 = new JButton("Start Insp");
- botãoStart2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent eventoDoBotão) {
- if (inspeção.inspeçãoAtivada == false) {
- inspeção.start();
- tempoCorrendo.setText("15");
- label1.setText("");
- label3.setText("");
- tempoCorrendo.setFont(new Font("Times New Roman", 1, 300));
- setSize(800, 400);
- setLocationRelativeTo(null);
- botãoStart2.setVisible(false);
- botãoStart.setVisible(true);
- }
- iniciarInspeção(eventoDoBotão);
- tempoCorrendo.setText("15");
- botãoStart2.setVisible(false);
- botãoStart.setVisible(true);
- label1.setText("");
- label3.setText("");
- tempoCorrendo.setFont(new Font("Times New Roman", 1, 300));
- setSize(800, 400);
- setLocationRelativeTo(null);
- botãoStart2.setVisible(false);
- botãoStart.setVisible(true);
- }
- });
- botãoStart.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent eventoDoBotão) {
- if (timing.threadCronoON == false) {
- timing.start();
- //media.start();
- tempoCorrendo.setForeground(Color.BLACK);
- botãoStart.setEnabled(false);
- botãoStop.setEnabled(true);
- pausarInspeção(eventoDoBotão);
- inspeção.segInsp = 15;
- tempoCorrendo.setText("15");
- tempoCorrendo.setFont(new Font("Times New Roman", 1, 200));
- setSize(800, 340);
- setLocationRelativeTo(null);
- }
- if ((timing.centésimo > 0) || (timing.minuto > 0) || (timing.segundo > 0)) {
- timing.centésimo = 0;
- timing.minuto = 0;
- timing.segundo = 0;
- botãoStart.setEnabled(false);
- botãoStop.setEnabled(true);
- iniciarInspeção(eventoDoBotão);
- inspeção.segInsp = 15;
- tempoCorrendo.setText("15");
- tempoCorrendo.setFont(new Font("Times New Roman", 1, 200));
- setSize(800, 340);
- setLocationRelativeTo(null);
- }
- iniciarTimer(eventoDoBotão);
- iniciarLongMedia(eventoDoBotão);
- pausarInspeção(eventoDoBotão);
- tempoCorrendo.setForeground(Color.BLACK);
- tempoCorrendo.setFont(new Font("Times New Roman", 1, 200));
- setSize(800, 340);
- setLocationRelativeTo(null);
- }
- });
- botãoStop.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent eventoDoBotão) {
- pausarTimer(eventoDoBotão);
- pausarLongMedia(eventoDoBotão);
- int totalCents = 0;
- int totalSeg = 0;
- int totalMin = 0;
- listaCents.add(timing.centésimo);
- listaSeg.add(timing.segundo);
- listaMin.add(timing.minuto);
- listaTotal.add(timing.minuto);
- listaTotal.add(timing.segundo);
- listaTotal.add(timing.centésimo);
- //System.out.println("Lista: " + listaTotal);
- for (int i : listaSeg) {
- totalSeg += i;
- }
- for (int i : listaCents) {
- totalCents += i;
- }
- for (int i : listaMin) {
- totalMin += i;
- }
- //label1.setText("Scramble: " + String.valueOf(Scrambler3x3.embaralhar3x3()));
- label1.setText("<html>Scramble:<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- + scramble2.embaralharMegaminx() + "<br>"
- );
- setSize(1400, 310);
- setLocationRelativeTo(null);
- // if (timing.minuto < 10) {
- // label4.setText("TimeList: 0"+ timing.minuto + ":" +timing.segundo + "." +timing.centésimo);
- // }
- // if (timing.segundo < 10) {
- // label4.setText("TimeList: 0"+timing.minuto + ":0" +timing.segundo + "." +timing.centésimo);
- // }
- // if (timing.centésimo < 10) {
- // label4.setText("TimeList: 0"+timing.minuto + ":0" +timing.segundo + ".0" +timing.centésimo);
- // }
- if (timing.minuto < 10) {
- label3.setText("Média: 0"+(totalMin/listaMin.size()) + ":" +(totalSeg/listaSeg.size()) + "." +(totalCents/listaCents.size()));
- }
- if (timing.segundo < 10) {
- label3.setText("Média: 0"+(totalMin/listaMin.size()) + ":0" +(totalSeg/listaSeg.size()) + "." +(totalCents/listaCents.size()));
- }
- if (timing.centésimo < 10) {
- label3.setText("Média: 0"+(totalMin/listaMin.size()) + ":0" +(totalSeg/listaSeg.size()) + ".0" +(totalCents/listaCents.size()));
- }
- botãoStop.setEnabled(false);
- botãoStart.setEnabled(true);
- pausarInspeção(eventoDoBotão);
- botãoStart2.setVisible(true);
- botãoStart.setVisible(false);
- }
- });
- add(botãoStart2);
- reagirSpace(botãoStart2);
- add(botãoStart);
- reagirSpace(botãoStart);
- add(botãoStop);
- reagirSpace(botãoStop);
- }
- public static void reagirSpace(JButton botão) {
- botão.registerKeyboardAction(botão.getActionForKeyStroke(KeyStroke.getKeyStroke(32, 0, false)), KeyStroke.getKeyStroke(32, 0, false), 2);
- botão.registerKeyboardAction(botão.getActionForKeyStroke(KeyStroke.getKeyStroke(32, 0, true)), KeyStroke.getKeyStroke(32, 0, true), 2);
- }
- void pausarTimer(ActionEvent evt) {
- contador = false;
- }
- void pausarInspeção(ActionEvent evt) {
- contador2 = false;
- }
- void pausarLongMedia(ActionEvent evt) {
- contador3 = false;
- }
- public static boolean isContador() {
- return contador;
- }
- public static boolean isContadorInsp() {
- return contador2;
- }
- public static boolean isContadorLongMedia() {
- return contador3;
- }
- void iniciarTimer(ActionEvent evt) {
- tempoCorrendo.revalidate();
- contador = true;
- }
- void iniciarInspeção(ActionEvent evt) {
- tempoCorrendo.revalidate();
- contador2 = true;
- }
- void iniciarLongMedia(ActionEvent evt) {
- contador3 = true;
- }
- public static void main(String[] args) {
- CRONO3 tela = new CRONO3();
- Panel meuPainel = new Panel();
- tela.setVisible(true);
- tela.setLocationRelativeTo(null);
- //tela.setResizable(false);
- tela.add(meuPainel);
- }
- }
- ////////////CRONOMETRAGEM
- package javaapplication1;
- import javax.swing.JLabel;
- public class Cronometragem extends Thread {
- private JLabel label;
- boolean threadCronoON = false;
- boolean threadCronoOFF = true;
- int centésimo = 0;
- int segundo = 0;
- int minuto = 0;
- public Cronometragem(JLabel stringTempo) {
- label = stringTempo;
- }
- public void run() {
- try {
- while(true) {
- Thread.sleep((long) 9,6737);
- threadCronoON = true;
- if (CRONO3.isContador()) {
- centésimo++;
- if (centésimo == 100) {
- centésimo = 0;
- segundo++;
- }
- if (segundo == 60) {
- segundo = 0;
- minuto += 1;
- }
- String timerMinuto = "";
- String timerSegundo = "";
- String timerCentésimo = "";
- if (minuto < 10) {
- timerMinuto = "0" + minuto;
- } else {
- timerMinuto = String.valueOf(minuto);
- }
- if (segundo < 10) {
- timerSegundo = "0" + segundo;
- } else {
- timerSegundo = String.valueOf(segundo);
- }
- if (centésimo < 10) {
- timerCentésimo = "0" + centésimo;
- } else {
- timerCentésimo = String.valueOf(centésimo);
- }
- label.setText(timerMinuto + ":" + timerSegundo + "." + timerCentésimo);
- label.revalidate();
- }
- }
- } catch (InterruptedException e) {
- stop();
- threadCronoON = false;
- System.out.println("Bugou" + "\tValor de threadCronoON: " + threadCronoON);
- }
- }
- }
- /////////////////////////////INSP TIME
- package javaapplication1;
- import java.awt.Color;
- import javax.swing.JLabel;
- public class InspTime extends Thread {
- private JLabel labelInsp;
- boolean inspeçãoAtivada = false;
- boolean inspeçãoDesativada = false;
- boolean ganhouDNF = false;
- int segInsp = 15;
- public InspTime(JLabel stringInsp) {
- labelInsp = stringInsp;
- }
- public void run() {
- for (;;) {
- try {
- inspeçãoAtivada = true;
- Thread.sleep(1000L);
- if (CRONO3.isContadorInsp()) {
- segInsp--;
- labelInsp.setText(String.valueOf(this.segInsp));
- labelInsp.revalidate();
- if(segInsp <= 3){
- labelInsp.setForeground(Color.RED);
- }
- if (segInsp <= 0) {
- labelInsp.setForeground(Color.BLACK);
- labelInsp.setText("DNF");
- labelInsp.revalidate();
- ganhouDNF = true;
- }
- }
- } catch (InterruptedException e) {
- }
- }
- }
- }
- ///////////////2x2 SCR
- package javaapplication1;
- import java.util.ArrayList;
- import java.util.Random;
- public class Scramble2x2 {
- public ArrayList embaralhar2x2() {
- ArrayList<String> lista = new ArrayList<>();
- Random r = new Random();
- String[] moves1 = {"F", "U", "R"};
- String[] moves2 = {" ", "' ", "2 "};
- String s = "";
- String f = "";
- for (int i = 0; i < 8; i++) {
- do {
- f = moves1[r.nextInt(3)];
- } while (f == s);
- s = f;
- String u = moves2[r.nextInt(3)];
- lista.add(s + u);
- }
- return lista;
- }
- }
- ////////////////////////////3X3 SCR
- package javaapplication1;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Random;
- public class Scramble3x3{
- public static String embaralhar3x3() {
- Random r = new Random();
- String[] globalMoves = { "F", "B", "U", "D", "R", "L" };
- String[] globalMovesMenosMoves1 = { "U", "D", "R", "L" };
- String[] globalMovesMenosMoves2 = { "B", "F", "L", "R" };
- String[] globalMovesMenosMoves3 = { "F", "B", "U", "D" };
- String[] sentido = { " ", "' ", "2 " };
- String[] moves1 = { "B", "F" };
- String[] moves2 = { "D", "U" };
- String[] moves3 = { "L", "R" };
- String mm1 = sentido[r.nextInt(3)];
- String mm2 = sentido[r.nextInt(3)];
- String mm3 = sentido[r.nextInt(3)];
- String mm4 = sentido[r.nextInt(3)];
- String mm5 = sentido[r.nextInt(3)];
- String mm6 = sentido[r.nextInt(3)];
- String mm7 = sentido[r.nextInt(3)];
- String mm8 = sentido[r.nextInt(3)];
- String mm9 = sentido[r.nextInt(3)];
- String mm10 = sentido[r.nextInt(3)];
- String mm11 = sentido[r.nextInt(3)];
- String mm12 = sentido[r.nextInt(3)];
- String mm13 = sentido[r.nextInt(3)];
- String mm14 = sentido[r.nextInt(3)];
- String mm15 = sentido[r.nextInt(3)];
- String mm16 = sentido[r.nextInt(3)];
- String mm17 = sentido[r.nextInt(3)];
- String mm18 = sentido[r.nextInt(3)];
- String mm19 = sentido[r.nextInt(3)];
- String mm20 = sentido[r.nextInt(3)];
- String mm21 = sentido[r.nextInt(3)];
- String mm22 = sentido[r.nextInt(3)];
- String mm23 = sentido[r.nextInt(3)];
- String mm24 = sentido[r.nextInt(3)];
- String mm25 = sentido[r.nextInt(3)];
- String m1 = globalMoves[r.nextInt(6)];
- String m2 = "";
- do
- {
- m2 = globalMoves[r.nextInt(6)];
- } while (m2 == m1);
- boolean opostosOk = false;
- int testeA = Arrays.binarySearch(moves1, m1);
- int testeB = Arrays.binarySearch(moves1, m2);
- int testeC = Arrays.binarySearch(moves2, m1);
- int testeD = Arrays.binarySearch(moves2, m2);
- int testeE = Arrays.binarySearch(moves3, m1);
- int testeF = Arrays.binarySearch(moves3, m2);
- if (((testeA >= 0) && (testeB >= 0)) || ((testeC >= 0) && (testeD >= 0)) || ((testeE >= 0) && (testeF >= 0))) {
- opostosOk = true;
- }
- String m3 = "";
- if (opostosOk)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m1);
- int buscaM12 = Arrays.binarySearch(moves2, m1);
- int buscaM13 = Arrays.binarySearch(moves3, m1);
- if (buscaM11 >= 0) {
- do
- {
- m3 = globalMovesMenosMoves1[r.nextInt(4)];
- } while (m3 == m2);
- } else if (buscaM12 >= 0) {
- do
- {
- m3 = globalMovesMenosMoves2[r.nextInt(4)];
- } while (m3 == m2);
- } else if (buscaM13 >= 0) {
- do
- {
- m3 = globalMovesMenosMoves3[r.nextInt(4)];
- } while (m3 == m2);
- }
- }
- else
- {
- do
- {
- m3 = globalMoves[r.nextInt(6)];
- } while (m3 == m2);
- }
- boolean opostosOk2 = false;
- int testeA2 = Arrays.binarySearch(moves1, m2);
- int testeB2 = Arrays.binarySearch(moves1, m3);
- int testeC2 = Arrays.binarySearch(moves2, m2);
- int testeD2 = Arrays.binarySearch(moves2, m3);
- int testeE2 = Arrays.binarySearch(moves3, m2);
- int testeF2 = Arrays.binarySearch(moves3, m3);
- if (((testeA2 >= 0) && (testeB2 >= 0)) || ((testeC2 >= 0) && (testeD2 >= 0)) || ((testeE2 >= 0) && (testeF2 >= 0))) {
- opostosOk2 = true;
- }
- String m4 = "";
- if (opostosOk2)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m2);
- int buscaM12 = Arrays.binarySearch(moves2, m2);
- int buscaM13 = Arrays.binarySearch(moves3, m2);
- if (buscaM11 >= 0) {
- m4 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m4 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m4 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m4 = globalMoves[r.nextInt(6)];
- } while (m4 == m3);
- }
- boolean opostosOk3 = false;
- int testeA3 = Arrays.binarySearch(moves1, m3);
- int testeB3 = Arrays.binarySearch(moves1, m4);
- int testeC3 = Arrays.binarySearch(moves2, m3);
- int testeD3 = Arrays.binarySearch(moves2, m4);
- int testeE3 = Arrays.binarySearch(moves3, m3);
- int testeF3 = Arrays.binarySearch(moves3, m4);
- if (((testeA3 >= 0) && (testeB3 >= 0)) || ((testeC3 >= 0) && (testeD3 >= 0)) || ((testeE3 >= 0) && (testeF3 >= 0))) {
- opostosOk3 = true;
- }
- String m5 = "";
- if (opostosOk3)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m3);
- int buscaM12 = Arrays.binarySearch(moves2, m3);
- int buscaM13 = Arrays.binarySearch(moves3, m3);
- if (buscaM11 >= 0) {
- m5 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m5 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m5 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m5 = globalMoves[r.nextInt(6)];
- } while (m5 == m4);
- }
- boolean opostosOk4 = false;
- int testeA4 = Arrays.binarySearch(moves1, m4);
- int testeB4 = Arrays.binarySearch(moves1, m5);
- int testeC4 = Arrays.binarySearch(moves2, m4);
- int testeD4 = Arrays.binarySearch(moves2, m5);
- int testeE4 = Arrays.binarySearch(moves3, m4);
- int testeF4 = Arrays.binarySearch(moves3, m5);
- if (((testeA4 >= 0) && (testeB4 >= 0)) || ((testeC4 >= 0) && (testeD4 >= 0)) || ((testeE4 >= 0) && (testeF4 >= 0))) {
- opostosOk4 = true;
- }
- String m6 = "";
- if (opostosOk4)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m4);
- int buscaM12 = Arrays.binarySearch(moves2, m4);
- int buscaM13 = Arrays.binarySearch(moves3, m4);
- if (buscaM11 >= 0) {
- m6 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m6 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m6 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m6 = globalMoves[r.nextInt(6)];
- } while (m6 == m5);
- }
- boolean opostosOk5 = false;
- int testeA5 = Arrays.binarySearch(moves1, m5);
- int testeB5 = Arrays.binarySearch(moves1, m6);
- int testeC5 = Arrays.binarySearch(moves2, m5);
- int testeD5 = Arrays.binarySearch(moves2, m6);
- int testeE5 = Arrays.binarySearch(moves3, m4);
- int testeF5 = Arrays.binarySearch(moves3, m5);
- if (((testeA5 >= 0) && (testeB5 >= 0)) || ((testeC5 >= 0) && (testeD5 >= 0)) || ((testeE5 >= 0) && (testeF5 >= 0))) {
- opostosOk5 = true;
- }
- String m7 = "";
- if (opostosOk5)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m5);
- int buscaM12 = Arrays.binarySearch(moves2, m5);
- int buscaM13 = Arrays.binarySearch(moves3, m5);
- if (buscaM11 >= 0) {
- do
- {
- m7 = globalMovesMenosMoves1[r.nextInt(4)];
- } while (m7 == m6);
- } else if (buscaM12 >= 0) {
- do
- {
- m7 = globalMovesMenosMoves2[r.nextInt(4)];
- } while (m7 == m6);
- } else if (buscaM13 >= 0) {
- do
- {
- m7 = globalMovesMenosMoves3[r.nextInt(4)];
- } while (m7 == m6);
- }
- }
- else
- {
- do
- {
- m7 = globalMoves[r.nextInt(6)];
- } while (m7 == m6);
- }
- boolean opostosOk6 = false;
- int testeA6 = Arrays.binarySearch(moves1, m6);
- int testeB6 = Arrays.binarySearch(moves1, m7);
- int testeC6 = Arrays.binarySearch(moves2, m6);
- int testeD6 = Arrays.binarySearch(moves2, m7);
- int testeE6 = Arrays.binarySearch(moves3, m6);
- int testeF6 = Arrays.binarySearch(moves3, m7);
- if (((testeA6 >= 0) && (testeB6 >= 0)) || ((testeC6 >= 0) && (testeD6 >= 0)) || ((testeE6 >= 0) && (testeF6 >= 0))) {
- opostosOk6 = true;
- }
- String m8 = "";
- if (opostosOk6)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m6);
- int buscaM12 = Arrays.binarySearch(moves2, m6);
- int buscaM13 = Arrays.binarySearch(moves3, m6);
- if (buscaM11 >= 0) {
- m8 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m8 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m8 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m8 = globalMoves[r.nextInt(6)];
- } while (m8 == m7);
- }
- boolean opostosOk7 = false;
- int testeA7 = Arrays.binarySearch(moves1, m7);
- int testeB7 = Arrays.binarySearch(moves1, m8);
- int testeC7 = Arrays.binarySearch(moves2, m7);
- int testeD7 = Arrays.binarySearch(moves2, m8);
- int testeE7 = Arrays.binarySearch(moves3, m7);
- int testeF7 = Arrays.binarySearch(moves3, m8);
- if (((testeA7 >= 0) && (testeB7 >= 0)) || ((testeC7 >= 0) && (testeD7 >= 0)) || ((testeE7 >= 0) && (testeF7 >= 0))) {
- opostosOk7 = true;
- }
- String m9 = "";
- if (opostosOk7)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m7);
- int buscaM12 = Arrays.binarySearch(moves2, m7);
- int buscaM13 = Arrays.binarySearch(moves3, m7);
- if (buscaM11 >= 0) {
- m9 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m9 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m9 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m9 = globalMoves[r.nextInt(6)];
- } while (m9 == m8);
- }
- boolean opostosOk8 = false;
- int testeA8 = Arrays.binarySearch(moves1, m8);
- int testeB8 = Arrays.binarySearch(moves1, m9);
- int testeC8 = Arrays.binarySearch(moves2, m8);
- int testeD8 = Arrays.binarySearch(moves2, m9);
- int testeE8 = Arrays.binarySearch(moves3, m8);
- int testeF8 = Arrays.binarySearch(moves3, m9);
- if (((testeA8 >= 0) && (testeB8 >= 0)) || ((testeC8 >= 0) && (testeD8 >= 0)) || ((testeE8 >= 0) && (testeF8 >= 0))) {
- opostosOk8 = true;
- }
- String m10 = "";
- if (opostosOk8)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m8);
- int buscaM12 = Arrays.binarySearch(moves2, m8);
- int buscaM13 = Arrays.binarySearch(moves3, m8);
- if (buscaM11 >= 0) {
- m10 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m10 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m10 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m10 = globalMoves[r.nextInt(6)];
- } while (m10 == m9);
- }
- boolean opostosOk9 = false;
- int testeA9 = Arrays.binarySearch(moves1, m9);
- int testeB9 = Arrays.binarySearch(moves1, m10);
- int testeC9 = Arrays.binarySearch(moves2, m9);
- int testeD9 = Arrays.binarySearch(moves2, m10);
- int testeE9 = Arrays.binarySearch(moves3, m9);
- int testeF9 = Arrays.binarySearch(moves3, m10);
- if (((testeA9 >= 0) && (testeB9 >= 0)) || ((testeC9 >= 0) && (testeD9 >= 0)) || ((testeE9 >= 0) && (testeF9 >= 0))) {
- opostosOk9 = true;
- }
- String m11 = "";
- if (opostosOk9)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m9);
- int buscaM12 = Arrays.binarySearch(moves2, m9);
- int buscaM13 = Arrays.binarySearch(moves3, m9);
- if (buscaM11 >= 0) {
- m11 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m11 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m11 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m11 = globalMoves[r.nextInt(6)];
- } while (m11 == m10);
- }
- boolean opostosOk10 = false;
- int testeA10 = Arrays.binarySearch(moves1, m10);
- int testeB10 = Arrays.binarySearch(moves1, m11);
- int testeC10 = Arrays.binarySearch(moves2, m10);
- int testeD10 = Arrays.binarySearch(moves2, m11);
- int testeE10 = Arrays.binarySearch(moves3, m10);
- int testeF10 = Arrays.binarySearch(moves3, m11);
- if (((testeA10 >= 0) && (testeB10 >= 0)) || ((testeC10 >= 0) && (testeD10 >= 0)) || ((testeE10 >= 0) && (testeF10 >= 0))) {
- opostosOk10 = true;
- }
- String m12 = "";
- if (opostosOk10)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m10);
- int buscaM12 = Arrays.binarySearch(moves2, m10);
- int buscaM13 = Arrays.binarySearch(moves3, m10);
- if (buscaM11 >= 0) {
- m12 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m12 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m12 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m12 = globalMoves[r.nextInt(6)];
- } while (m12 == m11);
- }
- boolean opostosOk11 = false;
- int testeA11 = Arrays.binarySearch(moves1, m11);
- int testeB11 = Arrays.binarySearch(moves1, m12);
- int testeC11 = Arrays.binarySearch(moves2, m11);
- int testeD11 = Arrays.binarySearch(moves2, m12);
- int testeE11 = Arrays.binarySearch(moves3, m11);
- int testeF11 = Arrays.binarySearch(moves3, m12);
- if (((testeA11 >= 0) && (testeB11 >= 0)) || ((testeC11 >= 0) && (testeD11 >= 0)) || ((testeE11 >= 0) && (testeF11 >= 0))) {
- opostosOk11 = true;
- }
- String m13 = "";
- if (opostosOk11)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m11);
- int buscaM12 = Arrays.binarySearch(moves2, m11);
- int buscaM13 = Arrays.binarySearch(moves3, m11);
- if (buscaM11 >= 0) {
- m13 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m13 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m13 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m13 = globalMoves[r.nextInt(6)];
- } while (m13 == m12);
- }
- boolean opostosOk12 = false;
- int testeA12 = Arrays.binarySearch(moves1, m12);
- int testeB12 = Arrays.binarySearch(moves1, m13);
- int testeC12 = Arrays.binarySearch(moves2, m12);
- int testeD12 = Arrays.binarySearch(moves2, m13);
- int testeE12 = Arrays.binarySearch(moves3, m12);
- int testeF12 = Arrays.binarySearch(moves3, m13);
- if (((testeA12 >= 0) && (testeB12 >= 0)) || ((testeC12 >= 0) && (testeD12 >= 0)) || ((testeE12 >= 0) && (testeF12 >= 0))) {
- opostosOk12 = true;
- }
- String m14 = "";
- if (opostosOk12)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m12);
- int buscaM12 = Arrays.binarySearch(moves2, m12);
- int buscaM13 = Arrays.binarySearch(moves3, m12);
- if (buscaM11 >= 0) {
- m14 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m14 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m14 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m14 = globalMoves[r.nextInt(6)];
- } while (m14 == m13);
- }
- boolean opostosOk13 = false;
- int testeA13 = Arrays.binarySearch(moves1, m13);
- int testeB13 = Arrays.binarySearch(moves1, m14);
- int testeC13 = Arrays.binarySearch(moves2, m13);
- int testeD13 = Arrays.binarySearch(moves2, m14);
- int testeE13 = Arrays.binarySearch(moves3, m13);
- int testeF13 = Arrays.binarySearch(moves3, m14);
- if (((testeA13 >= 0) && (testeB13 >= 0)) || ((testeC13 >= 0) && (testeD13 >= 0)) || ((testeE13 >= 0) && (testeF13 >= 0))) {
- opostosOk13 = true;
- }
- String m15 = "";
- if (opostosOk13)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m13);
- int buscaM12 = Arrays.binarySearch(moves2, m13);
- int buscaM13 = Arrays.binarySearch(moves3, m13);
- if (buscaM11 >= 0) {
- m15 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m15 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m15 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m15 = globalMoves[r.nextInt(6)];
- } while (m15 == m14);
- }
- boolean opostosOk14 = false;
- int testeA14 = Arrays.binarySearch(moves1, m14);
- int testeB14 = Arrays.binarySearch(moves1, m15);
- int testeC14 = Arrays.binarySearch(moves2, m14);
- int testeD14 = Arrays.binarySearch(moves2, m15);
- int testeE14 = Arrays.binarySearch(moves3, m14);
- int testeF14 = Arrays.binarySearch(moves3, m15);
- if (((testeA14 >= 0) && (testeB14 >= 0)) || ((testeC14 >= 0) && (testeD14 >= 0)) || ((testeE14 >= 0) && (testeF14 >= 0))) {
- opostosOk14 = true;
- }
- String m16 = "";
- if (opostosOk14)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m14);
- int buscaM12 = Arrays.binarySearch(moves2, m14);
- int buscaM13 = Arrays.binarySearch(moves3, m14);
- if (buscaM11 >= 0) {
- m16 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m16 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m16 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m16 = globalMoves[r.nextInt(6)];
- } while (m16 == m15);
- }
- boolean opostosOk15 = false;
- int testeA15 = Arrays.binarySearch(moves1, m15);
- int testeB15 = Arrays.binarySearch(moves1, m16);
- int testeC15 = Arrays.binarySearch(moves2, m15);
- int testeD15 = Arrays.binarySearch(moves2, m16);
- int testeE15 = Arrays.binarySearch(moves3, m15);
- int testeF15 = Arrays.binarySearch(moves3, m16);
- if (((testeA15 >= 0) && (testeB15 >= 0)) || ((testeC15 >= 0) && (testeD15 >= 0)) || ((testeE15 >= 0) && (testeF15 >= 0))) {
- opostosOk15 = true;
- }
- String m17 = "";
- if (opostosOk15)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m15);
- int buscaM12 = Arrays.binarySearch(moves2, m15);
- int buscaM13 = Arrays.binarySearch(moves3, m15);
- if (buscaM11 >= 0) {
- m17 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m17 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m17 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m17 = globalMoves[r.nextInt(6)];
- } while (m17 == m16);
- }
- boolean opostosOk16 = false;
- int testeA16 = Arrays.binarySearch(moves1, m16);
- int testeB16 = Arrays.binarySearch(moves1, m17);
- int testeC16 = Arrays.binarySearch(moves2, m16);
- int testeD16 = Arrays.binarySearch(moves2, m17);
- int testeE16 = Arrays.binarySearch(moves3, m16);
- int testeF16 = Arrays.binarySearch(moves3, m17);
- if (((testeA16 >= 0) && (testeB16 >= 0)) || ((testeC16 >= 0) && (testeD16 >= 0)) || ((testeE16 >= 0) && (testeF16 >= 0))) {
- opostosOk16 = true;
- }
- String m18 = "";
- if (opostosOk16)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m16);
- int buscaM12 = Arrays.binarySearch(moves2, m16);
- int buscaM13 = Arrays.binarySearch(moves3, m16);
- if (buscaM11 >= 0) {
- m18 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m18 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m18 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m18 = globalMoves[r.nextInt(6)];
- } while (m18 == m17);
- }
- boolean opostosOk17 = false;
- int testeA17 = Arrays.binarySearch(moves1, m17);
- int testeB17 = Arrays.binarySearch(moves1, m18);
- int testeC17 = Arrays.binarySearch(moves2, m17);
- int testeD17 = Arrays.binarySearch(moves2, m18);
- int testeE17 = Arrays.binarySearch(moves3, m17);
- int testeF17 = Arrays.binarySearch(moves3, m18);
- if (((testeA17 >= 0) && (testeB17 >= 0)) || ((testeC17 >= 0) && (testeD17 >= 0)) || ((testeE17 >= 0) && (testeF17 >= 0))) {
- opostosOk17 = true;
- }
- String m19 = "";
- if (opostosOk17)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m17);
- int buscaM12 = Arrays.binarySearch(moves2, m17);
- int buscaM13 = Arrays.binarySearch(moves3, m17);
- if (buscaM11 >= 0) {
- m19 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m19 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m19 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m19 = globalMoves[r.nextInt(6)];
- } while (m19 == m18);
- }
- boolean opostosOk18 = false;
- int testeA18 = Arrays.binarySearch(moves1, m18);
- int testeB18 = Arrays.binarySearch(moves1, m19);
- int testeC18 = Arrays.binarySearch(moves2, m18);
- int testeD18 = Arrays.binarySearch(moves2, m19);
- int testeE18 = Arrays.binarySearch(moves3, m18);
- int testeF18 = Arrays.binarySearch(moves3, m19);
- if (((testeA18 >= 0) && (testeB18 >= 0)) || ((testeC18 >= 0) && (testeD18 >= 0)) || ((testeE18 >= 0) && (testeF18 >= 0))) {
- opostosOk18 = true;
- }
- String m20 = "";
- if (opostosOk18)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m18);
- int buscaM12 = Arrays.binarySearch(moves2, m18);
- int buscaM13 = Arrays.binarySearch(moves3, m18);
- if (buscaM11 >= 0) {
- m20 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m20 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m20 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m20 = globalMoves[r.nextInt(6)];
- } while (m20 == m19);
- }
- boolean opostosOk19 = false;
- int testeA19 = Arrays.binarySearch(moves1, m19);
- int testeB19 = Arrays.binarySearch(moves1, m20);
- int testeC19 = Arrays.binarySearch(moves2, m19);
- int testeD19 = Arrays.binarySearch(moves2, m20);
- int testeE19 = Arrays.binarySearch(moves3, m19);
- int testeF19 = Arrays.binarySearch(moves3, m20);
- if (((testeA19 >= 0) && (testeB19 >= 0)) || ((testeC19 >= 0) && (testeD19 >= 0)) || ((testeE19 >= 0) && (testeF19 >= 0))) {
- opostosOk19 = true;
- }
- String m21 = "";
- if (opostosOk19)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m19);
- int buscaM12 = Arrays.binarySearch(moves2, m19);
- int buscaM13 = Arrays.binarySearch(moves3, m19);
- if (buscaM11 >= 0) {
- m21 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m21 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m21 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m21 = globalMoves[r.nextInt(6)];
- } while (m21 == m20);
- }
- boolean opostosOk20 = false;
- int testeA20 = Arrays.binarySearch(moves1, m20);
- int testeB20 = Arrays.binarySearch(moves1, m21);
- int testeC20 = Arrays.binarySearch(moves2, m20);
- int testeD20 = Arrays.binarySearch(moves2, m21);
- int testeE20 = Arrays.binarySearch(moves3, m20);
- int testeF20 = Arrays.binarySearch(moves3, m21);
- if (((testeA20 >= 0) && (testeB20 >= 0)) || ((testeC20 >= 0) && (testeD20 >= 0)) || ((testeE20 >= 0) && (testeF20 >= 0))) {
- opostosOk20 = true;
- }
- String m22 = "";
- if (opostosOk20)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m20);
- int buscaM12 = Arrays.binarySearch(moves2, m20);
- int buscaM13 = Arrays.binarySearch(moves3, m20);
- if (buscaM11 >= 0) {
- m22 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m22 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m22 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m22 = globalMoves[r.nextInt(6)];
- } while (m22 == m21);
- }
- boolean opostosOk21 = false;
- int testeA21 = Arrays.binarySearch(moves1, m21);
- int testeB21 = Arrays.binarySearch(moves1, m22);
- int testeC21 = Arrays.binarySearch(moves2, m21);
- int testeD21 = Arrays.binarySearch(moves2, m22);
- int testeE21 = Arrays.binarySearch(moves3, m21);
- int testeF21 = Arrays.binarySearch(moves3, m22);
- if (((testeA21 >= 0) && (testeB21 >= 0)) || ((testeC21 >= 0) && (testeD21 >= 0)) || ((testeE21 >= 0) && (testeF21 >= 0))) {
- opostosOk21 = true;
- }
- String m23 = "";
- if (opostosOk21)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m21);
- int buscaM12 = Arrays.binarySearch(moves2, m21);
- int buscaM13 = Arrays.binarySearch(moves3, m21);
- if (buscaM11 >= 0) {
- m23 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m23 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m23 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m23 = globalMoves[r.nextInt(6)];
- } while (m23 == m22);
- }
- boolean opostosOk22 = false;
- int testeA22 = Arrays.binarySearch(moves1, m22);
- int testeB22 = Arrays.binarySearch(moves1, m23);
- int testeC22 = Arrays.binarySearch(moves2, m22);
- int testeD22 = Arrays.binarySearch(moves2, m23);
- int testeE22 = Arrays.binarySearch(moves3, m22);
- int testeF22 = Arrays.binarySearch(moves3, m23);
- if (((testeA22 >= 0) && (testeB22 >= 0)) || ((testeC22 >= 0) && (testeD22 >= 0)) || ((testeE22 >= 0) && (testeF22 >= 0))) {
- opostosOk22 = true;
- }
- String m24 = "";
- if (opostosOk22)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m22);
- int buscaM12 = Arrays.binarySearch(moves2, m22);
- int buscaM13 = Arrays.binarySearch(moves3, m22);
- if (buscaM11 >= 0) {
- m24 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m24 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m24 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- }
- else
- {
- do
- {
- m24 = globalMoves[r.nextInt(6)];
- } while (m24 == m23);
- }
- boolean opostosOk23 = false;
- int testeA23 = Arrays.binarySearch(moves1, m23);
- int testeB23 = Arrays.binarySearch(moves1, m24);
- int testeC23 = Arrays.binarySearch(moves2, m23);
- int testeD23 = Arrays.binarySearch(moves2, m24);
- int testeE23 = Arrays.binarySearch(moves3, m23);
- int testeF23 = Arrays.binarySearch(moves3, m24);
- if (((testeA23 >= 0) && (testeB23 >= 0)) || ((testeC23 >= 0) && (testeD23 >= 0)) || ((testeE23 >= 0) && (testeF23 >= 0))) {
- opostosOk23 = true;
- }
- String m25 = "";
- if (opostosOk23)
- {
- int buscaM11 = Arrays.binarySearch(moves1, m23);
- int buscaM12 = Arrays.binarySearch(moves2, m23);
- int buscaM13 = Arrays.binarySearch(moves3, m23);
- if (buscaM11 >= 0) {
- do
- {
- m25 = globalMovesMenosMoves1[r.nextInt(4)];
- } while (m25 == m24);
- } else if (buscaM12 >= 0) {
- do
- {
- m25 = globalMovesMenosMoves2[r.nextInt(4)];
- } while (m25 == m24);
- } else if (buscaM13 >= 0) {
- do
- {
- m25 = globalMovesMenosMoves3[r.nextInt(4)];
- } while (m25 == m24);
- }
- }
- else
- {
- do
- {
- m25 = globalMoves[r.nextInt(6)];
- } while (m25 == m24);
- }
- String moves = m1 + mm1 + m2 + mm2 + m3 + mm3 + m4 + mm4 + m5 + mm5 + m6 +
- mm6 + m7 + mm7 + m8 + mm8 + m9 + mm9 + m10 + mm10 + m11 + mm11 +
- m12 + mm12 + m13 + mm13 + m14 + mm14 + m15 + mm15 + m16 + mm16 + m17
- + mm17 + m18 + mm18 + m19 + mm19 + m20 + mm20 + m21 + mm21 + m22 +
- mm22 + m23 + mm23 + m24 + mm24 + m25 + mm25;
- return moves;
- }
- }
- //////////////////////////////////CLOCK SCR
- package javaapplication1;
- import java.util.Random;
- public class ScrambleClock {
- public String embaralharClock() {
- Random r = new Random();
- String[] sentidos = {"5- ", "4- ", "3- ", "2- ", "1- ", "0 ",
- "1+ ", "2+ ", "3+ ", "4+ ", "5+ ", "6+ "};
- String[] pinos = {"UR ", "DR ", "DL ", "UL "};
- int[] decisão = {1, 2, 3, 4};
- int valor = decisão[r.nextInt(4)];
- String scramble = "UR" + sentidos[r.nextInt(12)]
- + "DR" + sentidos[r.nextInt(12)]
- + "DL" + sentidos[r.nextInt(12)]
- + "UL" + sentidos[r.nextInt(12)]
- + "U" + sentidos[r.nextInt(12)]
- + "R" + sentidos[r.nextInt(12)]
- + "D" + sentidos[r.nextInt(12)]
- + "L" + sentidos[r.nextInt(12)]
- + "ALL" + sentidos[r.nextInt(12)]
- + "y2 "
- + "U" + sentidos[r.nextInt(12)]
- + "R" + sentidos[r.nextInt(12)]
- + "D" + sentidos[r.nextInt(12)]
- + "L" + sentidos[r.nextInt(12)]
- + "ALL" + sentidos[r.nextInt(12)];
- String pinoss1 = "";
- String pinoss2 = "";
- String pinoss3 = "";
- String pinoss4 = "";
- if (valor == 1) {
- pinoss1 = pinos[r.nextInt(4)];
- } else if (valor == 2) {
- pinoss1 = pinos[r.nextInt(4)];
- do {
- pinoss2 = pinos[r.nextInt(4)];
- } while (pinoss2 == pinoss1);
- } else if (valor == 3) {
- pinoss1 = pinos[r.nextInt(4)];
- do {
- pinoss2 = pinos[r.nextInt(4)];
- } while (pinoss2 == pinoss1);
- do {
- do{
- pinoss3 = pinos[r.nextInt(4)];
- }while(pinoss3 == pinoss1);
- } while (pinoss3 == pinoss2);
- } else {
- pinoss4 = "UR DR DL UL";
- }
- String pinoFinal = pinoss1 + pinoss2 + pinoss3 + pinoss4;
- String scrambleFinal = scramble + pinoFinal;
- return scrambleFinal;
- }
- }
- ////////////////////////////MEGA SCR
- package javaapplication1;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Random;
- public class ScrambleMegaminx {
- public ArrayList embaralharMegaminx() {
- Random r = new Random();
- ArrayList<String> lista = new ArrayList<>();
- String[] moves1 = {"R++ ", "R-- "};
- String[] moves2 = {"D++ ", "D-- "};
- String[] moves3 = {"U\n", "U'\n"};
- String[] m1 = new String[3];
- String[] m2 = new String[3];
- String[] m3 = new String[3];
- //for (int j = 0; j < 8; j++) {
- for (int i = 0; i < 3; i++) {
- m1[i] = moves1[r.nextInt(2)];
- m2[i] = moves2[r.nextInt(2)];
- lista.add(m1[i]);
- lista.add(m2[i]);
- if (i == 2) {
- m1[i] = moves1[r.nextInt(2)];
- m2[i] = moves2[r.nextInt(2)];
- m1[i] = moves1[r.nextInt(2)];
- m2[i] = moves2[r.nextInt(2)];
- m1[i] = moves1[r.nextInt(2)];
- m3[i] = moves3[r.nextInt(2)];
- lista.add(m1[i]);
- lista.add(m2[i]);
- lista.add(m1[i]);
- lista.add(m2[i]);
- lista.add(m1[i]);
- lista.add(m3[i]);
- }
- }
- //}
- return lista;
- }
- }
- //////////////////////////////////SKEWB SCR
- package javaapplication1;
- import java.util.ArrayList;
- import java.util.Random;
- public class ScrambleSkewb {
- public ArrayList embaralhar2x2() {
- ArrayList<String> lista = new ArrayList<>();
- Random r = new Random();
- String[] moves1 = {"B", "U", "R", "L"};
- String[] moves2 = {" ", "' "};
- String s = "";
- String f = "";
- for (int i = 0; i < 8; i++) {
- do {
- f = moves1[r.nextInt(4)];
- } while (f == s);
- s = f;
- String u = moves2[r.nextInt(2)];
- lista.add(s + u);
- }
- return lista;
- }
- }
- /////////////////////////////////////SQR SCR (N FINALIZADO)
- package javaapplication2;
- import java.util.Random;
- public class SqScr {
- public static void main(String[] args) {
- Random r = new Random();
- String[] startUpMove = {"-5", "-3", "-2", "0", "1", "3", "4", "6"};
- String[] movimentoInicialB_a1 = {"-5", "-2", "1", "4"};
- String[] movimentoInicialB_a2 = {"-3", "0", "3", "6"};
- String[] movimentoInicialB_b = {"-4", "-1", "2", "5"};
- String[] movimentosEquivalentesAMenos1Cima = {"-4", "-1", "2", "5"};
- String[] cubeShapeCases = {
- "(3,0)/(1,-4)/(0,2)/(4,6)/(2,1)/(-3,-1)",
- "(0,-3)/(-2,-1)/(-3,4)/(3,2)/(2,-2)",
- "(0,-3)/(-2,-1)/(-3,2)/(-1,-2)/(-4,0)",
- "(3,0)/(1,2)/(2,6)/(4,-4)/(1,2)",
- "(0,-3)/(-2,-1)/(-3,4)/(-5,2)/(1,2)",
- "(0,-3)/(-2,-1)/(-3,4)/(3,6)/(-2,3)",
- "(3,0)/(1,-4)/(0,2)/(4,6)/(-4,1)",
- "(0,-3)/(-2,-1)/(-3,4)/(6,4)/(2,0)",
- "(0,-3)/(-2,-1)/(-3,4)/(3,-4/)(4,-5)",
- "(3,0)/(1,2)/(2,0)/(-1,0)/(-2,0)",
- "(0,-3)/(-2,-1)/(-3,4)/(1,2)/(0,-4)",
- "(3,0)/(1,-4)/(0,2/)(4,6)/(2,1)",
- "(3,3)/(-1,-2)/(0,-2)/(-5,-4)/(-4,3)",
- "(3,3)/(-1,-2)/(0,-2)/(-5,-4)/(-4,3)",
- //14°
- };
- String shape = "";
- while (true) {
- boolean cimaEstáDesalinhado = false;
- boolean baixoEstáDesalinhado = false;
- String move1 = "";
- String move2 = "";
- String move3 = "";
- String move4 = "";
- String move5 = "";
- String move6 = "";
- String move7 = "";
- String move8 = "";
- String move9 = "";
- String move10 = "";
- String move11 = "";
- String move12 = "";
- if (cimaEstáDesalinhado == false && baixoEstáDesalinhado == false) {
- move1 = startUpMove[r.nextInt(8)];
- }
- if (move1.contains("-5") || move1.contains("-2") || move1.contains("1") || move1.contains("4")) {
- cimaEstáDesalinhado = true;
- baixoEstáDesalinhado = false;
- move2 = movimentoInicialB_a2[r.nextInt(4)];
- } else {
- cimaEstáDesalinhado = false;
- baixoEstáDesalinhado = true;
- move2 = movimentoInicialB_b[r.nextInt(4)];
- }
- if (cimaEstáDesalinhado == true && baixoEstáDesalinhado == false) {
- cimaEstáDesalinhado = false;
- baixoEstáDesalinhado = true;
- move3 = movimentosEquivalentesAMenos1Cima[r.nextInt(4)];
- move4 = movimentoInicialB_b[r.nextInt(4)];
- } else if (cimaEstáDesalinhado == false && baixoEstáDesalinhado == true) {
- move3 = startUpMove[r.nextInt(8)];
- if (move3.contains("-5") || move3.contains("-2") || move3.contains("1") || move3.contains("4")) {
- cimaEstáDesalinhado = true;
- baixoEstáDesalinhado = false;
- move4 = movimentoInicialB_a1[r.nextInt(4)];
- } else {
- cimaEstáDesalinhado = false;
- baixoEstáDesalinhado = true;
- move4 = movimentoInicialB_a2[r.nextInt(4)];
- }
- }
- if (cimaEstáDesalinhado == false && baixoEstáDesalinhado == true) {
- move5 = startUpMove[r.nextInt(4)];
- if (move5.contains("-5") || move5.contains("-2") || move5.contains("1") || move5.contains("4")) {
- cimaEstáDesalinhado = true;
- baixoEstáDesalinhado = false;
- move6 = movimentoInicialB_a1[r.nextInt(4)];
- } else {
- cimaEstáDesalinhado = false;
- baixoEstáDesalinhado = true;
- move6 = movimentoInicialB_a2[r.nextInt(4)];
- }
- } else if (cimaEstáDesalinhado == true && baixoEstáDesalinhado == false) {
- cimaEstáDesalinhado = false;
- baixoEstáDesalinhado = true;
- move5 = movimentosEquivalentesAMenos1Cima[r.nextInt(4)];
- move6 = movimentoInicialB_b[r.nextInt(4)];
- }
- if (cimaEstáDesalinhado == true && baixoEstáDesalinhado == false) {
- move7 = movimentosEquivalentesAMenos1Cima[r.nextInt(4)];
- move8 = movimentoInicialB_b[r.nextInt(4)];
- move9 = startUpMove[r.nextInt(8)];
- if (move9.contains("-5") || move9.contains("-2") || move9.contains("1") || move9.contains("4")) {
- move10 = movimentoInicialB_a1[r.nextInt(4)];
- move11 = movimentosEquivalentesAMenos1Cima[r.nextInt(4)];
- move12 = movimentoInicialB_a2[r.nextInt(4)];
- System.out.print("(" + move1 + "," + move2 + ")/" + "(" + move3 + "," + move4 + ")/("
- + move5 + "," + move6 + ")/(" + move7 + "," + move8 + ")/(" + move9 + "," + move10 + ")/("
- + move11 + "," + move12 + ")/");
- break;
- } else {
- move10 = movimentoInicialB_a1[r.nextInt(4)];
- System.out.print("(" + move1 + "," + move2 + ")/" + "(" + move3 + "," + move4 + ")/("
- + move5 + "," + move6 + ")/(" + move7 + "," + move8 + ")/(" + move9 + "," + move10 + ")/");
- break;
- }
- }
- }
- //shape = cubeShapeCases[r.nextInt(14)];
- System.out.println(cubeShapeCases[r.nextInt(14)]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement