Skip to content

Targeting Matrix ​

Origins

Targeting Matrix was developed and documented by the RoboWiki community as a curve-fitting alternative to the bucket-and-count approach GuessFactor Targeting and BestPSpace both build on.

A GuessFactor bin only means something once enough shots have landed in it. Early in a battle, or with a rare combination of segment values, plenty of bins sit at zero or one visits, too thin to trust. A Targeting Matrix sidesteps the bucket entirely: instead of counting visits per bin, it fits one smooth mathematical curve through every recorded shot at once, and that curve can answer for a distance or velocity it has never exactly visited.

Fit a curve instead of filling bins ​

Treat "predict the firing angle from distance" as ordinary curve fitting. Pick a polynomial degree, record one row per shot with that distance raised to each power, and record the angle that shot actually needed next to it. That is exactly the linear algebra problem Ax=bAx = b: AA holds the recorded distance features, bb holds the correct angles, and xx holds the polynomial coefficients still to be solved for.

Solve it with one matrix equation ​

AA is not square, more shots than unknowns, so there is no exact solution, only a best fit. The least-squares answer comes from the normal equations:

x=(A⊤A)−1A⊤bx = (A^\top A)^{-1} A^\top b

Once xx is solved, predicting a new angle is just evaluating the polynomial at the new distance: f(x)=x1⋅distance2+x2⋅distance+x3f(x) = x_1 \cdot \text{distance}^2 + x_2 \cdot \text{distance} + x_3. A three-point example makes the setup concrete: three recorded distances aa, bb, cc and their known-correct angles fill A=[a2a1b2b1c2c1]A = \begin{bmatrix} a^2 & a & 1 \\ b^2 & b & 1 \\ c^2 & c & 1 \end{bmatrix} against the three angles in bb, and solving for xx gives the coefficients that fit a curve through all three points at once, not a lookup table for exactly those three.

Add more variables without adding more buckets ​

Segmentation grows by multiplication: adding a new variable to a GuessFactor gun means splitting every existing bin into more, smaller bins, each needing its own visits to fill. A Targeting Matrix grows by addition instead. Adding target velocity as a second factor just appends another column to AA, distance stays a column, velocity becomes a column, the angle in bb does not change, and the same normal-equation solve handles both at once.

Name the cost ​

A polynomial degree is a commitment made in advance. Too low, and the curve cannot bend enough to track real behavior. Too high, and it chases noise between data points instead of the underlying pattern, a risk that grows with every variable added. The matrix solve itself is real computation, cheap for one recompute but not free to run every tick the way incrementing a bin counter is. Most importantly, a smooth curve assumes the relationship actually is smooth. GuessFactor Targeting or Multiple Choice & BestPSpace can represent a movement pattern with two separate peaks in the same bin range, a single polynomial curve fits through the middle of both and describes neither.

Further Reading ​

Based on RoboWiki content (CC BY-SA 3.0) for classic Robocode and the official Robocode Tank Royale documentation.