lgbot: lane setting stops it circling you (max sideways drift before turning back)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
esefandClaude Opus 5.5 committed 2026-10-15 14:48:30 +03:00
1 parent 696d2f2dad
commit aa457014e6
5 files changed
+55 -24

No files matched your search

+23 -8
View File
@@ -14,15 +14,15 @@ RUN_SPEED = 320 # QL ground run speed, units/s
# In the air there is no friction, so no boost (vertical speed 0 = on the ground, near enough).
FRICTION_COMP = 1.3
KEYS = ["strafe_min", "strafe_max", "fake", "range", "range_play", "speed"]
KEYS = ["strafe_min", "strafe_max", "fake", "range", "range_play", "speed", "lane"]
LIMITS = {"strafe_min": (50, 2000), "strafe_max": (50, 2000), "fake": (0, 100),
"range": (150, 750), "range_play": (0, 1), "speed": (50, 100)}
"range": (150, 750), "range_play": (0, 1), "speed": (50, 100), "lane": (0, 2000)}
PRESETS = {
1: {"strafe_min": 600, "strafe_max": 1000, "fake": 0, "range": 450, "range_play": 0, "speed": 80},
2: {"strafe_min": 400, "strafe_max": 800, "fake": 10, "range": 450, "range_play": 0, "speed": 90},
3: {"strafe_min": 250, "strafe_max": 600, "fake": 25, "range": 400, "range_play": 1, "speed": 100},
4: {"strafe_min": 180, "strafe_max": 450, "fake": 35, "range": 380, "range_play": 1, "speed": 100},
5: {"strafe_min": 120, "strafe_max": 350, "fake": 50, "range": 350, "range_play": 1, "speed": 100},
1: {"strafe_min": 600, "strafe_max": 1000, "fake": 0, "range": 450, "range_play": 0, "speed": 80, "lane": 600},
2: {"strafe_min": 400, "strafe_max": 800, "fake": 10, "range": 450, "range_play": 0, "speed": 90, "lane": 500},
3: {"strafe_min": 250, "strafe_max": 600, "fake": 25, "range": 400, "range_play": 1, "speed": 100, "lane": 400},
4: {"strafe_min": 180, "strafe_max": 450, "fake": 35, "range": 380, "range_play": 1, "speed": 100, "lane": 350},
5: {"strafe_min": 120, "strafe_max": 350, "fake": 50, "range": 350, "range_play": 1, "speed": 100, "lane": 300},
}
PUSH_RANGE, BACKOFF_RANGE = 250, 700
BACKOFF_HEALTH, PUSH_LEAD = 60, 30
@@ -64,15 +64,30 @@ def resolve(move, overrides):
class Strafer:
"""Strafe direction over time: holds one side for strafe_min..strafe_max ms, then switches.
A fake is a 60-120 ms tap to the other side followed by a new hold on the original side."""
A fake is a 60-120 ms tap to the other side followed by a new hold on the original side.
Lane: strafing sideways to someone moves you around them, and fakes keep you going the same
way, so the net sideways drift is tracked and the bot turns back once it is more than `lane`
units off centre (0 = no limit). That keeps it doing ADAD in front of you instead of circling."""
def __init__(self, rng=random):
self.rng = rng
self.direction = 1
self.until = 0
self.faking = False
self.drift = 0 # signed ms of strafing, + = direction 1
self.last = None
def step(self, now_ms, s):
if self.last is not None:
self.drift += self.direction * (now_ms - self.last)
self.last = now_ms
if s["lane"]:
lane_ms = s["lane"] * 1000.0 / (RUN_SPEED * s["speed"] / 100.0)
if self.direction * self.drift >= lane_ms:
self.direction = -self.direction
self.faking = False
self.until = now_ms + self.rng.randint(s["strafe_min"], s["strafe_max"])
return self.direction
if now_ms >= self.until:
self.direction = -self.direction
if self.faking: