Luigi commited on
Commit
9374b54
ยท
1 Parent(s): 9fdd425

debug: Add critical logs to identify movement and production issues

Browse files

- Log unit target status every 2s (has target vs no target)
- Log production queue status every 3s (active vs idle)
- This will help identify if targets are being cleared or queues are disappearing

Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -669,6 +669,13 @@ class ConnectionManager:
669
  unit.attack_animation -= 1
670
 
671
  # Movement
 
 
 
 
 
 
 
672
  if unit.target:
673
  # Move towards target
674
  dx = unit.target.x - unit.position.x
@@ -684,9 +691,9 @@ class ConnectionManager:
684
 
685
  # Debug log for movement (only log occasionally to avoid spam)
686
  if self.game_state.tick % 20 == 0: # Every second (20 ticks/sec)
687
- print(f" ๐Ÿšถ Unit {unit.id} ({unit.type}) moving: ({old_x:.1f},{old_y:.1f}) -> ({unit.position.x:.1f},{unit.position.y:.1f}), dist={dist:.1f}")
688
  else:
689
- print(f" โœ… Unit {unit.id} ({unit.type}) reached destination ({unit.position.x:.1f},{unit.position.y:.1f})")
690
  unit.target = None
691
  unit.manual_order = False # Clear manual order flag when destination reached
692
  # If Harvester reached manual destination, resume AI
@@ -745,6 +752,14 @@ class ConnectionManager:
745
  if building.attack_animation > 0:
746
  building.attack_animation -= 1
747
 
 
 
 
 
 
 
 
 
748
  if building.production_queue:
749
  # RED ALERT: Check power status for this building's player
750
  _, _, power_status = self.game_state.calculate_power(building.player_id)
@@ -758,7 +773,7 @@ class ConnectionManager:
758
 
759
  # Debug log every 2 seconds (40 ticks at 20Hz)
760
  if self.game_state.tick % 40 == 0:
761
- print(f" ๐Ÿญ Building {building.id} ({building.type}) producing: {building.production_queue[0]} - progress: {building.production_progress:.2%}")
762
 
763
  if building.production_progress >= 1.0:
764
  # Complete production
 
669
  unit.attack_animation -= 1
670
 
671
  # Movement
672
+ # DEBUG: Log unit target status for player units
673
+ if unit.player_id == 0 and self.game_state.tick % 40 == 0: # Every 2 seconds
674
+ if unit.target:
675
+ print(f" ๐ŸŽฏ Unit {unit.id[:8]} ({unit.type}) HAS target: ({unit.target.x:.1f}, {unit.target.y:.1f}), pos: ({unit.position.x:.1f}, {unit.position.y:.1f})")
676
+ else:
677
+ print(f" โŒ Unit {unit.id[:8]} ({unit.type}) NO target, pos: ({unit.position.x:.1f}, {unit.position.y:.1f})")
678
+
679
  if unit.target:
680
  # Move towards target
681
  dx = unit.target.x - unit.position.x
 
691
 
692
  # Debug log for movement (only log occasionally to avoid spam)
693
  if self.game_state.tick % 20 == 0: # Every second (20 ticks/sec)
694
+ print(f" ๐Ÿšถ Unit {unit.id[:8]} ({unit.type}) moving: ({old_x:.1f},{old_y:.1f}) -> ({unit.position.x:.1f},{unit.position.y:.1f}), dist={dist:.1f}")
695
  else:
696
+ print(f" โœ… Unit {unit.id[:8]} ({unit.type}) reached destination ({unit.position.x:.1f},{unit.position.y:.1f})")
697
  unit.target = None
698
  unit.manual_order = False # Clear manual order flag when destination reached
699
  # If Harvester reached manual destination, resume AI
 
752
  if building.attack_animation > 0:
753
  building.attack_animation -= 1
754
 
755
+ # DEBUG: Log production queue status
756
+ if building.player_id == 0 and building.type in [BuildingType.BARRACKS, BuildingType.WAR_FACTORY]:
757
+ if self.game_state.tick % 60 == 0: # Every 3 seconds
758
+ if building.production_queue:
759
+ print(f" ๐Ÿ“‹ Building {building.id[:8]} ({building.type}) queue: {building.production_queue}, progress: {building.production_progress:.2%}")
760
+ else:
761
+ print(f" ๐Ÿ’ค Building {building.id[:8]} ({building.type}) IDLE (no queue)")
762
+
763
  if building.production_queue:
764
  # RED ALERT: Check power status for this building's player
765
  _, _, power_status = self.game_state.calculate_power(building.player_id)
 
773
 
774
  # Debug log every 2 seconds (40 ticks at 20Hz)
775
  if self.game_state.tick % 40 == 0:
776
+ print(f" ๐Ÿญ Building {building.id[:8]} ({building.type}) producing: {building.production_queue[0]} - progress: {building.production_progress:.2%}")
777
 
778
  if building.production_progress >= 1.0:
779
  # Complete production