fix: 실패한 타일 제외

This commit is contained in:
21in7
2026-03-25 21:24:13 +09:00
parent c99ca1e43c
commit 9a2185ca4b
3 changed files with 14 additions and 5 deletions

View File

@@ -114,3 +114,4 @@ planner.set_goal(
- AI가 "move 먼저 → 작업" 패턴을 학습하도록 프롬프트가 설계되어 있습니다
- `agent_log.jsonl`에 모든 행동과 타임스탬프가 기록됩니다
- `mine_resource`에서 실패한 채굴 타일 제외(`exclude`)는 Lua와 Python 양쪽에서 정수 타일 좌표(`tx, ty`) 키로 통일해, 제외한 좌표가 반복 선택되지 않도록 합니다.
- 또한 채굴 시작(`mining_state`) 좌표는 정수 타일이 아니라, Lua가 찾은 실제 자원 엔티티의 `e.position`(정확 실수 좌표)을 사용해 “플레이어가 타일 위에 있는데도 즉시 채굴 감지 실패”를 줄입니다.

View File

@@ -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"을 주는 게 안정적
-- 반환 형식: "<tx,ty>|<ex,ey>"
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}")