Kelvineger

Puzzle8

Mar 2nd, 2016
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. package puzzle8;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Collections;
  5. import java.util.List;
  6.  
  7. /**
  8.  *
  9.  * @author Kelvin
  10.  */
  11. public class Puzzle8 {
  12.  
  13.     public static void main(String[] args) {
  14.         boolean result = true;
  15.         List<Tabuleiro> abertos = new ArrayList<Tabuleiro>();
  16.         List<Tabuleiro> fechados = new ArrayList<Tabuleiro>();
  17.         List<Tabuleiro> aux = new ArrayList<Tabuleiro>();
  18.  
  19.         Tabuleiro tab = new Tabuleiro();
  20.  
  21.         tab.tabInicial();
  22.         tab.imprimiTab(tab.posicoes);
  23.  
  24.         if (tab.igual(tab.posicoes) == false) {
  25.             aux = tab.geraFilhos();
  26.             for (int k = 0; k < aux.size(); k++) {
  27.                 if (tab.igual(aux.get(k).posicoes) == false) {
  28.                     fechados.add(aux.get(k));
  29.                     Collections.sort(fechados);
  30.                 }
  31.             }
  32.         }
  33.         while (tab.igual(fechados.get(0).posicoes) == false) {
  34.             abertos.add(fechados.get(0));
  35.             tab.imprimiTab(aux.get(0).posicoes);
  36.             fechados.remove(fechados.get(0));
  37.             Collections.sort(fechados);
  38.             if (result == true) {
  39.                 System.out.println("achou a resolucao");
  40.             }
  41.         }
  42.     }
  43. }
Add Comment
Please, Sign In to add comment