1 2 package org.objectweb.jac.samples.solitaire; 3 4 import java.util.*; 5 6 public class Run{ 7 public static void main(String [] args) { 8 byte[][] game = new byte[][] { 9 new byte[] {2,2,2,2,2,2,2,2,2,2,2} , 10 new byte[] {2,2,2,2,2,2,2,2,2,2,2} , 11 new byte[] {2,2,2,2,0,0,0,2,2,2,2} , 12 new byte[] {2,2,2,2,0,1,0,2,2,2,2} , 13 new byte[] {2,2,0,0,1,1,1,0,0,2,2} , 14 new byte[] {2,2,0,1,1,0,1,1,0,2,2} , 15 new byte[] {2,2,0,0,1,1,1,0,0,2,2} , 16 new byte[] {2,2,2,2,0,1,0,2,2,2,2} , 17 new byte[] {2,2,2,2,0,0,0,2,2,2,2} , 18 new byte[] {2,2,2,2,2,2,2,2,2,2,2} , 19 new byte[] {2,2,2,2,2,2,2,2,2,2,2} 20 } ; 21 22 int x = 0; 23 Vector current = new Vector(); 24 current.add( new Configuration(32,game,null) ); 25 Vector next = new Vector(); 26 boolean finish = true; 27 do { x = x+1; 28 System.out.println( "Next step for :" ); 29 for ( int i=0; i < current.size(); i++ ) { 31 Vector children = new Vector(); 32 children = ((Configuration)current.get(i)).createChildren(); 33 34 for (int j=0; j < children.size(); j++) { 35 36 byte[][] element = new byte[11][]; 37 for(int k = 0 ; k < 11 ; k++) 38 element[k] = (byte[]) ((Configuration)children.get(j)).game[k].clone(); 39 40 byte[][] copy1 = new byte[element.length][]; 41 for(int k = 0 ; k < element.length ; k++){ 42 copy1[10 - k] = (byte[]) element[k].clone();} 43 44 byte[][] copy2 = new byte[element.length][element.length]; 45 for(int k = 0 ; k < element.length ; k++) 46 for(int l = 0 ; l < element.length ; l++){ 47 copy2[k][l] = element[l][k];} 48 49 byte[][] copy3 = new byte[element.length][]; 50 for(int k = 0 ; k < element.length ; k++){ 51 copy3[10 - k] = (byte[]) copy2[k].clone();} 52 53 byte[][] copy4 = new byte[element.length][element.length]; 54 for(int k = 0 ; k < element.length ; k++) 55 for(int l = 0 ; l < element.length ; l++){ 56 copy4[k][l] = copy1[l][k];} 57 58 byte[][] copy5 = new byte[element.length][]; 59 for(int k = 0 ; k < element.length ; k++){ 60 copy5[10 - k] = (byte[]) copy4[k].clone();} 61 62 byte[][] copy6 = new byte[element.length][element.length]; 63 for(int k = 0 ; k < element.length ; k++) 64 for(int l = 0 ; l < element.length ; l++){ 65 copy6[k][l] = copy5[l][k];} 66 67 byte[][] copy7 = new byte[element.length][]; 68 for(int k = 0 ; k < element.length ; k++){ 69 copy7[10 - k] = (byte[]) copy6[k].clone();} 70 71 72 80 81 next.add ( children.get(j) ); 82 } }System.out.println( "taille : " + next.size() ); 83 84 finish = true; 85 86 if (next.size() > 0) { 87 current = next; 88 finish = false; 89 } 90 next = new Vector(); 91 } while ( finish == false ); 92 Configuration affichage = new Configuration(0, game , null); 93 94 for (int b=0; b < current.size(); b++) { 95 affichage = (Configuration)current.get(b); 96 System.out.println("--------------------------------------------------" ); 97 for ( int a=0; a < x; a++ ) { 98 System.out.println( affichage ); 99 affichage = affichage.parent; 100 } 101 } 102 103 } 104 105 } 106 | Popular Tags |