diff --git a/README.md b/README.md index 3494dfa..66cd9d4 100644 --- a/README.md +++ b/README.md @@ -114,3 +114,4 @@ planner.set_goal( - AI가 "move 먼저 → 작업" 패턴을 학습하도록 프롬프트가 설계되어 있습니다 - `agent_log.jsonl`에 모든 행동과 타임스탬프가 기록됩니다 - `mine_resource`에서 실패한 채굴 타일 제외(`exclude`)는 Lua와 Python 양쪽에서 정수 타일 좌표(`tx, ty`) 키로 통일해, 제외한 좌표가 반복 선택되지 않도록 합니다. +- 또한 채굴 시작(`mining_state`) 좌표는 정수 타일이 아니라, Lua가 찾은 실제 자원 엔티티의 `e.position`(정확 실수 좌표)을 사용해 “플레이어가 타일 위에 있는데도 즉시 채굴 감지 실패”를 줄입니다. diff --git a/__pycache__/action_executor.cpython-311.pyc b/__pycache__/action_executor.cpython-311.pyc index dc3d2d1..950cbd7 100644 Binary files a/__pycache__/action_executor.cpython-311.pyc and b/__pycache__/action_executor.cpython-311.pyc differ diff --git a/action_executor.py b/action_executor.py index 2525b80..946d75b 100644 --- a/action_executor.py +++ b/action_executor.py @@ -161,7 +161,9 @@ for _, e in ipairs(res) do local ty = math.floor(e.position.y + 0.5) local key = string.format("%d,%d", tx, ty) if not exclude[key] then - rcon.print(key) + -- mining_state는 타일 정수가 아니라, 엔티티의 "정확한 e.position"을 주는 게 안정적 + -- 반환 형식: "|" + rcon.print(string.format("%d,%d|%.3f,%.3f", tx, ty, e.position.x, e.position.y)) return end end @@ -179,8 +181,13 @@ rcon.print("ALL_EXCLUDED") return False, f"{ore} 근처 타일 {len(failed_positions)}개 모두 접근 불가 — 다른 위치로 이동 필요" try: - parts = find_result.strip().split(",") - ox, oy = int(parts[0]), int(parts[1]) + find_result = find_result.strip() + key_part, pos_part = find_result.split("|", 1) + key_xy = key_part.split(",") + ox, oy = int(key_xy[0]), int(key_xy[1]) # move 타겟(정수 타일) + + pos_xy = pos_part.split(",") + mine_x, mine_y = float(pos_xy[0]), float(pos_xy[1]) # mining 타겟(엔티티 정확 좌표) except: return False, f"좌표 파싱 실패: {find_result}" @@ -198,7 +205,7 @@ rcon.print("ALL_EXCLUDED") mined_this_tile = False for tick in range(300): # 최대 30초 - self.rcon.lua(P + f"p.mining_state = {{mining = true, position = {{{ox}, {oy}}}}}") + self.rcon.lua(P + f"p.mining_state = {{mining = true, position = {{{mine_x}, {mine_y}}}}}") time.sleep(0.1) if tick % 8 == 7: @@ -215,7 +222,8 @@ rcon.print("ALL_EXCLUDED") else: stall_count += 1 - if stall_count >= 2: + # 채굴은 "바로 아이템 카운트가 오르지" 않을 수 있어 너무 빨리 포기하지 않도록 완충 + if stall_count >= 5: break self.rcon.lua(P + "p.mining_state = {mining = false}")