Difference between revisions of "Bin Smoothing"

From Robowiki
Jump to navigation Jump to search
(tried to make a decent page)
m (→‎PPP: very minor edit)
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{stub}}
+
The process of spreading or normalizing the values stored in a [[Visit Count Stats]] bin.
Bin Smoothing is the process of spreading or normalizing the values stored in a Bin for [[WaveSurfing]] or [[Segmentation]]. It's not needed for [[WaveSurfing]] or [[Segmentation]], but can, in theory, improve performance if done right.
+
 
=How Bin Smoothing Works=
+
With VCS, the full range of firing angles is split up into a number of discrete bins. When recording a visit (gun) or bullet hit (movement), the bin covering the firing angle is incremented. Bin Smoothing means also incrementing some or all of the rest of the bins to a lesser degree - i.e., creating a smooth graph across all the bins, instead of a single spike in the visited bin.
Bin Smoothing 'flattens' small spikes within it's Bins.
+
 
=Bin Smoothing Formulas=
+
It's debatable if this actually improves performance, especially in [[:Category:Targeting|guns]]. Nevertheless, it is a common practice.
If you have your own Bin Smoothing Formula, feel free to post it here.
+
 
==Pez==
+
== Bin Smoothing formulas ==
(going to transfer from Talk Page)
+
=== Inverse square ===
==PPP==
+
A common method is to increase the visited bin by 1 and all other bins by <code>(1 / square(abs(binIndex - visitIndex) + 1))</code>. The pattern of values added to the visited bin and its neighbors would be: 1, 1/4, 1/9, 1/16.
(going to transfer from Talk Page)
+
<syntaxhighlight>
 +
    public static void logHit(double[] bins, int index) {
 +
        for (int x = 0; x < bins.length; x++) {
 +
            bins[x] += 1 / Math.pow(Math.abs(x - index) + 1, 2);
 +
        }
 +
    }
 +
</syntaxhighlight>
 +
 
 +
=== From [[Pugilist]] ===
 +
This smooths the bin values as they are read from the visits array, using all the other bin values weighted by distance:
 +
<syntaxhighlight>
 +
    double smoothedVisits(int index) {
 +
double smoothed = 0;
 +
int i = 0;
 +
do {
 +
    smoothed += (double)visits[i] / Math.sqrt((double)(Math.abs(index - i) + 1.0));
 +
    i++;
 +
} while (i < Pugilist.FACTORS);
 +
return smoothed / Math.pow(distanceToTarget() / bulletVelocity, 1.3);
 +
    }
 +
</syntaxhighlight>
 +
 
 +
=== PPP ===
 +
This also smooths the bin values as they are read, using only the two closest neighbor bins:
 +
<syntaxhighlight>
 +
double smoothedVisits(int index) {
 +
    double smoothed = 0;
 +
    if (index > 0) {
 +
        smoothed += visits[index - 1] / 2;
 +
    }
 +
    if (index < FACTORS - 1) {
 +
        smoothed += visits[index + 1] / 2;
 +
    }
 +
    smoothed += visits[index];
 +
    return smoothed;
 +
}
 +
</syntaxhighlight>
 +
 
 +
=== Other ways ===
 +
<code>Math.pow(0.5, Math.abs(index - count))</code> - This pattern would be: 1, 0.5, 0.25, 0.125.
 +
 
 +
<code>Math.pow(0.1, Math.abs(index - count))</code> - This pattern would be: 1, 0.1, 0.01, 0.001.
 +
 
 +
== See also ==
 +
* [[Visit Count Stats]]
 +
 
 +
__NOTOC__
 +
 
 +
[[Category:Terminology]]

Latest revision as of 23:20, 24 December 2013

The process of spreading or normalizing the values stored in a Visit Count Stats bin.

With VCS, the full range of firing angles is split up into a number of discrete bins. When recording a visit (gun) or bullet hit (movement), the bin covering the firing angle is incremented. Bin Smoothing means also incrementing some or all of the rest of the bins to a lesser degree - i.e., creating a smooth graph across all the bins, instead of a single spike in the visited bin.

It's debatable if this actually improves performance, especially in guns. Nevertheless, it is a common practice.

Bin Smoothing formulas

Inverse square

A common method is to increase the visited bin by 1 and all other bins by (1 / square(abs(binIndex - visitIndex) + 1)). The pattern of values added to the visited bin and its neighbors would be: 1, 1/4, 1/9, 1/16.

    public static void logHit(double[] bins, int index) {
        for (int x = 0; x < bins.length; x++) {
            bins[x] += 1 / Math.pow(Math.abs(x - index) + 1, 2);
        }
    }

From Pugilist

This smooths the bin values as they are read from the visits array, using all the other bin values weighted by distance:

    double smoothedVisits(int index) {
	double smoothed = 0;
	int i = 0;
	do {
	    smoothed += (double)visits[i] / Math.sqrt((double)(Math.abs(index - i) + 1.0));
	    i++;
	} while (i < Pugilist.FACTORS);
	return smoothed / Math.pow(distanceToTarget() / bulletVelocity, 1.3);
    }

PPP

This also smooths the bin values as they are read, using only the two closest neighbor bins:

double smoothedVisits(int index) {
    double smoothed = 0;
    if (index > 0) {
        smoothed += visits[index - 1] / 2;
    }
    if (index < FACTORS - 1) {
        smoothed += visits[index + 1] / 2;
    }
    smoothed += visits[index];
    return smoothed;
}

Other ways

Math.pow(0.5, Math.abs(index - count)) - This pattern would be: 1, 0.5, 0.25, 0.125.

Math.pow(0.1, Math.abs(index - count)) - This pattern would be: 1, 0.1, 0.01, 0.001.

See also