Commit Graph

2 Commits

Author SHA1 Message Date
033979c663 feat: enhance AI planning logic and add unit tests for Map class
- Modified plan_next_actions in server.py to remove selected positions from regard_list, preventing reuse in subsequent planning steps for better AI decision-making
- Added comprehensive unit tests in test_map.py for enemy_to_walls and choose_enemy functions to ensure correct behavior and distance calculations in the game map
2025-12-28 12:32:53 +08:00
c046cfab54 feat(backend): add Map class with BFS pathfinding and faster updates
- Reduce `GameMap` update interval from 1000 ms to 10 ms for more responsive gameplay.
- Introduce thread lock, update thresholds, and player‑to‑flag tracking variables for safer concurrent access.
- Add `my_side_is_left` flag to determine team orientation.
- Implement new `Map` class:
  * Builds a grid representation of the world, marking walls, enemy flag carriers, and allies.
  * Generates adjacency lists (`edge`) respecting safe‑zone rules.
  * Provides `guideance` method that runs a BFS (unit‑weight Dijkstra) to compute the shortest path and returns the first movement direction via `world.get_direction`.
- Import `collections` for efficient deque usage.
- Include compiled `.pyc` for the new module.

These changes enable the policy to make quick, informed movement decisions based on real‑time map analysis.
2025-12-27 18:10:12 +08:00