Research aimTo() mechanics — gun turn limits and API #149
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Question
How does gun turning work in Tank Royale? What is the max gun turn rate per tick? Is it affected by body turn? What API call sets the gun turn? Does an
aimTo()-like helper already exist in the bot API or in any existing bot, or must we write one? This determines the aimTo() function contract.Parent map: #147
Research Findings: Gun Turn Mechanics
Max Gun Turn Rate
20.0 degrees/tick (
MAX_GUN_TURN_RATEconstant intankroyale_botapi/constants.nim)API Call to Set Gun Turn
setGunTurnRate(desiredDelta.clamp(-20.0, 20.0))Gun Turn Independence vs Body Turn
Gun turn is affected by body turn via an opt-in adjustment flag.
Two separate control mechanisms:
Raw gun turn: Independent of body rotation
setGunTurnRate(rate)Adjusted gun turn (opt-in): Affects relative behavior
setAdjustGunForBodyTurn(true)inonRoundStarted()In classic Robocode terms: Tank Royale separates these concerns. You set the gun turn rate independently, then optionally enable adjustment that makes body turns affect absolute gun direction. OscillatorBot and QBot both use this.
Existing aimTo() Helper
Yes, one exists. In
PPO_Bot_garage/src/PPO_Bot/controllers.nim:Contracts to match:
Existing Usage Examples
Conclusion for aimTo()
The
aimToTick()helper already exists in PPO_Bot. Reuse it rather than rewrite. All three existing patterns (OscillatorBot direct, QBot with offset, PPO's aimToTick) converge on the same math:(targetBearing - gunDirection).clamp(±20). No surprises; the API is simple and uniform.