Difference between revisions of "Bin Smoothing"

From Robowiki
Jump to navigation Jump to search
m (Using <syntaxhighlight>.)
m (→‎PPP: very minor edit)
 
(2 intermediate revisions by 2 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 [[Wave Surfing]] or [[Segmentation]]. It's not needed for [[Wave Surfing]] 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.
 
  
=== [[Pugilist]]'s ===
+
== Bin Smoothing formulas ==
 +
=== Inverse square ===
 +
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.
 +
<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>
 
<syntaxhighlight>
 
     double smoothedVisits(int index) {
 
     double smoothedVisits(int index) {
Line 22: Line 31:
  
 
=== PPP ===
 
=== PPP ===
 +
This also smooths the bin values as they are read, using only the two closest neighbor bins:
 
<syntaxhighlight>
 
<syntaxhighlight>
 
double smoothedVisits(int index) {
 
double smoothedVisits(int index) {
Line 35: Line 45:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 
=== Other ways ===
 
=== Other ways ===
<pre>Math.pow(0.5, Math.abs(index - count))</pre>
+
<code>Math.pow(0.5, Math.abs(index - count))</code> - This pattern would be: 1, 0.5, 0.25, 0.125.
This does a 50% decrease.
+
 
 +
<code>Math.pow(0.1, Math.abs(index - count))</code> - This pattern would be: 1, 0.1, 0.01, 0.001.
  
<pre>Math.pow(0.1, Math.abs(index - count))</pre>
+
== See also ==
This does a 90% decrease
+
* [[Visit Count Stats]]
  
<pre>1.0/(double)(1 + (index - count)*(index - count))</pre>
+
__NOTOC__
  
==Bots Using Bin Smoothing==
+
[[Category:Terminology]]
(Please post your Bots here if they use Bin Smoothing)
 

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