feat: 인벤토리 캐시 및 JSON 인코더 추가
- 인벤토리 캐시 기능을 추가하여, RCON으로 인벤토리를 읽지 못할 경우 이전에 성공적으로 읽은 데이터를 활용 - Lua에서 JSON 인코딩을 위한 간단한 함수 추가, 일부 Factorio 버전에서 `game.table_to_json`이 없을 경우 대체 - `README.md`에 인벤토리 캐시 및 JSON 인코더 사용에 대한 설명 추가 - `scan_resources()`와 `mine_resource`의 반경을 확장하여 자원 탐색 실패를 줄임
This commit is contained in:
14
main.py
14
main.py
@@ -41,11 +41,11 @@ if p then
|
||||
rcon.print(p.name .. " @ " .. string.format("%.0f, %.0f", p.position.x, p.position.y))
|
||||
end
|
||||
""")
|
||||
print(f"[초기화] ✅ 플레이어 발견: {info}")
|
||||
print(f"[초기화] OK 플레이어 발견: {info}")
|
||||
return True
|
||||
|
||||
if attempt == 0:
|
||||
print("[초기화] ⚠️ 접속한 플레이어가 없습니다!")
|
||||
print("[초기화] WARN 접속한 플레이어가 없습니다!")
|
||||
print("[초기화] 팩토리오 클라이언트로 이 서버에 접속하세요.")
|
||||
print(f"[초기화] 서버 주소: {RCON_HOST}")
|
||||
print(f"[초기화] 대기 중... (최대 30초)")
|
||||
@@ -86,7 +86,7 @@ def run():
|
||||
|
||||
# ── 압축 레벨 자동 선택 ──
|
||||
if entity_count < COMPRESS_THRESHOLD:
|
||||
print("[상태] 초반 모드 — 상세 상태 수집")
|
||||
print("[상태] 초반 모드 - 상세 상태 수집")
|
||||
state = reader.get_full_state()
|
||||
summary = reader.summarize_for_ai(state)
|
||||
entity_count = sum(
|
||||
@@ -94,10 +94,10 @@ def run():
|
||||
if isinstance(v, int)
|
||||
)
|
||||
elif entity_count < 200:
|
||||
print(f"[상태] 중반 모드 — 구역 압축 (건물 {entity_count}개)")
|
||||
print(f"[상태] 중반 모드 - 구역 압축 (건물 {entity_count}개)")
|
||||
summary = compressor.get_compressed_state(detail_level=1)
|
||||
else:
|
||||
print(f"[상태] 후반 모드 — 글로벌 압축 (건물 {entity_count}개)")
|
||||
print(f"[상태] 후반 모드 - 글로벌 압축 (건물 {entity_count}개)")
|
||||
summary = compressor.get_compressed_state(detail_level=0)
|
||||
|
||||
global_info = compressor._get_global_summary()
|
||||
@@ -121,13 +121,13 @@ def run():
|
||||
print(f" params: {json.dumps(action.get('params',{}), ensure_ascii=False)}")
|
||||
|
||||
success, message = executor.execute(action)
|
||||
status = "✅" if success else "❌"
|
||||
status = "OK" if success else "FAIL"
|
||||
print(f" 결과: {status} {message}")
|
||||
|
||||
planner.record_feedback(action, success, message)
|
||||
|
||||
if not success:
|
||||
print(" → 실패. 재계획 요청")
|
||||
print(" -> 실패. 재계획 요청")
|
||||
queue.clear()
|
||||
|
||||
_log(total_actions, action, success, message)
|
||||
|
||||
Reference in New Issue
Block a user