*/
public Casella obteMoviment( EstatCasella fitxa )
{
if ( partida.getTornsJugats() <= 1 )
{
Casella obertura = obertura();
if ( obertura != null )
{
return obertura;
}
}
tauler = partida.getTauler();
int puntuacio_millor = Integer.MIN_VALUE + 1;
Casella millor_moviment = null;
int caselles_restants = tauler.getMida() * tauler.getMida() - tauler.getTotalFitxes();
if ( partida.getTornsJugats() < 2 )
{
caselles_restants--;
}
else if ( tauler.getTotalFitxes() % ( ( int ) ( 2.3 * tauler.getMida() ) ) == 0 &&
partida.getTornsJugats() != 0 )
{
profunditat_maxima++;
}
int max_moviments = Math.max( caselles_restants / ( int ) ( Math.sqrt( tauler.getMida() ) * 0.6 ), 7 );
boolean[][] explorades = new boolean[tauler.getMida()][tauler.getMida()];
int num_explorades = 0;
while ( num_explorades < max_moviments && num_explorades < caselles_restants )
{
Casella actual =
new Casella( generador.nextInt( tauler.getMida() ), generador.nextInt( tauler.getMida() ) );
if ( tauler.esMovimentValid( fitxa, actual ) && !explorades[actual.getFila()][actual.getColumna()] )
{
explorades[actual.getFila()][actual.getColumna()] = true;
num_explorades++;
tauler.mouFitxa( fitxa, actual );
int puntuacio_actual =
negaMonteScout( fitxa, fitxaContraria( fitxa ), Integer.MIN_VALUE + 1, Integer.MAX_VALUE - 1, 1,
partida.comprovaEstatPartida( actual.getFila(), actual.getColumna() ) );
tauler.treuFitxa( actual );
if ( puntuacio_actual > puntuacio_millor )
{