Commit Graph

5 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
5e76bb2452 feat(ai): add Map class for pathfinding and speed up world updates
- Remove unused `random` import and introduce `collections` for BFS queue.
- Decrease `GameMap` update interval from 1000 ms to 1 ms and lower `update_threshold` from 100 to 1 for near‑real‑time world state.
- Add thread‑safe lock, timestamp tracking, and rename `player_to_flag_assignments` to `player_to_flag_assign`.
- Introduce `my_side_is_left` flag to differentiate safe‑zone logic.
- Implement new `Map` class:
  * Stores grid, edges, and safe‑zone status.
  * Updates grid with walls, allies, enemies, and safe‑zone handling.
  * Computes adjacency edges respecting obstacles.
  * Provides `guideance` (BFS) to obtain the first movement direction towards a target.
- Overall refactor improves AI flag‑picking speed and decision accuracy.
2025-12-28 11:38:50 +08:00
bcca96e73f refactor(server): tighten flag thresholds, add movement log
Adjusted range checks for flag handling:
- Changed `lentime<=5` to `lentime<6`.
- Updated `lentime<=10` to `lentime<12`.
- Modified `lentime<8` to `lentime<6`.

These tweaks refine the decision logic for flag acquisition, ensuring more consistent behavior at boundary values.

Added a debug print statement to log each player's current position and target destination, aiding in troubleshooting movement decisions.
2025-12-28 10:08:09 +08:00
e84aa30202 feat: refine map update logic and add side‑aware path helpers
- Decrease `GameMap` update interval from 10 ms to 1 ms and lower `update_threshold` to 1 for more responsive state syncing.
- Remove unused `random` import.
- Adjust safe‑zone detection to offset player position based on team side.
- Restrict enemy marking to opponent side, preventing incorrect obstacle placement.
- Update edge generation logic to correctly handle safe‑zone and opponent cells.
- Add `closest` and `closest_in_range` helper methods that compute nearest positions while respecting team side boundaries.
- Introduce global `my_side_is_left` handling within `Map.update` for side‑dependent calculations.

These changes improve map accuracy, AI pathfinding, and overall game performance.
2025-12-28 09:48:31 +08:00
2593d31346 feat(ctf): add backend policy module with pathfinding logic
Introduce a new `CTF/backend/mypolicy` Python module that implements a comprehensive game policy for the capture‑the‑flag bot. The file defines a global world model, thread‑safe state handling, and a `Map` class that builds a grid representation of the game map, generates traversable edges, and provides BFS‑based `guideance` and `length` methods for pathfinding and distance calculation. This policy enables the bot to make informed movement decisions based on safe zones, walls, allies, and enemies. Additionally, macOS `.DS_Store` placeholder files were added to the repository.
2025-12-27 20:54:40 +08:00