setup.diminishingReturn ??= function(base,targetRaw,grace,algorithm='sqrt'){
	let difference = targetRaw - base;
	let differenceAbs = Math.abs(difference);

	if(differenceAbs < grace)
		return targetRaw;

	let differenceSign= Math.sign(difference);
	let differenceAbsWithoutGrace = differenceAbs - grace;

	let differenceDiminshed = 0;
	switch (algorithm) {
		case 'sqrt':
			differenceDiminshed = Math.sqrt(differenceAbsWithoutGrace);
			break;

		default:
			console.error('diminishingReturn','Algorithm not found',algorithm);
			return 0;
	}

	let differenceComplete = (differenceDiminshed + grace) * differenceSign;

	return base + differenceComplete;

}