I need help... I'm doing Bejeweled in JAVA, but I need help to overpass a problem...

When I start the board for the first time, I cannot have 3 or more pieces of the same color, but my function "verifica_inicio" it's not doing the work that it should have :S

Can anyone help me?

pos_x/pos_y is the position in the matrix

fig_aleat is the random piece that is randomized at the moment

public int verifica_inicio(int fig_aleat,int pos_x,int pos_y){ if(pos_x<2 && pos_y<2){ return 1; } if(pos_x<2){ if((fig_aleat!=matriz[pos_x][pos_y-1] || fig_aleat!=matriz[pos_x][pos_y-2])){ return 1; } } if (pos_y<2){ if(fig_aleat!=matriz[pos_x-1][pos_y] || fig_aleat!=matriz[pos_x-2][pos_y]){ return 1; } } if(fig_aleat!=matriz[pos_x-1][pos_y] || fig_aleat!=matriz[pos_x-2][pos_y]){ if((fig_aleat!=matriz[pos_x][pos_y-1] || fig_aleat!=matriz[pos_x][pos_y-2])){ return 1; } } return 0; }