public static double scoreForUnsafePieces(BoardState state, boolean white) {
		int unsafeCount = 0;
		for(int i=0; i<BoardUtils.BOARD_SIZE; i++) {
			if(state.getCountAt(i)==0) continue;
			boolean match = (white == state.isPositionWhite(i));
			if(!match) continue;
			if(state.getCountAt(i)==1) {
				if(white && i<=5) unsafeCount++;
				else if(!white && i>=18) unsafeCount++;
				else if(canBeKilledNextMove(state, i, white)) unsafeCount += 5; // constant 5 can be changed to optimize the performance
			}
		}
		return unsafeCount;
	}