Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rascunhos_etc;
- import java.util.*;
- public class NewClass {
- public static void main(String[] args) {
- Random r = new Random();
- String[] globalMoves = {"F ", "B ", "U ", "D ", "R ", "L "};
- //Arrays classificados
- String[] moves1 = {"B ", "F "};
- String[] moves2 = {"D ", "U "};
- String[] moves3 = {"L ", "R "};
- String m1 = globalMoves[r.nextInt(6)];
- String m2 = "";
- do {
- m2 = globalMoves[r.nextInt(6)];
- } while (m2 == m1);
- int testeA = Arrays.binarySearch(moves1, m1);
- int testeB = Arrays.binarySearch(moves2, m1);
- int testeC = Arrays.binarySearch(moves3, m1);
- int testeD = Arrays.binarySearch(moves1, m2);
- // int teste21 = Arrays.binarySearch(moves2, m2);
- // int teste31 = Arrays.binarySearch(moves3, m2);
- String m3 = "";
- do {
- if (testeD == testeA || testeD == testeB || testeD == testeC) {
- m3 = moves2[r.nextInt(2)];//~~
- } else {
- m3 = globalMoves[r.nextInt(6)];
- }
- } while (m3 == m2);
- int testeE = Arrays.binarySearch(moves1, m2);
- int testeF = Arrays.binarySearch(moves2, m2);
- int testeG = Arrays.binarySearch(moves3, m2);
- int testeH = Arrays.binarySearch(moves1, m3);
- String m4 = "";
- do {
- if (testeH == testeE || testeH == testeF || testeH == testeG) {
- m4 = moves2[r.nextInt(2)];//~~
- } else {
- m4 = globalMoves[r.nextInt(6)];
- }
- } while (m4 == m3);
- int testeI = Arrays.binarySearch(moves1, m3);
- int testeJ = Arrays.binarySearch(moves2, m3);
- int testeK = Arrays.binarySearch(moves3, m3);
- int testeL = Arrays.binarySearch(moves1, m4);
- String m5 = "";
- do {
- if (testeL == testeI || testeL == testeJ || testeL == testeK) {
- m5 = moves2[r.nextInt(2)];//~~
- } else {
- m5 = globalMoves[r.nextInt(6)];
- }
- } while (m5 == m4);
- System.out.println(m1 + m2 + m3 + m4 + m5);
- //se value (m2) for encontrado na busca, binarySearch retorna
- //o índice do elemento; caso contrário, binarySearch retorna
- //um valor negativo.
- //procurando o valor
- //enquanto m3 pertencer ao array de m1: sortear de novo, mas apenas se m3 e m1 pertencer ao array de m2;
- //enquanto m3 for do mesmo array de m2: sortear de novo;
- //se m2 não pertencer ao array de m1: sortear qualquer um de globalMoves;
- //se m2 pertencer ao array de m1: sortear um valor de qualquer array, exceto do array de m1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement