Created attachment 11 [details] Bug private boolean checkPawn(){ int x = king_x; int y = king_y; Piece temp1,temp2; if(color){ temp1 = board.getPiece(x+1, y+1); temp2 = board.getPiece(x+1, y-1); if((temp1!=null && temp1 instanceof Pawn && temp1.getColor()!=color) || (temp2!=null && temp2 instanceof Pawn && temp2.getColor()!=color)) return true; else return false; } else{ temp1 = board.getPiece(x-1, y+1); temp2 = board.getPiece(x-1, y-1); if((temp1!=null && temp1 instanceof Pawn && temp1.getColor()!=color) || (temp2!=null && temp2 instanceof Pawn && temp2.getColor()!=color)) return true; else return false; } } temp1 = board.getPiece(x+1, y+1); temp2 = board.getPiece(x+1, y-1); These two lines may cause Outofboundary error if x=7 or y=7. There should be a boundary check before it.