diff --git a/engine/world.py b/engine/world.py index c1358ca..df88459 100644 --- a/engine/world.py +++ b/engine/world.py @@ -95,7 +95,8 @@ def nearby_agents(agent_id: str, x: int, y: int, radius: float = HEARING_DISTANC c.row_factory = sqlite3.Row try: rows = c.execute( - "SELECT id,name,x,y,energy FROM agents WHERE id!=? AND alive=1", (agent_id,) + "SELECT id,name,personality,x,y,energy FROM agents " + "WHERE id!=? AND alive=1", (agent_id,) ).fetchall() out = [] for r in rows: @@ -103,6 +104,12 @@ def nearby_agents(agent_id: str, x: int, y: int, radius: float = HEARING_DISTANC if d <= radius: d2 = dict(r) d2["distance"] = d + # personality is stored as a JSON string; parse so callers + # get a real list (matches agents_mod.get). + try: + d2["personality"] = json.loads(d2.get("personality") or "[]") + except Exception: + d2["personality"] = [] out.append(d2) return out finally: diff --git a/server.py b/server.py index eb441a8..6437784 100644 --- a/server.py +++ b/server.py @@ -164,8 +164,10 @@ async def ws(ws: WebSocket): try: msg = await asyncio.to_thread(queue.get, timeout=30.0) await ws.send_json(msg) + except WebSocketDisconnect: + break except Exception: - # heartbeat - await ws.send_json({"type": "ping", "ts": time.time()}) + # client went away — stop sending + break except WebSocketDisconnect: pass