lgbot: auto recording while two humans fight (lgbot_record 2 / QL_RECORD), analyzer pairs any opponents
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
3535940331
commit
acf625d72b
8 files changed
+133
-51
No files matched your search
@@ -169,6 +169,35 @@ class Tick(unittest.TestCase):
|
||||
self.assertEqual(self.w.cvars["lgbot_record"], "0")
|
||||
self.assertIsNone(self.plugin.rec)
|
||||
|
||||
def test_auto_records_only_two_humans_fighting(self):
|
||||
import tempfile
|
||||
path = os.path.join(tempfile.mkdtemp(), "rec.csv")
|
||||
self.mod.REC_FILE = path
|
||||
self.w.cvars["lgbot_record"] = "2"
|
||||
self.run_frames(40) # one human vs the bot: not recorded
|
||||
self.assertFalse(os.path.exists(path))
|
||||
h2 = FakePlayer(2, "other", HUMAN_ID + 1, (450, 300, 0))
|
||||
self.w.players.append(h2)
|
||||
self.run_frames(40)
|
||||
h2.pos = [5000, 0, 0] # walks away: stops writing
|
||||
self.run_frames(5)
|
||||
with open(path) as f:
|
||||
before = f.read()
|
||||
self.run_frames(40)
|
||||
with open(path) as f:
|
||||
after = f.read()
|
||||
self.assertEqual(before, after)
|
||||
self.assertIn(",h2,", before)
|
||||
self.assertNotIn(str(HUMAN_ID), before)
|
||||
self.plugin.stop_recording()
|
||||
|
||||
def test_humans_fighting(self):
|
||||
f = self.mod.humans_fighting
|
||||
self.assertTrue(f([(0, 0, 0), (900, 0, 0)]))
|
||||
self.assertFalse(f([(0, 0, 0), (1200, 0, 0)]))
|
||||
self.assertFalse(f([(0, 0, 0), (100, 0, 400)]))
|
||||
self.assertFalse(f([(0, 0, 0)]))
|
||||
|
||||
def test_no_target_means_no_steering(self):
|
||||
self.human.team = "spectator"
|
||||
self.run_frames(40)
|
||||
|
||||
Reference in new issue
Block a user