throw new Exception();
for (int k=0;k<board.getTraySize();k++)
if (board.getTrayPiece(k).getColor() == Settings.topColor)
{
engine.aiReturnPlace(board.getTrayPiece(k), new Spot(x, y));
break;
}
}
}
catch (IOException e)
{
JOptionPane.showMessageDialog(null, "File Format Error: Unexpected end of file.",
"AI", JOptionPane.INFORMATION_MESSAGE);
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null, "File Format Error: Invalid File Structure.",
"AI", JOptionPane.INFORMATION_MESSAGE);
}
finally
{
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
break;
}
//double check the ai setup
for (int i=0;i<10;i++)
for (int j=0;j<4; j++)
{
Piece p = null;
for (int k=0;k<board.getTraySize();k++)
if (board.getTrayPiece(k).getColor() == Settings.topColor)
{
p = board.getTrayPiece(k);
break;
}
if (p==null)
break;
engine.aiReturnPlace(p, new Spot(i, j));
}
//if the user didn't finish placing pieces just put them on
for (int i=0;i<10;i++)
for (int j=6;j<10;j++)
{
Piece p = null;
for (int k=0;k<board.getTraySize();k++)
if (board.getTrayPiece(k).getColor() != Settings.topColor)
{
p = board.getTrayPiece(k);
break;
}
if (p==null)
break;
engine.aiReturnPlace(p, new Spot(i, j));
}
engine.play();
}