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

+19 -6
View File
@@ -42,13 +42,13 @@ class StraferTest(unittest.TestCase):
return out
def test_holds_within_range_without_fakes(self):
s = preset(3, fake=0, strafe_min=250, strafe_max=600)
s = preset(3, fake=0, strafe_min=250, strafe_max=600, lane=0)
ch = self.changes(s, 300)
gaps = [b[0] - a[0] for a, b in zip(ch, ch[1:])]
self.assertTrue(all(245 <= g <= 610 for g in gaps), (min(gaps), max(gaps)))
def test_fake_taps_are_short_and_return(self):
s = preset(5, fake=100, strafe_min=300, strafe_max=300)
s = preset(5, fake=100, strafe_min=300, strafe_max=300, lane=0)
ch = self.changes(s, 200)
gaps = [b[0] - a[0] for a, b in zip(ch, ch[1:])]
# always faking: alternating short tap (60-120) and full hold (300), direction never really changes
@@ -57,7 +57,7 @@ class StraferTest(unittest.TestCase):
self.assertTrue(all(60 <= g <= 125 for g in short))
def test_fake_fraction_matches_setting(self):
s = preset(3, fake=30, strafe_min=300, strafe_max=300)
s = preset(3, fake=30, strafe_min=300, strafe_max=300, lane=0)
st, now, fakes, decisions = Strafer(random.Random(7)), 0, 0, 0
st.step(0, s)
while decisions < 2000:
@@ -70,6 +70,19 @@ class StraferTest(unittest.TestCase):
self.assertAlmostEqual(fakes / decisions, 0.30, delta=0.04)
def test_lane_stops_circling(self):
# always faking = always drifting the same way; the lane must turn it back
s = preset(5, fake=100, strafe_min=300, strafe_max=300, lane=300, speed=100)
lane_ms = 300 / 320.0 * 1000
st, now, drift = Strafer(random.Random(3)), 0, 0
d = st.step(0, s)
for _ in range(20000):
now += 25
drift += d * 25
self.assertLessEqual(abs(drift), lane_ms + 50)
d = st.step(now, s)
class Range(unittest.TestCase):
def test_plain(self):
self.assertEqual(wanted_range(preset(1), 100, 100), 450)
@@ -251,14 +264,14 @@ class Commands(unittest.TestCase):
class Prompts(unittest.TestCase):
def test_enter_keeps_everything(self):
old = {"aim": 2, "move": 4, "details": {"fake": 70}}
new = setup.prompt_setup(old, feeder("", "", "", "", "", "", "", "", ""), lambda *_: None)
new = setup.prompt_setup(old, feeder("", "", "", "", "", "", "", "", "", ""), lambda *_: None)
self.assertEqual(new, old)
def test_poor_aim_best_movement_custom(self):
new = setup.prompt_setup({"aim": 3, "move": 3, "details": {}},
feeder("1", "5", "y", "", "300", "60", "", "n", "90"), lambda *_: None)
feeder("1", "5", "y", "", "300", "60", "", "n", "90", "250"), lambda *_: None)
self.assertEqual(new, {"aim": 1, "move": 5,
"details": {"strafe_max": 300, "fake": 60, "range_play": 0, "speed": 90}})
"details": {"strafe_max": 300, "fake": 60, "range_play": 0, "speed": 90, "lane": 250}})
# only values that differ from the movement preset are stored as overrides
def test_no_details_clears_them(self):