- Overview: Take Wu and Swartz (2024) as baseline approach to obtain \(t_\text{ws}\), approximate \(t_\text{ws}\) with an efficient analytical model
Description of Wu and Swartz (2024) algorithm:
- Constraints: maximum speed \(\sqrt{v_x^2 + v_y^2} \leq v_{\text{max}}\), maximum acceleration \(\sqrt{a_x^2 + a_y^2} \leq a_{\text{max}}\)
- Two-phase model: player has constant acceleration (\(a_x\), \(a_y\)) unil he reaches \(\sqrt{v_x^2 + v_y^2} = v_\text{max}\), then continues to run to target location with \(v_{max}\)
- Obtain solution: grid search over possible acceleration pairs (\(a_x\), \(a_y\)), taking minimum time \(t\) such that player reaches target location as \(t_\text{ws}\)
Approximation model:
- Decompose time into two analytically solvable components (\(t_\text{simple}\), \(p\)) and include a scalar (\(\alpha\)) which can be learned to approximate \(t_\text{ws}\)
- \(t_\text{approx} = t_\text{simple} + \alpha \times p\)
(Jump back)
Description:
We ignore the direction of velocity. Player starts with current total speed \(v_0\), and then has constant acceleration \(a\) until he reaches \(v_\text{max}\) and then runs with \(v_\text{max}\) to target location
Two cases: player reaches target location before maximum speed or player reaches maximum speed before target location
Calculation:
Calculate distance to target location: \(d_\text{target} = \sqrt{(x_1 - x_0)^2 + (y_1 - y_0)^2}\)
Check distance player runs while accelerating to maximum speed: \(d_\text{acc} = \frac{v_\text{max} + v_0}{2} \cdot t_\text{acc}\)
where \(v_0 = \sqrt{(v_{x,0}^2 + v_{y,0}^2)}\) is the current total speed and \(t_\text{acc} = (v_\text{max} - v_0)/a\) is the time it takes to reach maximum speed
Case 1: \(d_\text{acc} \geq d_\text{target}\): solve kinematic equation \(d_\text{target} = v_0 \cdot t + \frac{1}{2} \cdot a \cdot t\) using quadratic formula to obtain: \(t_\text{simple} = \frac{-v_0 \pm \sqrt{v_0^2 + 2 \cdot a \cdot d_\text{target}}}{a}\) (take positive root, as negative solutions in time nonsensical)
Case 2: \(d_\text{acc} < d_\text{target}\): calculate time it takes to cover remaining distance after acceleration (\(d_\text{rem} = d_\text{target} - d_\text{acc}\)) as \(t_\text{rem} = \frac{d_\text{rem}}{v_\text{max}}\) and add time of acceleration phase to obtain: \(t_\text{simple} = t_\text{rem} + t_\text{acc}\)
Description:
As \(t_\text{simple}\) ignores the direction of velocity, the penalty \(p\) is a term to account for this
It is calculated as the angular mismatch of a player, i.e. the shortest angular difference between the players current movement angle and the angle from the current location of the player to the target location; and then scaled by the current total speed
Intuitively: the faster a player runs into the “wrong” direction, the higher the penalty
We test two penalty variants: (i) the angular mismatch, and (ii) the cosine difference of the angular mismatch, which introduces non-linearity
Angular mismatch calculation: \[
\Delta \theta = \min(|\theta_\text{move} - \theta_\text{target}|, 2 \pi - |\theta_\text{move} - \theta_\text{target}|)
\]
where \(\theta_\text{move} = \operatorname{atan2}(v_{0,y},v_{0,x})\) is the current movement angle and \(\theta_\text{target} = \operatorname{atan2}((y_1 - y_0) , (x_1 - x_0))\) the angle from the current location to the target location
Penalty calculation:
Goal: learn \(\alpha\) such that \(t_\text{approx} = t_\text{simple} + \alpha \times p_i \approx t_\text{ws}\)
Generate training data:
- 1.000.000 random combinations of current location \((x_0, y_0)\) and target location \((x_1, y_1)\) within the pitch dimensions and current velocity \((v_{x,0}, v_{y,0})\)
- Calculate for each sample:
- \(t_\text{ws}\): by grid search using Wu and Swartz (2024) algorithm as described
- \(t_\text{simple}, p_1, p_2\): analytically as described
Train model: linear regression without intercept (in case of no penalty, i.e. 0 velocity or no angular mismatch, \(t_\text{ws} \approx t_\text{simple}\), as running in straight line to target is then optimal)
where \(\beta_1\) and \(\beta_2\) are coefficients estimated by minimizing the sum of squared residuals \(\sum_i^n \epsilon_i^2\)
- Resulting coefficients: \(\beta_1 = 0.1328\), \(\beta_2 = 0.1986\)
Evaluation:
Generate 300.000 test data (same method as generating training data)
Calculate for each test sample \(t_\text{ws}\) and \(t_{\text{approx}_1} = t_\text{simple} + 0.1328 \cdot p_1\), \(t_{\text{approx}_2} = t_\text{simple} + 0.1986 \cdot p_2\)
Evaluate \(t_\text{ws} - t_{\text{approx}_1}\) (Angular) and \(t_\text{ws} - t_{\text{approx}_2}\) (Cosine) by using root mean squared error (RMSE), mean absolute error (MAE) and fraction of cases where absolute difference is below \(0.01\) (< 0.01) and \(0.05\) (< 0.05) seconds
Context: \(t_\text{ws}\) is on average 6.23 seconds for the test data
Evaluation table:
|
Metric
|
Angular
|
Cosine
|
|
RMSE
|
0.2480
|
0.1189
|
|
MAE
|
0.1906
|
0.0678
|
|
< 0.01
|
0.6183
|
0.7016
|
|
< 0.05
|
0.6875
|
0.9004
|
Conclusion:
- Cosine difference penalty better than (raw) angular mismatch penalty
- With the cosine difference penalty we can approximate \(t_\text{ws}\) very well in an efficient way