Difference between revisions of "Bin Smoothing"
Skilgannon (talk | contribs) m (→Other Ways: added another) |
m (→PPP: very minor edit) |
||
(9 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
− | + | 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 [[:Category:Targeting|guns]]. Nevertheless, it is a common practice. |
− | + | ||
− | ==[[Pugilist]]== | + | == 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> | ||
double smoothedVisits(int index) { | double smoothedVisits(int index) { | ||
double smoothed = 0; | double smoothed = 0; | ||
Line 16: | Line 28: | ||
return smoothed / Math.pow(distanceToTarget() / bulletVelocity, 1.3); | return smoothed / Math.pow(distanceToTarget() / bulletVelocity, 1.3); | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
− | ==PPP== | + | |
− | < | + | === PPP === |
+ | This also smooths the bin values as they are read, using only the two closest neighbor bins: | ||
+ | <syntaxhighlight> | ||
double smoothedVisits(int index) { | double smoothedVisits(int index) { | ||
double smoothed = 0; | double smoothed = 0; | ||
Line 30: | Line 44: | ||
return smoothed; | return smoothed; | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
− | ==Other | + | |
− | < | + | === Other ways === |
− | This | + | <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.