#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Diagnostic ciblé P1 v0.15.2 : POURQUOI le téléport de renfort ne part pas sur le seed 1794824738987 (repro /tmp/ls-repro3.log : ennemis posés au sol au même étage que le joueur (y=26100), 30 « aucun chemin », 0 téléport). Rejoue la séquence exacte du bloc téléport (Behaviour.update) : 1. cellule du joueur via resolveNavCell((100, 26100)) — liens ? 2. BFS ennemi -> joueur (pourquoi « aucun chemin ») 3. findConnectedNavPointNear(playerPos, enemyPos) — le port fidèle : scan des cellules liées à 1000-3000 px du joueur, >= 600 px de l'ennemi, BFS-connectées au joueur """ import os import sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from navmesh_connectivity import load_segments, generate_map, NavMeshSim SEED = 1794824738987 PLAYER = (100.0, 26100.0) # ciblePos des logs de la repro ENEMIES = [(1948.0, 26100.0), (2052.0, 26100.0), (1707.0, 26057.0)] def resolve_nav_cell(sim, x, y): np_ = sim.get_nav_point(x, y) if np_ is not None and np_.links: return np_ i = int(round(x / 100.0)) j = int(round(y / 100.0)) + 1 for d in (-1, 1): ni = i + d if 0 <= ni < sim.W and 0 <= j < sim.H and sim.nav[ni][j].links: return sim.nav[ni][j] return np_ def main(): segs = load_segments() solid, _s, _g = generate_map(SEED, segs) sim = NavMeshSim(solid) sim.init((20.0, 20.0)) px, py = PLAYER pi, pj = int(round(px / 100.0)), int(round(py / 100.0)) + 1 print("cellule brute du joueur : (%d,%d)" % (pi, pj)) cell = sim.nav[pi][pj] print(" liens=%d type=%s" % (len(cell.links), cell.type)) pcell = resolve_nav_cell(sim, px, py) if pcell is None: print(" resolveNavCell -> NULL (hors grille)") else: print(" resolveNavCell -> (%d,%d) liens=%d" % (pcell.x // 100, pcell.y // 100, len(pcell.links))) for ex, ey in ENEMIES: ecell = resolve_nav_cell(sim, ex, ey) if ecell is None: print("\nennemi (%.0f,%.0f) : cellule NULL" % (ex, ey)) continue path = sim.get_path(ecell, pcell) if pcell else [] print("\nennemi (%.0f,%.0f) cellule (%d,%d) liens=%d -> chemin vers " "joueur : %s" % (ex, ey, ecell.x // 100, ecell.y // 100, len(ecell.links), "%d pas" % len(path) if path else "AUCUN")) if not path and pcell is not None: reach = sim.reachable(ecell) print(" composante ennemie : %d cellules ; joueur dedans : %s" % (len(reach), pcell in reach)) preach = sim.reachable(pcell) print(" composante joueur : %d cellules" % len(preach)) # findConnectedNavPointNear : candidats connectés AU JOUEUR best = None best_d = None for i in range(sim.W): for j in range(sim.H): n = sim.nav[i][j] if not n.links: continue dx = ((i * 100 - px) ** 2 + (j * 100 - py) ** 2) ** 0.5 if dx < 1000 or dx > 3000: continue de = ((i * 100 - ex) ** 2 + (j * 100 - ey) ** 2) ** 0.5 if de < 600: continue if n in preach: # connecté au joueur if best is None or de < best_d: best, best_d = n, de if best is not None: print(" => findConnectedNavPointNear : cellule (%d,%d) à " "%.0f px de l'ennemi — TÉLÉPORT POSSIBLE" % (best.x // 100, best.y // 100, best_d)) else: print(" => AUCUN candidat connecté au joueur 1000-3000 px " "— téléport IMPOSSIBLE (joueur isolé dans le graphe)") return 0 if __name__ == "__main__": sys.exit(main())