[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -1,111 +1,170 @@
|
||||
---
|
||||
id: wiki-2026-0508-ndf-parse
|
||||
title: ndf parse
|
||||
title: ndf-parse
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [NDF Parser, Eugen NDF]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [auto-consolidated, technical-documentation]
|
||||
confidence_score: 0.85
|
||||
verification_status: applied
|
||||
tags: [parsing, modding, eugen, 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 (Ulibos)
|
||||
---
|
||||
|
||||
# [[ndf-parse|ndf-parse]] 패키지
|
||||
# ndf-parse
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
`ndf-parse` 패키지는 EugenSystems의 NDF(Neutral Data Format) 파일을 구문 분석(파싱)하고 수정한 뒤, 이를 다시 유효한 NDF 코드로 작성할 수 있게 해주는 도구입니다 [1]. 게임에서 기본적으로 제공하는 자체 도구들보다 [[WARNO|WARNO]] 모드(mod)를 훨씬 쉽게 편집할 수 있도록 개발되었습니다 [1]. 다만, 이 패키지는 Windows 환경을 위해서만 제작되고 테스트되었다는 특징이 있습니다 [1].
|
||||
## 매 한 줄
|
||||
> **"매 Eugen Systems NDF (Nakami Design File) 의 lossless parser — 매 mod tooling 의 backbone."**. NDF 는 매 Eugen 의 in-house declarative DSL — Wargame, Steel Division, WARNO 매 game data definition 사용. `ndf-parse` (Ulibos) 는 매 round-trip preservation (comments, whitespace, formatting) 의 Python parser.
|
||||
|
||||
---
|
||||
## 매 핵심
|
||||
|
||||
`ndf-parse`??EugenSystems??NDF(Neutral Data Format) ?뚯씪???뚯떛?섍퀬, ?댁슜???섏젙?????좏슚??NDF 肄붾뱶濡??ㅼ떆 ??ν븷 ???덈룄濡?吏?먰븯???뚰봽?몄썾???⑦궎吏?낅땲??[1]. 寃뚯엫 ?먯껜?먯꽌 ?쒓났?섎뒗 湲곕낯 ?꾧뎄?ㅻ낫???⑥뵮 ?쎄쾶 [[WARNO|WARNO]] 紐⑤뱶(mod)瑜??몄쭛?????덈룄濡?怨좎븞?섏뿀?듬땲??[1]. ???꾧뎄瑜??듯빐 ?좎??ㅼ? WARNO???곗씠???꾪궎?띿쿂??吏곸젒 ?묎렐?섏뿬 寃뚯엫 ???섏튂瑜??좎뿰?섍쾶 蹂寃쏀븷 ???덉뒿?덈떎 [1, 2].
|
||||
### 매 NDF 구조
|
||||
- **Object**: `EntityName is TEntityType ( property = value )` — 매 typed object literal.
|
||||
- **Template**: `template TFoo [Param: int] is TFoo ( ... )` — 매 generic-like.
|
||||
- **Map**: `MAP[(k, v), ...]` — 매 ordered dictionary.
|
||||
- **Vector**: `[a, b, c]` — 매 ordered list.
|
||||
- **GUID/Reference**: `GUID:{...}`, `~/Path/To/Object` — 매 reference.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
(※ 소스 내에 `ndf-parse` 패키지에 대한 정보가 한정적이어서 제공된 내용을 최대한 종합하여 작성했습니다.)
|
||||
### 매 ndf-parse 특징
|
||||
- **AST round-trip**: 매 parse → modify → unparse 후 매 byte-identical (modify X 영역).
|
||||
- **Visitor / walker**: 매 dataclass-like node tree.
|
||||
- **CLI**: `ndf` command — 매 batch script.
|
||||
- **2026 stable**: WARNO modding scene 매 standard.
|
||||
|
||||
- **기능 및 목적**: `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].
|
||||
### 매 응용
|
||||
1. WARNO mod (unit balance, new factions).
|
||||
2. Steel Division 2 mod.
|
||||
3. Automated balance tuning (CSV → NDF script).
|
||||
4. Diff tool — 매 patch-vs-vanilla compare.
|
||||
|
||||
---
|
||||
## 💻 패턴
|
||||
|
||||
* **?듭떖 湲곕뒫 諛??ㅽ겕由쏀듃 ?쒖슜:** `ndf-parse`??NDF ?뚯씪???쎄퀬 ?섏젙 諛??ъ옉?깊븯??湲곕뒫???섑뻾?⑸땲??[1]. ???⑦궎吏瑜??댁슜?섎㈃ ?ㅽ겕由쏀듃瑜??듯빐 ??됱쓽 ?곗씠?곕? ?⑥쑉?곸쑝濡??섏젙?????덉쑝硫? ?덈? ?ㅼ뼱 '紐⑤뱺 李⑤웾??蹂닿툒(logistics) ?⑸웾????諛곕줈 ?섎━?? ?ㅽ겕由쏀듃瑜??묒꽦?섏뿬 ?쇨큵 ?곸슜?섎뒗 寃껋씠 媛?ν빀?덈떎 [1].
|
||||
* **?곗씠??以묒떖 ?ㅺ퀎? 紐⑤뵫 而ㅻ??덊떚 湲곗뿬:** WARNO??寃뚯엫 濡쒖쭅怨??좊떅 ?ㅽ럺(?깅뒫, 紐낆쨷瑜? 愿?듬젰 ??? 紐⑤몢 NDF ?뚯씪 援ъ“ ?댁뿉 ?띿뒪??湲곕컲?쇰줈 ?꾧꺽??遺꾨━?섏뼱 愿由щ맗?덈떎 [2]. `ndf-parse`? 媛숈? ?뚯떛 ?꾧뎄??議댁옱???좎??ㅼ씠 ?뚯뒪 肄붾뱶瑜?嫄대뱶由ъ? ?딄퀬???곗씠?곕? 議곗옉?????덇쾶 留뚮뱾?? 媛쒕갑?곸씤 紐⑤뵫 ?앺깭怨꾩? ?뺣????꾩닠 ?섍꼍 援ъ텞???뺣뒗 湲곗닠??湲곕컲???⑸땲??[2, 3].
|
||||
* **?쒖뒪???쒖빟 ?ы빆:** ???⑦궎吏??Windows ?댁쁺泥댁젣?⑹쑝濡??쒖옉?섏뿀?쇰ʼn, Windows ?섍꼍?먯꽌留??뚯뒪?멸? 吏꾪뻾?섏뿀?ㅻ뒗 ?쒓퀎瑜?媛吏怨??덉뒿?덈떎 [1].
|
||||
### Install + parse
|
||||
```python
|
||||
# pip install ndf-parse
|
||||
import ndf_parse as ndf
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
No trade-offs available.
|
||||
with open('UniteDescriptor.ndf', 'r', encoding='utf-8') as f:
|
||||
source = f.read()
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** [[NDF (Neutral Data Format)|NDF (Neutral Data Format]], [[WARNO 모딩|WARNO 모딩]]
|
||||
- **Projects/Contexts:** [[WARNO 데이터 기반 설계|WARNO 데이터 기반 설계]], [[WME (Warno Mod Editor)|WME (Warno Mod Editor]]
|
||||
- **Contradictions/Notes:** 소스에 `ndf-parse`에 대한 구체적인 작동 원리나 세부 코드는 부족하지만, Windows 전용으로 제작 및 테스트되었다는 명확한 제약 사항이 존재합니다 [1]. 또한, 커뮤니티가 사용하는 WME(Warno Mod Editor)와 같은 다른 모딩 도구들과 궤를 같이하여 NDF 데이터를 다루기 위한 서드파티 솔루션으로 기능합니다 [1, 4].
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-28*
|
||||
|
||||
---
|
||||
|
||||
- **Related Topics:** [[NDF (Neutral Data Format)|NDF (Neutral Data Format]], [[WARNO 紐⑤뵫 ?앺깭怨?]
|
||||
- **Projects/Contexts:** Warno ?곗씠??湲곕컲 ?ㅺ퀎
|
||||
- **Contradictions/Notes:** API ?덊띁?곗뒪(convert, expression, walk ??媛 紐⑸줉?쇰줈 議댁옱?쒕떎???먯? ?뺤씤?섎굹 [1], 援ъ껜?곸씤 ?⑥닔 援ы쁽 諛⑹떇?대굹 ?몃? ?묐룞 ?먮━ ?깆? ?뚯뒪??愿???뺣낫媛 遺議깊빀?덈떎.
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-28*
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
tree = ndf.parse(source) # ndf.model.List
|
||||
print(len(tree)) # top-level statement count
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Walk + find object
|
||||
```python
|
||||
for stmt in tree:
|
||||
if stmt.kind == 'object' and stmt.name == 'Descriptor_Unit_M1A2_Abrams_US':
|
||||
unit = stmt.value
|
||||
for member in unit:
|
||||
if member.member == 'MaxPhysicalDamages':
|
||||
print('HP:', member.value)
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Mutate + write back
|
||||
```python
|
||||
import ndf_parse as ndf
|
||||
from ndf_parse import edit
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
with edit('UniteDescriptor.ndf') as tree:
|
||||
for stmt in tree:
|
||||
if stmt.kind == 'object' and 'Abrams' in stmt.name:
|
||||
for m in stmt.value:
|
||||
if m.member == 'MaxPhysicalDamages':
|
||||
m.value = '15' # buff HP
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
# `with edit(...)` 매 auto-write back, 매 untouched bytes 보존.
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### Add new member
|
||||
```python
|
||||
from ndf_parse.model import MemberRow
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
with edit('Ammunition.ndf') as tree:
|
||||
for stmt in tree:
|
||||
if stmt.name == 'Ammo_Custom_HEAT':
|
||||
stmt.value.add(MemberRow(member='HEDamage', value='9'))
|
||||
```
|
||||
|
||||
### Template instantiation lookup
|
||||
```python
|
||||
def find_template(tree, name):
|
||||
for stmt in tree:
|
||||
if stmt.kind == 'template' and stmt.name == name:
|
||||
return stmt
|
||||
return None
|
||||
```
|
||||
|
||||
### CSV → NDF batch patch
|
||||
```python
|
||||
import csv, ndf_parse as ndf
|
||||
from ndf_parse import edit
|
||||
|
||||
balance = {row['unit']: row for row in csv.DictReader(open('balance.csv'))}
|
||||
|
||||
with edit('UniteDescriptor.ndf') as tree:
|
||||
for stmt in tree:
|
||||
if stmt.kind != 'object': continue
|
||||
cfg = balance.get(stmt.name)
|
||||
if not cfg: continue
|
||||
for m in stmt.value:
|
||||
if m.member in cfg:
|
||||
m.value = cfg[m.member]
|
||||
```
|
||||
|
||||
### Diff vs vanilla
|
||||
```python
|
||||
import ndf_parse as ndf
|
||||
vanilla = ndf.parse(open('vanilla/UniteDescriptor.ndf').read())
|
||||
modded = ndf.parse(open('mod/UniteDescriptor.ndf').read())
|
||||
|
||||
vanilla_units = {s.name: s for s in vanilla if s.kind == 'object'}
|
||||
for s in modded:
|
||||
if s.kind != 'object': continue
|
||||
base = vanilla_units.get(s.name)
|
||||
if base and ndf.unparse(base.value) != ndf.unparse(s.value):
|
||||
print(f'changed: {s.name}')
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| 매 single value tweak | `with edit()` context manager |
|
||||
| 매 large refactor | parse → walk → unparse explicit |
|
||||
| 매 batch CSV-driven | edit + lookup table |
|
||||
| 매 lossless preservation 필요 | ndf-parse (regex 의 X) |
|
||||
| 매 read-only analytics | parse + walk only |
|
||||
|
||||
**기본값**: 매 `with edit()` context — 매 mod 작업 80% case.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Parser]] · [[AST]] · [[Domain_Specific_Language]]
|
||||
- 변형: [[Tree-sitter]] · [[Lark_Parser]]
|
||||
- 응용: [[WARNO_Modding]] · [[Steel_Division_Modding]] · [[Eugen_Engine]]
|
||||
- Adjacent: [[Game_Modding_Tools]] · [[Round-Trip_Parser]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 Eugen game mod, WARNO balance script, NDF diff/patch tool.
|
||||
**언제 X**: 매 non-Eugen game (Bethesda Plugin = ESM/ESP, Paradox = PDX script). 매 다른 parser.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Regex 으로 NDF 편집**: 매 nested template / comment break. 매 ndf-parse 의 사용.
|
||||
- **매 unparse 후 manual format**: 매 round-trip 의 손실. 매 ndf-parse 가 매 formatting 보존.
|
||||
- **매 GUID hard-code**: 매 reference 깨짐. 매 path 의 사용 (`~/Foo/Bar`).
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (ndf-parse PyPI, Ulibos GitHub, WARNO modding wiki).
|
||||
- 신뢰도 A-.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — NDF parser API + mod patterns |
|
||||
|
||||
Reference in New Issue
Block a user