Difference between revisions of "Visit Count Stats"
RednaxelaBot (talk | contribs) m (Using <syntaxhighlight>.) |
m (→See Also: Add link) |
||
(4 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{cleanup}} | {{cleanup}} | ||
− | Visit counts | + | Visit counts are a way to keep track of statistics. Typically this is implemented with an array or a List where each bucket contains a count on how many times it has been visited. Each element in the array is referred to as a bucket or a bin. |
== VisitCountStats and GuessFactorTargeting == | == VisitCountStats and GuessFactorTargeting == | ||
''See also: [[Talk:Visit Count Stats]]'' | ''See also: [[Talk:Visit Count Stats]]'' | ||
− | Don't confuse visit counts and [[ | + | Don't confuse visit counts and [[GuessFactor Targeting]]. They are not the same. VisitCountStats are an ''implementation'' detail, while [[GuessFactor Targeting]] is a [[:Category:Advanced Targeting Strategies|targeting strategy]]. |
− | You could have a [[GuessFactor]] gun without [[VisitCountStats]], as in the [[DynamicClustering]] gun of [[Lukious]]; you could also have a VisitCountStats gun without [[GuessFactors]], | + | You could have a [[GuessFactor]] gun without [[VisitCountStats]], as in the [[DynamicClustering]] gun of [[Lukious]]; you could also have a VisitCountStats gun without [[GuessFactors]], such as by using [[Bearing Offset|bearing offsets]] instead. The majority of [[GuessFactor]] guns, such as the one in [[GFTargetingBot]] or the [[GuessFactor Targeting Tutorial]], use VisitCountStats, but they're different things for sure. |
== Limit File Size == | == Limit File Size == | ||
''From '''VisitCountStats/LimitFileSize''' on the old wiki.'' | ''From '''VisitCountStats/LimitFileSize''' on the old wiki.'' | ||
− | Visit count stats | + | Visit count stats are simple and powerful. But if you save stats between battles you might find that the files tend to grow quite large as you fight more battles against an enemy. Here's a way to limit the size of your saved data files: |
<syntaxhighlight> public void registerFactorVisit(int[] factors, int index) { | <syntaxhighlight> public void registerFactorVisit(int[] factors, int index) { | ||
Line 35: | Line 35: | ||
If you set MAX_FACTOR_VISITS to 255 the visit count buckets will never grow above byte size and this sets a much lower limit on how big the files get. | If you set MAX_FACTOR_VISITS to 255 the visit count buckets will never grow above byte size and this sets a much lower limit on how big the files get. | ||
− | An added benefit with this approach is that it offers some [ | + | An added benefit with this approach is that it offers some StatsDecay[http://old.robowiki.net/robowiki?StatsDecay]. [[Rolling Averages]] are very effective for this though not always applicable to all VisitCountStats designs. |
− | The trick is of course to set the max value correctly since it's not as easily figured as with | + | The trick is of course to set the max value correctly since it's not as easily figured as with [[Rolling Averages]]. You'll have to experiment some to get it right I guess. And what's right against one enemy might be wrong against some others. I guess that if you add [[Virtual Guns]] to this you can use some different maximums and let the VG array figure out what works or not against a given enemy. |
== Dynamic == | == Dynamic == | ||
Line 67: | Line 67: | ||
== Examples == | == Examples == | ||
* [[Marshmallow]]: an [[ArrayList]] with custom visit count objects stored, but it can be much simpler than that. | * [[Marshmallow]]: an [[ArrayList]] with custom visit count objects stored, but it can be much simpler than that. | ||
− | * [[FloodMini]], [ | + | * [[FloodMini]], VertiLeach/Code[http://old.robowiki.net/robowiki?VertiLeach/Code], etc: a normal multi-dimensional int or double array |
== Strategies == | == Strategies == | ||
VisitCountStats can be used to store statistics for many strategies, including: | VisitCountStats can be used to store statistics for many strategies, including: | ||
− | * [[ | + | * [[Displacement Targeting]] |
− | * [[ | + | * [[GuessFactor Targeting]] |
− | * [[ | + | * [[Laser Targeting]] |
− | * [ | + | * EscapeArea Targeting[http://old.robowiki.net/robowiki?EscapeAreaTargeting] |
== See Also == | == See Also == | ||
− | * [[Rolling | + | * [[Stats Buffer]] |
+ | * [[Rolling Averages]] | ||
* [[Statistical Targeting]] | * [[Statistical Targeting]] | ||
[[Category:Statistical Algorithms]] | [[Category:Statistical Algorithms]] |
Latest revision as of 03:27, 15 September 2017
This article may require cleanup to meet RoboWiki's quality standards. Please improve this article if you can.
|
Visit counts are a way to keep track of statistics. Typically this is implemented with an array or a List where each bucket contains a count on how many times it has been visited. Each element in the array is referred to as a bucket or a bin.
Contents
VisitCountStats and GuessFactorTargeting
See also: Talk:Visit Count Stats
Don't confuse visit counts and GuessFactor Targeting. They are not the same. VisitCountStats are an implementation detail, while GuessFactor Targeting is a targeting strategy.
You could have a GuessFactor gun without VisitCountStats, as in the DynamicClustering gun of Lukious; you could also have a VisitCountStats gun without GuessFactors, such as by using bearing offsets instead. The majority of GuessFactor guns, such as the one in GFTargetingBot or the GuessFactor Targeting Tutorial, use VisitCountStats, but they're different things for sure.
Limit File Size
From VisitCountStats/LimitFileSize on the old wiki.
Visit count stats are simple and powerful. But if you save stats between battles you might find that the files tend to grow quite large as you fight more battles against an enemy. Here's a way to limit the size of your saved data files:
public void registerFactorVisit(int[] factors, int index) {
if (factors[index] < MAX_FACTOR_VISITS) {
factors[index]++;
}
else {
decrementTheOtherFactors(factors, index);
}
}
void decrementTheOtherFactors(int[] factors, int index) {
for (int i = 0, numFactors = factors.length; i < numFactors; i++) {
if (i != index && factors[i] > 0) {
factors[i]--;
}
}
}
What happens here is that visit counts never will exceed MAX_FACTOR_VISITS. When we are about to increment a visit count that has reached this maximum we instead decrement the surrounding visit counts.
If you set MAX_FACTOR_VISITS to 255 the visit count buckets will never grow above byte size and this sets a much lower limit on how big the files get.
An added benefit with this approach is that it offers some StatsDecay[1]. Rolling Averages are very effective for this though not always applicable to all VisitCountStats designs.
The trick is of course to set the max value correctly since it's not as easily figured as with Rolling Averages. You'll have to experiment some to get it right I guess. And what's right against one enemy might be wrong against some others. I guess that if you add Virtual Guns to this you can use some different maximums and let the VG array figure out what works or not against a given enemy.
Dynamic
From VisitCountStats/Dynamic on the old wiki.
Dynamic visit counts means you create a different number of visit buckets for different enemy distances. The point is that so that you shouldn't need smoothing the curve or calculate kernel densities or whatever before acting on the data in your stat buffers. It also keeps your stat files no bigger than necessary. Here's how it is implemented in GloomyDark. It assumes you are segmenting on distance, but that is a good segmentation in most cases:
...
public static final double BOT_WIDTH = 36;
...
int numFactors(double distance) {
int n = (int)(1.25 * (distance / bulletVelocity(DEFAULT_BULLET_POWER) * MAX_VELOCITY / BOT_WIDTH));
return n + 1 - n % 2;
}
int[][][][][] makeAimFactorVisits() {
int[][][][][] factors = new int[ACCEL_SEGMENTS][AIM_VELOCITY_SEGMENTS][AIM_DISTANCE_SEGMENTS][1][];
for (int a = 0; a < ACCEL_SEGMENTS; a++) {
for (int v = 0; v < AIM_VELOCITY_SEGMENTS; v++) {
for (int d = 0; d < AIM_DISTANCE_SEGMENTS; d++) {
factors[a][v][d][0] = new int[numFactors((d + 1) * MAX_DISTANCE / AIM_DISTANCE_SEGMENTS)];
}
}
}
return factors;
}
Examples
- Marshmallow: an ArrayList with custom visit count objects stored, but it can be much simpler than that.
- FloodMini, VertiLeach/Code[2], etc: a normal multi-dimensional int or double array
Strategies
VisitCountStats can be used to store statistics for many strategies, including:
- Displacement Targeting
- GuessFactor Targeting
- Laser Targeting
- EscapeArea Targeting[3]