Reduce some false positives with survivalfly. [Not finished.]

This commit is contained in:
asofold 2013-02-05 01:52:15 +01:00
parent fcd18ead24
commit 2b8dd41461

View File

@ -344,7 +344,7 @@ public class SurvivalFly extends Check {
if (!resetFrom && !resetTo){ if (!resetFrom && !resetTo){
// "On-air" checks (vertical) // "On-air" checks (vertical)
vDistanceAboveLimit = Math.max(vDistanceAboveLimit, verticalAccounting(now, yDistance, data, cc)); vDistanceAboveLimit = Math.max(vDistanceAboveLimit, verticalAccounting(now, from, to, yDistance, data, cc));
} }
final double result = (Math.max(hDistanceAboveLimit, 0D) + Math.max(vDistanceAboveLimit, 0D)) * 100D; final double result = (Math.max(hDistanceAboveLimit, 0D) + Math.max(vDistanceAboveLimit, 0D)) * 100D;
@ -682,7 +682,7 @@ public class SurvivalFly extends Check {
* @param cc * @param cc
* @return * @return
*/ */
private double verticalAccounting(final long now, final double yDistance, final MovingData data, final MovingConfig cc) { private double verticalAccounting(final long now, final PlayerLocation from, final PlayerLocation to, final double yDistance, final MovingData data, final MovingConfig cc) {
double vDistanceAboveLimit = 0; double vDistanceAboveLimit = 0;
// y direction change detection. // y direction change detection.
// TODO: Consider using accounting for y-change detection. // TODO: Consider using accounting for y-change detection.
@ -727,7 +727,7 @@ public class SurvivalFly extends Check {
// Here yDistance can be negative and positive (!). // Here yDistance can be negative and positive (!).
if (yDistance != 0D){ if (yDistance != 0D){
// final double accAboveLimit = verticalAccounting(now, yDistance, data.vDistSum, data.vDistCount ,tags, "vacc"); // final double accAboveLimit = verticalAccounting(now, yDistance, data.vDistSum, data.vDistCount ,tags, "vacc");
final double accAboveLimit = verticalAccounting(now, yDistance, data.vDistAcc ,tags, "vacc"); final double accAboveLimit = verticalAccounting(now, from, to, yDistance, data.vDistAcc ,tags, "vacc");
if (accAboveLimit > vDistanceAboveLimit){ if (accAboveLimit > vDistanceAboveLimit){
// Account for lag. // Account for lag.
// TODO: 1.1 might be too pessimistic. // TODO: 1.1 might be too pessimistic.
@ -769,7 +769,7 @@ public class SurvivalFly extends Check {
* @return absolute difference on violation.; * @return absolute difference on violation.;
*/ */
// private static final double verticalAccounting(final long now, final double value, final ActionFrequency sum, final ActionFrequency count, final ArrayList<String> tags, String tag) // private static final double verticalAccounting(final long now, final double value, final ActionFrequency sum, final ActionFrequency count, final ArrayList<String> tags, String tag)
private static final double verticalAccounting(final long now, final double value, final ActionAccumulator acc, final ArrayList<String> tags, String tag) private static final double verticalAccounting(final long now, final PlayerLocation from, final PlayerLocation to, final double value, final ActionAccumulator acc, final ArrayList<String> tags, String tag)
{ {
// sum.add(now, (float) value); // sum.add(now, (float) value);
// count.add(now, 1f); // count.add(now, 1f);
@ -777,29 +777,39 @@ public class SurvivalFly extends Check {
// TODO: Add on-eq-return parameter // TODO: Add on-eq-return parameter
// if (count.bucketScore(2) > 0 && count.bucketScore(1) > 0) { // if (count.bucketScore(2) > 0 && count.bucketScore(1) > 0) {
final int i1, i2; final int i1, i2;
if (acc.bucketCount(0) == acc.bucketCapacity()){ // TODO: distinguish near-ground moves somehow ?
i1 = 0; // if (acc.bucketCount(0) == acc.bucketCapacity()){
i2 = 1; // i1 = 0;
} // i2 = 1;
else{ // }
// else{
i1 = 1; i1 = 1;
i2 = 2; i2 = 2;
} // }
if (acc.bucketCount(i1) > 0 && acc.bucketCount(i2) > 0) { if (acc.bucketCount(i1) > 0 && acc.bucketCount(i2) > 0) {
// final float sc1 = sum.bucketScore(1); // final float sc1 = sum.bucketScore(1);
// final float sc2 = sum.bucketScore(2); // final float sc2 = sum.bucketScore(2);
final float sc1 = acc.bucketScore(i1); final float sc1 = acc.bucketScore(i1);
final float sc2 = acc.bucketScore(i2); final float sc2 = acc.bucketScore(i2);
final double diff = sc1 - sc2; final double diff = sc1 - sc2;
if (diff > 0 || value > -1.3 && Math.abs(diff) < 0.09) { final double aDiff = Math.abs(diff);
if (value < -1.1 && (Math.abs(diff) < Math.abs(value) || sc2 < - 10)){ // TODO: Relate this to the fall distance !
if (diff > 0 || value > -1.1 && aDiff <= 0.09) { // TODO: sharpen later (force speed gain while falling).
// TODO: The last part is a temporary workaround for sprinting down block-stairs (around sc1*sc2).
if (value < -1.1 && (aDiff < Math.abs(value) || sc2 < - 10)
|| value < 0 && aDiff < 0.27 && sc1 * sc2 > 0.0 && Math.abs(sc1) > 0.27 && (BlockProperties.isGround(from.getTypeIdBelow()) || BlockProperties.isGround(to.getTypeIdBelow()) || from.isOnGround(0.6, 0.4, 0))){
tags.add(tag + "grace"); tags.add(tag + "grace");
return 0; return 0;
} }
tags.add(tag); tags.add(tag);
if (diff < 0 ){
return 1.3 - aDiff;
}
else{
return diff; return diff;
} }
} }
}
// TODO: return Float.MAX_VALUE if no violation ? // TODO: return Float.MAX_VALUE if no violation ?
return 0; return 0;
} }