Repository navigation
Expand file tree
/
Copy pathdebug_test.py
More file actions
58 lines (45 loc) · 1.52 KB
/
Copy pathdebug_test.py
File metadata and controls
58 lines (45 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""
Test script to debug the AI player
"""
import os
import sys
import time
from dotenv import load_dotenv
# Add src directory to path
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
load_dotenv()
def test_timing():
"""Test the timing logic"""
print("Testing timing logic...")
decision_interval = 5.0
last_decision_time = None
for i in range(20):
current_time = time.time()
should_make_decision = last_decision_time is None or (current_time - last_decision_time) >= decision_interval
if should_make_decision:
print(f"Decision made at {i}: {current_time}")
last_decision_time = current_time
else:
remaining = decision_interval - (current_time - last_decision_time)
print(f"Frame {i}: {remaining:.2f}s until next decision")
time.sleep(0.5) # Simulate frame time
def test_input_handler():
"""Test the input handler"""
print("\nTesting input handler...")
from input_handler import InputHandler
handler = InputHandler()
handler.start()
print("Input handler started. Try typing 'start' and then 'q'")
# Wait for input
while not handler.should_quit:
if handler.ai_started:
print("✅ AI started!")
break
time.sleep(0.1)
handler.stop()
print("Input handler stopped.")
if __name__ == "__main__":
print("🔍 Debugging AI Player...")
test_timing()
test_input_handler()