SwitchHistoryRule limits quality incorrectly
Created by: twdkeule
The check drops + noDrops >= SAMPLE_SIZE
is placed incorrectly.
If quality starts at level 1, drops to lvl 0 and then rises to lvl 4 and stays there, quality will sometimes we limited to lvl 3, which makes no sense.
In the for loop there is in this order:
- a nodrop at lvl 0 => MAX_SWITCHOK, but not enough samples
- a drop at lvl 1 => MAX_SWITCH not OK , but not enough samples
- 4 nodrops at lvl 4 => enough samples, but MAX_SWITCH is still not OK from the previous drop at lvl 1 => limit quality to level 3. Which, again, makes no sense.
for (let i = 0; i < switchRequests.length; i++) {
if (switchRequests[i] !== undefined) {
drops += switchRequests[i].drops;
noDrops += switchRequests[i].noDrops;
dropSize += switchRequests[i].dropSize;
if (drops + noDrops >= SAMPLE_SIZE && (drops / noDrops > MAX_SWITCH)) {
switchRequest.value = i > 0 ? i - 1 : 0;
switchRequest.reason = {index: switchRequest.value, drops: drops, noDrops: noDrops, dropSize: dropSize};
log('Switch history rule index: ' + switchRequest.value + ' samples: ' + (drops + noDrops) + ' drops: ' + drops);
break;
}
}
}