for (int y=0; y<sorokszama; y++) {
for (int x=0; x<oszlopokszama; x++) {
positionPriority[x][y]=0;
positionValues[x][y]=0;
Position actual = new Position(x, y);
int celltipus = skeleton.getType(actual);
String tipus = (celltipus==ISkeletonTable.CELL_BLACK?"Fekete":"Feher");
System.out.println("at ("+x+","+y+"): "+tipus);
// ### poziciok prioritasanak szamolasa ###
if ( celltipus == ISkeletonTable.CELL_WHITE){
int x_pos = x;
boolean whitePos=true;
int celltipusNext=ISkeletonTable.CELL_BLACK;
//int celltipusNextBlack=ISkeletonTable.CELL_BLACK;
positionPriority[x][y]++;
do{
x_pos--;
Position nextPosition = new Position(x_pos, y);
celltipusNext = skeleton.getType(nextPosition);
if( celltipusNext == ISkeletonTable.CELL_WHITE )
positionPriority[x][y]++;
else
whitePos = false;
}while( whitePos == true );
// ### vizszintes + ###
x_pos = x;
do{
while ( x_pos < (oszlopokszama-1) ){
x_pos++;
Position nextPosition = new Position(x_pos, y);
celltipusNext = skeleton.getType(nextPosition);
if( celltipusNext == ISkeletonTable.CELL_WHITE )
positionPriority[x][y]++;
else
whitePos = false;
if( x_pos < (oszlopokszama-1) ){
Position nextBlackPosition = new Position(x_pos+1, y);
int celltipusNextBlack = skeleton.getType(nextBlackPosition);
if( celltipusNextBlack == ISkeletonTable.CELL_BLACK)
break;
}
if( x_pos == (oszlopokszama-1))
break;
}
}while( whitePos == true );
// ### vizszintes - ###
x_pos=x;
do{
x_pos--;
Position nextPosition = new Position(x_pos, y);
celltipusNext = skeleton.getType(nextPosition);
if( celltipusNext == ISkeletonTable.CELL_WHITE )
positionPriority[x][y]++;
else
whitePos = false;
}while( whitePos == true );
// ### fuggoleges + ###
int y_pos = y;
do{
while ( y_pos < (sorokszama-1) ){
y_pos++;
Position nextPosition = new Position(x, y_pos);
celltipusNext = skeleton.getType(nextPosition);
if( celltipusNext == ISkeletonTable.CELL_WHITE )
positionPriority[x][y]++;
else
whitePos = false;
if( y_pos < (sorokszama-1) ){
Position nextBlackPosition = new Position(x, y_pos);
int celltipusNextBlack = skeleton.getType(nextBlackPosition);
if( celltipusNextBlack == ISkeletonTable.CELL_BLACK)
break;
}
if( y_pos == (sorokszama-1))
break;
}
}while( whitePos == true );
// ### fuggoleges
y_pos=y;
do{
y_pos--;
Position nextPosition = new Position(x, y_pos);
celltipusNext = skeleton.getType(nextPosition);
if( celltipusNext == ISkeletonTable.CELL_WHITE )
positionPriority[x][y]++;
else
whitePos = false;
}while( whitePos == true );
}
System.out.println(" vizszintes prio szam: "+ positionPriority[x][y]);
// a poziciok ertekkel valo feltoltese
int i_pos, j_pos;
for( int prioNumIdx = 16; prioNumIdx >1; prioNumIdx-- ){
for (int j=0; j<sorokszama; j++) {
for (int i=0; i<oszlopokszama; i++) {
if ( positionPriority[i][j] == prioNumIdx ){
i_pos=i;
boolean[] values = new boolean[10]; // a lehetseges ertekek
for ( int v=1; v<10; v++) values[v]= true;
while ( positionPriority[i_pos][j] !=0 ){
i_pos++;
for (int check=0; check!=10; check++){
if( positionValues[i_pos][j]==check) values[check] = false;
}
}
i_pos=i;
while ( positionPriority[i_pos][j] !=0 ){
i_pos--;
for (int check=0; check!=10; check++){
if( positionValues[i_pos][j]==check) values[check] = false;
}
}
j_pos=j;
while ( positionPriority[i][j_pos] !=0 ){
j_pos++;
for (int check=0; check!=10; check++){
if( positionValues[i][j_pos]==check) values[check] = false;
}
}
j_pos=j;
while ( positionPriority[i][j_pos] !=0 ){
j_pos--;
for (int check=0; check!=10; check++){
if( positionValues[i][j_pos]==check) values[check] = false;
}
}
int valuesCount=0;
for (int v=0; v!=10; v++)
if ( values[v]==true ) valuesCount++;
Random rand = new Random();
//int n = 10;
//int r = rand.nextInt(n+1);
int r = rand.nextInt(valuesCount);
int trueIdx=0;
int w=1;
while( w!=10 ){
if( values[w]==true ){
trueIdx++;
if( trueIdx==r ) positionValues[i][j]=w;
}
w++;
}
}
//System.out.println(i+". sor, "+j+". oszlop: "+ positionValues[i][j]);
}
//System.out.println(" ###### ");
}
}
}
}
for (int jdx=0; jdx< sorokszama; jdx++){
int str[]=new int[oszlopokszama+1];
for (int idx=0; idx < oszlopokszama; idx++){
str[idx]=positionValues[idx][jdx];
//System.out.println(positionValues[idx][jdx]);
}
//System.out.println(jdx+". sor: "+str[0]+str[1]+str[2]+str[3]+str[4]+str[5]+str[6]+str[7]+str[8] );
}
// ###########################################
System.out.println("#########################");
Vector<String> wordsInRows = new Vector<String>();
Vector<String> wordsInColumns = new Vector<String>();
/*for (int x=0; x!=oszlopokszama+1; x++)
for (int y=0; y!=sorokszama+1; y++)
positionValues[x][y]=0;*/
for (int y=0; y!=sorokszama; y++) {
for (int x=0; x!=oszlopokszama; x++) {
Position actual = new Position(x, y);
Position prePosition_X = new Position( x-1 , y );
Position prePosition_Y = new Position( x , y-1 );
int celltipus = skeleton.getType(actual);
int celltipus_pre_X = skeleton.getType(prePosition_X);
int celltipus_pre_Y = skeleton.getType(prePosition_Y);
//String tipus = (celltipus==ISkeletonTable.CELL_BLACK?"Fekete":"Feher");
//System.out.println("at ("+x+","+y+"): "+tipus);
if ( celltipus_pre_X == ISkeletonTable.CELL_BLACK && celltipus == ISkeletonTable.CELL_WHITE ){
boolean nextPositionBlack=false;
int celltipusNext=ISkeletonTable.CELL_BLACK;
int x_pos = x; // ### vizszintes ###
do{
x_pos++;
if ( x_pos == oszlopokszama){
String nextWord= x + "~" + (x_pos-1) + "," + y ;
wordsInRows.add(nextWord);
nextPositionBlack = true;
}else{
Position nextPosition = new Position(x_pos, y);
celltipusNext = skeleton.getType(nextPosition);
if( celltipusNext == ISkeletonTable.CELL_BLACK ) {
nextPositionBlack = true;
String nextWord= x + "~" + (x_pos-1) + "," + y ;
wordsInRows.add(nextWord);
}
}
}while( nextPositionBlack != true );
}
if ( celltipus_pre_Y == ISkeletonTable.CELL_BLACK && celltipus == ISkeletonTable.CELL_WHITE ){
boolean nextPositionBlack=false;
int celltipusNext=ISkeletonTable.CELL_BLACK;
int y_pos = y; // ### f�gg�leges ###
do{
y_pos++;
if ( y_pos == sorokszama){
String nextWord= x + "," + y + "~" + (y_pos-1) ;
wordsInColumns.add(nextWord);
nextPositionBlack = true;
}else{
Position nextPosition = new Position(x, y_pos);
celltipusNext = skeleton.getType(nextPosition);
if( celltipusNext == ISkeletonTable.CELL_BLACK ) {
nextPositionBlack = true;
String nextWord= x + "," + y + "~" + (y_pos-1) ;
wordsInColumns.add(nextWord);