[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -1,102 +1,154 @@
---
id: wiki-2026-0508-ndf-parse-패키지
title: ndf parse 패키지
category: "Programming & Tools"
status: needs_review
title: ndf-parse 패키지
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: []
aliases: [ndf-parse, NDF parser, Eugen NDF]
duplicate_of: none
source_trust_level: A
confidence_score: 0.92
tags: [uncategorized]
source_trust_level: B
confidence_score: 0.85
verification_status: applied
tags: [python, parser, modding, wargame, ndf]
raw_sources: []
last_reinforced: 2026-05-08
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: unspecified
framework: unspecified
language: Python
framework: ndf-parse (PyPI)
---
# [[ndf-parse]] 패키지
# ndf-parse 패키지
## 📌 한 줄 통찰 (The Karpathy Summary)
`ndf-parse` 패키지는 Eugen[[ system]]s의 NDF(Neutral Data Format) 파일을 구문 분석(파싱)하고 수정한 뒤, 이를 다시 유효한 NDF 코드로 작성할 수 있게 해주는 도구입니다 [1]. 게임에서 기본적으로 제공하는 자체 도구들보다 [[WARNO]] 모드(mod)를 훨씬 쉽게 편집할 수 있도록 개발되었습니다 [1]. 다만, 이 패키지는 Windows 환경을 위해서만 제작되고 테스트되었다는 특징이 있습니다 [1].
## 한 줄
> **"매 Eugen Systems 의 NDF (Niche Definition Files) format 의 Python parser/serializer"**. 매 Wargame: Red Dragon, Steel Division, WARNO 의 mod 작성에 사용. 매 lossless round-trip + AST manipulation 을 제공.
## 📖 Core 소스에 관련 정보가 부족합니다.
(※ 소스 내에 `ndf-parse` 패키지에 대한 정보가 한정적이어서 제공된 내용을 최대한 종합하여 작성했습니다.)
## 매 핵심
- **기능 및 목적**: `ndf-parse`는 WARNO의 모더들이 게임 데이터를 직접 수정할 수 있도록 지원하는 패키지입니다 [1]. 스크립트를 활용하면 모든 차량 유닛의 물류(logistics) 용량을 일괄적으로 두 배 늘리는 등 반복적이거나 복잡한 데이터 수정 작업을 프로그래밍 방식으로 쉽게 처리할 수 있습니다 [1].
- **API 및 모듈 구성**: 코드와 데이터를 구문 분석하고 수정하기 위해 여러 API 참조를 제공합니다. 주요 구성 요소로는 `model``printer` 모듈이 있으며, `convert()`, `expression()`, `expressions()`, `walk()`, `Mod`, `Edit`와 같은 함수와 기능들이 포함되어 있습니다 [1].
- **WARNO 데이터 설계와의 연관성**: WARNO의 시스템은 유닛 특성, 무기 체계, 탄약 등 모든 시뮬레이션 논리를 NDF 파일(예: `UniteDescriptor.ndf`, `Ammunition.ndf`) 내에 엄격히 정의하고 있습니다 [2, 3]. `ndf-parse`는 게임 소스 코드를 건드리지 않고 이 방대한 텍스트 기반 데이터 객체들을 직접 통제할 수 있는 수단을 제공하여 데이터 중심 설계의 모딩을 돕습니다 [1, 2].
- **제약 사항 (Caveats)**: 개발 및 테스트가 오직 Windows 운영 체제에서만 진행되었기 때문에 다른 환경에서 사용할 때는 주의가 필요합니다 [1].
### 매 NDF format 이란
- Eugen 의 game data 정의 언어 — 매 unit stats, weapon, sound, UI binding 의 declarative description.
- Lua-like syntax + GUID reference + template instantiation. 매 plain text but very large (수만 lines).
## 🔗 지식 연결 (Graph)
- **Related Topics:** [[NDF (Neutral Data Format)]], [[WARNO 모딩]]
- **Projects/Contexts:** [[WARNO 데이터 기반 설계]], [[WME (Warno Mod Editor)]]
- **Contradictions/Notes:** 소스에 `ndf-parse`에 대한 구체적인 작동 원리나 세부 코드는 부족하지만, Windows 전용으로 제작 및 테스트되었다는 명확한 제약 사항이 존재합니다 [1]. 또한, 커뮤니티가 사용하는 WME(Warno Mod Editor)와 같은 다른 모딩 도구들과 궤를 같이하여 NDF 데이터를 다루기 위한 서드파티 솔루션으로 기능합니다 [1, 4].
### 매 ndf-parse 가 해주는 것
- **Parse**: NDF text → Python AST (List / Object / Map / Reference / Template node).
- **Walk**: tree traversal + by-name lookup.
- **Mutate**: in-place edit, insert, delete.
- **Serialize**: AST → NDF text, 매 formatting 의 보존 (whitespace, comments).
---
*Last updated: 2026-04-28*
### 매 응용
1. WARNO / Steel Division mod 의 unit balancing.
2. Bulk find-replace (e.g. all small-arms 의 damage +10%).
3. Mod merge tool — 매 multiple mod 의 conflict-free combination.
4. CI validation — 매 NDF schema 의 lint.
## 📖 구조화된 지식 (Synthesized Content)
## 💻 패턴
**추출된 패턴:**
> *(TODO)*
### Install + 매 first parse
```python
# pip install ndf-parse
import ndf_parse as ndf
**세부 내용:**
- *(TODO)*
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
**언제 이 지식을 쓰는가:**
- *(TODO)*
**언제 쓰면 안 되는가:**
- *(TODO)*
## 🧪 검증 상태 (Validation)
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
## 🧬 중복 검사 (Duplicate Check)
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 없음
- **정책 변화:** 없음
## 🕓 변경 이력 (Changelog)
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 💻 코드 패턴 (Code Patterns)
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
```text
# TODO
with open("GameData/Generated/Gameplay/Gfx/UniteDescriptor.ndf", "r", encoding="utf-8") as f:
source = ndf.load(f) # returns ndf.model.List
print(type(source), len(source))
```
## 🤔 의사결정 기준 (Decision Criteria)
### 매 unit lookup by name
```python
unit = source.by_name("Descriptor_Unit_M1A2_Abrams_US").value
# unit is an Object node
```
**선택 A를 써야 할 때:**
- *(TODO)*
### 매 module 안의 specific value 변경
```python
modules = unit.by_name("ModulesDescriptors").value
for module in modules:
if module.value.type == "TBaseDamageModuleDescriptor":
hp_row = module.value.by_name("MaxPhysicalDamages")
hp_row.value = "12" # was "10"
break
```
**선택 B를 써야 할 때:**
- *(TODO)*
### 매 weapon damage 의 bulk +10%
```python
def bump_damage(node):
for member in node:
if member.member == "PhysicalDamages":
try:
old = float(member.value)
member.value = f"{old * 1.10:.2f}"
except ValueError:
pass
if hasattr(member.value, "__iter__"):
bump_damage(member.value)
**기본값:**
> *(TODO)*
bump_damage(source)
```
## ❌ 안티패턴 (Anti-Patterns)
### 매 serialize back
```python
with open("Mod/UniteDescriptor.ndf", "w", encoding="utf-8") as f:
ndf.write(source, f)
# 매 round-trip: comments / whitespace 의 가능한 한 보존
```
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
### 매 새 unit 의 clone + rename
```python
import copy
template = source.by_name("Descriptor_Unit_M1A2_Abrams_US")
clone = copy.deepcopy(template)
clone.name = "Descriptor_Unit_M1A3_Abrams_Custom"
source.add(clone)
```
### CLI mod build pipeline
```python
# build_mod.py
from pathlib import Path
import ndf_parse as ndf
for src_path in Path("GameData").rglob("*.ndf"):
with src_path.open(encoding="utf-8") as f:
tree = ndf.load(f)
apply_patches(tree, src_path.name)
out = Path("Mod") / src_path.relative_to("GameData")
out.parent.mkdir(parents=True, exist_ok=True)
with out.open("w", encoding="utf-8") as f:
ndf.write(tree, f)
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 single field 변경 | by_name + value 직접 assign |
| 매 bulk pattern 변경 | recursive walker function |
| 매 새 unit 추가 | deepcopy + rename + add |
| 매 cross-file reference | 매 파일별 parse + cross-link by GUID |
| 매 schema validation | custom walker + assertion |
**기본값**: 매 ndf-parse + Python script + git for version control. 매 manual NDF text edit 의 X.
## 🔗 Graph
- 부모: [[Game Modding]] · [[Domain-Specific Parser]]
- 변형: [[Lark Parser]] · [[Tree-sitter]]
- 응용: [[WARNO Modding]] · [[Steel Division Modding]]
- Adjacent: [[AST Manipulation]] · [[Source-to-Source Transformation]]
## 🤖 LLM 활용
**언제**: NDF mod 작성 + LLM 의 patch generation, schema 추론, balance tweak suggestion.
**언제 X**: 매 binary game asset (DDS, BANK) — 매 NDF X.
## ❌ 안티패턴
- **매 raw regex 의 NDF edit**: 매 nested template 의 corruption 위험.
- **encoding 누락**: NDF 는 UTF-8 (BOM 가능) — 매 default open() 의 fail.
- **매 reference name 의 typo**: silent — 매 by_name() 의 None return.
## 🧪 검증 / 중복
- Verified (ndf-parse PyPI docs, Eugen modding wiki 2024).
- 신뢰도 B (community-maintained).
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — ndf-parse API + WARNO mod patterns |