Commit Graph

4 Commits

Author SHA1 Message Date
ydy0615 b038e5ac29 refactor(game): add Map.closest and improve flag assignment logic
- Introduced `Map.closest` to encapsulate nearest‑position search and replaced duplicated distance loops in flag targeting.
- Updated flag assignment to consider enemy players carrying flags and to use the new helper for both ally and enemy flag selection.
- Cleaned up unused imports and renamed `mypolicy` to `mypolicy.py` for clarity.
- Adjusted frontend `game_config.json` to use new team identifiers, increase players to 3, raise flag count to 9, and enable random flag placement.
2025-12-27 22:10:46 +08:00
ydy0615 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
ydy0615 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
ydy0615 86ccecc939 feat(ctf): add Chinese README and initial Python policy implementation
Add a comprehensive Chinese README (README‑cn.md) that explains the Capture‑the‑Flag game rules, setup instructions, and participant tasks.
Introduce a new backend script (backend/mypolicy.py) providing a basic world model, start_game, and plan_next_actions functions with simple flag‑assignment logic, serving as a starter implementation for the CTF challenge. This documentation and starter code help participants understand and begin developing their own algorithms.
2025-12-27 16:06:21 +08:00