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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ko">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>군집 무인기 자율 협력 시뮬레이터 데모</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { background:#fff; color:#1f2937; font-family:system-ui,-apple-system,"Apple SD Gothic Neo","Malgun Gothic",sans-serif; margin:0; padding:20px; }
|
| 9 |
+
* { box-sizing:border-box; }
|
| 10 |
+
.container { max-width:1150px; margin:0 auto; background:#fff; border-radius:12px; box-shadow:0 6px 20px rgba(0,0,0,.08); overflow:hidden; border:1px solid #e5e7eb; }
|
| 11 |
+
.header { background:linear-gradient(135deg,#1d4ed8,#312e81); padding:24px; }
|
| 12 |
+
.header h1 { margin:0; font-size:22px; color:#fff; }
|
| 13 |
+
.header p { margin:8px 0 0; font-size:14px; color:#dbeafe; line-height:1.6; }
|
| 14 |
+
.main-grid { display:grid; grid-template-columns:1fr; gap:24px; padding:24px; }
|
| 15 |
+
@media (min-width:1024px){ .main-grid{ grid-template-columns:1fr 2fr; } }
|
| 16 |
+
.control-panel { background:#f9fafb; padding:20px; border-radius:8px; border:1px solid #e5e7eb; align-self:start; }
|
| 17 |
+
.panel-title { font-size:17px; font-weight:700; color:#1d4ed8; margin:0 0 16px; border-bottom:1px solid #e5e7eb; padding-bottom:8px; }
|
| 18 |
+
.form-group { margin-bottom:18px; }
|
| 19 |
+
.form-group > label, .group-label { display:block; font-size:14px; font-weight:600; margin-bottom:8px; }
|
| 20 |
+
.flex-gap { display:flex; gap:10px; flex-wrap:wrap; }
|
| 21 |
+
.radio-label { display:flex; align-items:center; gap:6px; background:#fff; padding:7px 14px; border-radius:6px; border:1px solid #d1d5db; cursor:pointer; font-size:14px; }
|
| 22 |
+
.radio-label:has(input:checked) { border-color:#2563eb; background:#eff6ff; color:#1d4ed8; font-weight:600; }
|
| 23 |
+
.radio-label:has(input:disabled) { opacity:.45; cursor:not-allowed; }
|
| 24 |
+
.hint { font-size:12px; color:#6b7280; margin-top:6px; line-height:1.5; }
|
| 25 |
+
.btn { width:100%; background:#2563eb; color:#fff; font-weight:700; padding:12px; border:none; border-radius:8px; cursor:pointer; font-size:15px; }
|
| 26 |
+
.btn:hover { background:#1d4ed8; }
|
| 27 |
+
.params { margin-top:18px; font-size:12px; border-collapse:collapse; width:100%; background:#fff; }
|
| 28 |
+
.params td { border:1px solid #e5e7eb; padding:4px 8px; }
|
| 29 |
+
.params td:last-child { text-align:right; font-variant-numeric:tabular-nums; }
|
| 30 |
+
.params caption { text-align:left; font-weight:700; font-size:13px; margin-bottom:6px; color:#374151; }
|
| 31 |
+
.legend { margin-top:16px; font-size:13px; color:#4b5563; line-height:1.9; }
|
| 32 |
+
.dot { display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:6px; vertical-align:middle; }
|
| 33 |
+
.results-panel { padding:20px; border-radius:8px; border:1px solid #e5e7eb; background:#f9fafb; margin-bottom:24px; }
|
| 34 |
+
.results-title { font-size:16px; font-weight:700; color:#374151; margin:0 0 12px; }
|
| 35 |
+
.metrics-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-bottom:14px; }
|
| 36 |
+
@media (max-width:600px){ .metrics-grid{ grid-template-columns:1fr; } }
|
| 37 |
+
.metric-card { background:#fff; padding:12px; border-radius:6px; border:1px solid #e5e7eb; }
|
| 38 |
+
.metric-label { font-size:12px; color:#6b7280; }
|
| 39 |
+
.metric-value { font-size:21px; font-weight:700; margin-top:4px; font-variant-numeric:tabular-nums; }
|
| 40 |
+
.metric-sub { font-size:11px; color:#9ca3af; margin-top:2px; }
|
| 41 |
+
#resReward { color:#059669; } #resLength { color:#d97706; } #resEntropy { color:#0891b2; }
|
| 42 |
+
.summary-box { font-size:14px; color:#374151; background:#fff; padding:12px; border-radius:6px; border:1px solid #e5e7eb; line-height:1.7; margin-bottom:14px; }
|
| 43 |
+
.tables { display:grid; grid-template-columns:1fr; gap:14px; }
|
| 44 |
+
@media (min-width:760px){ .tables{ grid-template-columns:1.3fr 1fr; } }
|
| 45 |
+
table.res { width:100%; border-collapse:collapse; font-size:13px; background:#fff; }
|
| 46 |
+
table.res caption { text-align:left; font-weight:700; font-size:13px; color:#374151; margin-bottom:6px; }
|
| 47 |
+
table.res th, table.res td { border:1px solid #e5e7eb; padding:5px 8px; text-align:right; font-variant-numeric:tabular-nums; }
|
| 48 |
+
table.res th { background:#f3f4f6; color:#4b5563; font-weight:600; }
|
| 49 |
+
table.res td:first-child, table.res th:first-child { text-align:center; }
|
| 50 |
+
table.res tr.sel td { background:#dbeafe; font-weight:700; color:#1e3a8a; }
|
| 51 |
+
table.res td.best { color:#059669; }
|
| 52 |
+
.canvas-container { display:flex; flex-direction:column; align-items:center; background:#f9fafb; padding:16px; border-radius:8px; border:1px solid #e5e7eb; }
|
| 53 |
+
.canvas-title { font-size:13px; color:#374151; margin-bottom:8px; font-weight:600; }
|
| 54 |
+
#liveStatus { font-size:12px; color:#374151; margin-top:8px; font-family:monospace; text-align:center; }
|
| 55 |
+
#liveReward { font-size:12px; color:#4b5563; margin-top:6px; font-family:monospace; text-align:center; line-height:1.6; }
|
| 56 |
+
canvas { background:#fff; border:1px solid #d1d5db; border-radius:4px; max-width:100%; height:auto; }
|
| 57 |
+
.footer { padding:16px; border-top:1px solid #e5e7eb; text-align:center; font-size:12px; color:#6b7280; background:#f9fafb; line-height:1.8; }
|
| 58 |
+
.footer a { color:#1d4ed8; font-weight:600; }
|
| 59 |
+
/* 탭 */
|
| 60 |
+
.tabs { display:flex; gap:4px; padding:12px 24px 0; border-bottom:1px solid #e5e7eb; background:#fff; flex-wrap:wrap; }
|
| 61 |
+
.tab { background:none; border:1px solid transparent; border-bottom:none; padding:9px 16px; font-size:14px; color:#6b7280; cursor:pointer; border-radius:8px 8px 0 0; font-family:inherit; margin-bottom:-1px; }
|
| 62 |
+
.tab:hover { color:#1d4ed8; }
|
| 63 |
+
.tab.active { color:#111827; font-weight:700; border-color:#1d4ed8; border-width:2px; background:#fff; }
|
| 64 |
+
.tab-panel[hidden] { display:none; }
|
| 65 |
+
/* 검토·교육 */
|
| 66 |
+
.review-grid { display:grid; grid-template-columns:1fr; gap:20px; padding:24px; }
|
| 67 |
+
@media (min-width:900px){ .review-grid{ grid-template-columns:1fr 1fr; } }
|
| 68 |
+
.review-card { border:1px solid #e5e7eb; border-radius:10px; padding:20px 22px; background:#fff; }
|
| 69 |
+
.review-card h3 { margin:0 0 12px; font-size:16px; color:#111827; }
|
| 70 |
+
.review-card ul { margin:0; padding-left:18px; }
|
| 71 |
+
.review-card li { font-size:14px; line-height:1.75; color:#374151; margin-bottom:12px; }
|
| 72 |
+
.review-card li:last-child { margin-bottom:0; }
|
| 73 |
+
.review-card li b.k { color:#111827; }
|
| 74 |
+
.discuss { margin:0 24px 24px; border:1px solid #bfdbfe; background:#eff6ff; border-radius:10px; padding:16px 22px; }
|
| 75 |
+
.discuss h3 { margin:0 0 8px; font-size:15px; color:#1e3a8a; }
|
| 76 |
+
.discuss ol { margin:0; padding-left:20px; font-size:14px; line-height:1.8; color:#1f2937; }
|
| 77 |
+
</style>
|
| 78 |
+
</head>
|
| 79 |
+
<body>
|
| 80 |
+
<div class="container">
|
| 81 |
+
<div class="header">
|
| 82 |
+
<h1>군집 무인기 자율 협력을 위한 멀티 에이전트 강화학습 설계 데모</h1>
|
| 83 |
+
<p>MA-POCA(Unity ML-Agents) 기반 실험에서 적·아군 투입 규모와 적 처치 보상 스케일이 협력 정책(누적 보상, 에피소드 길이, 정책 엔트로피)에 미친 영향을 논문 결과로 보여주고, 논문의 환경·보상 규칙을 2D 전장에서 재현합니다.</p>
|
| 84 |
+
</div>
|
| 85 |
+
|
| 86 |
+
<div class="tabs" role="tablist">
|
| 87 |
+
<button class="tab active" role="tab" data-tab="sim">① 시뮬레이터</button>
|
| 88 |
+
<button class="tab" role="tab" data-tab="review">② 검토·교육</button>
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
<div class="tab-panel" id="panel-sim">
|
| 92 |
+
<div class="main-grid">
|
| 93 |
+
<div class="control-panel">
|
| 94 |
+
<h2 class="panel-title">시나리오 설정</h2>
|
| 95 |
+
|
| 96 |
+
<div class="form-group">
|
| 97 |
+
<span class="group-label">적 타겟 수 (Target)</span>
|
| 98 |
+
<div class="flex-gap">
|
| 99 |
+
<label class="radio-label"><input type="radio" name="enemy" value="4" checked> 4대</label>
|
| 100 |
+
<label class="radio-label"><input type="radio" name="enemy" value="5"> 5대</label>
|
| 101 |
+
</div>
|
| 102 |
+
</div>
|
| 103 |
+
|
| 104 |
+
<div class="form-group">
|
| 105 |
+
<span class="group-label">아군 에이전트 수 (Agent)</span>
|
| 106 |
+
<div class="flex-gap">
|
| 107 |
+
<label class="radio-label"><input type="radio" name="agent" value="2" checked> 2대</label>
|
| 108 |
+
<label class="radio-label"><input type="radio" name="agent" value="3"> 3대</label>
|
| 109 |
+
<label class="radio-label"><input type="radio" name="agent" value="4"> 4대</label>
|
| 110 |
+
</div>
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
<div class="form-group">
|
| 114 |
+
<span class="group-label">적 처치 보상 (Target Elimination Reward)</span>
|
| 115 |
+
<div class="flex-gap">
|
| 116 |
+
<label class="radio-label"><input type="radio" name="scale" value="1"> +1</label>
|
| 117 |
+
<label class="radio-label"><input type="radio" name="scale" value="3" checked> +3 (기본)</label>
|
| 118 |
+
<label class="radio-label"><input type="radio" name="scale" value="5"> +5</label>
|
| 119 |
+
</div>
|
| 120 |
+
<div class="hint" id="scaleHint">보상 스케일 실험은 논문의 대표 조합(적 4 : 아군 2)에서만 수행되었습니다.</div>
|
| 121 |
+
</div>
|
| 122 |
+
|
| 123 |
+
<button id="runBtn" class="btn">전술 시뮬레이션 실행</button>
|
| 124 |
+
|
| 125 |
+
<table class="params">
|
| 126 |
+
<caption>환경 파라미터 (논문 표 1·2)</caption>
|
| 127 |
+
<tr><td>전장 크기</td><td>350 m × 400 m</td></tr>
|
| 128 |
+
<tr><td>이동 속도 (공통)</td><td>20 m/s</td></tr>
|
| 129 |
+
<tr><td>미사일 속도 / 피해</td><td>40 m/s / 1</td></tr>
|
| 130 |
+
<tr><td>미사일 재장전</td><td>5 s</td></tr>
|
| 131 |
+
<tr><td>체력 (HP)</td><td>1</td></tr>
|
| 132 |
+
<tr><td>아군 공격 사거리</td><td>50 m</td></tr>
|
| 133 |
+
<tr><td>적 공격 사거리</td><td>30 m</td></tr>
|
| 134 |
+
<tr><td>외곽 경계</td><td>반사(Reflection)</td></tr>
|
| 135 |
+
</table>
|
| 136 |
+
|
| 137 |
+
<div class="legend">
|
| 138 |
+
<div><span class="dot" style="background:#2563eb"></span>아군 에이전트 (사거리 50 m)</div>
|
| 139 |
+
<div><span class="dot" style="background:#dc2626"></span>적 타겟 (사거리 30 m)</div>
|
| 140 |
+
<div><span class="dot" style="background:#9ca3af"></span>격추된 기체</div>
|
| 141 |
+
<div><span class="dot" style="background:#111827;width:6px;height:6px"></span>미사일</div>
|
| 142 |
+
</div>
|
| 143 |
+
</div>
|
| 144 |
+
|
| 145 |
+
<div>
|
| 146 |
+
<div class="results-panel">
|
| 147 |
+
<h3 class="results-title" id="resTitle">논문 실험 결과</h3>
|
| 148 |
+
<div class="metrics-grid">
|
| 149 |
+
<div class="metric-card">
|
| 150 |
+
<div class="metric-label" id="rewardLabel">최종 누��� 보상</div>
|
| 151 |
+
<div id="resReward" class="metric-value">–</div>
|
| 152 |
+
<div class="metric-sub" id="rewardSub"></div>
|
| 153 |
+
</div>
|
| 154 |
+
<div class="metric-card">
|
| 155 |
+
<div class="metric-label">최종 에피소드 길이</div>
|
| 156 |
+
<div id="resLength" class="metric-value">–</div>
|
| 157 |
+
<div class="metric-sub" id="lengthSub"></div>
|
| 158 |
+
</div>
|
| 159 |
+
<div class="metric-card">
|
| 160 |
+
<div class="metric-label">정책 엔트로피 (초기 → 수렴)</div>
|
| 161 |
+
<div id="resEntropy" class="metric-value">–</div>
|
| 162 |
+
<div class="metric-sub" id="entropySub"></div>
|
| 163 |
+
</div>
|
| 164 |
+
</div>
|
| 165 |
+
<div id="resSummary" class="summary-box"></div>
|
| 166 |
+
|
| 167 |
+
<div class="tables">
|
| 168 |
+
<table class="res">
|
| 169 |
+
<caption>표 6. 에이전트-타겟 조합별 결과 (처치 보상 +3)</caption>
|
| 170 |
+
<thead><tr><th>적:아군</th><th>누적 보상</th><th>에피소드 길이</th><th>엔트로피</th></tr></thead>
|
| 171 |
+
<tbody id="t6"></tbody>
|
| 172 |
+
</table>
|
| 173 |
+
<table class="res">
|
| 174 |
+
<caption>표 7. 보상값별 결과 (적 4 : 아군 2, 1대당)</caption>
|
| 175 |
+
<thead><tr><th>보상</th><th>누적 보상</th><th>길이</th><th>엔트로피</th></tr></thead>
|
| 176 |
+
<tbody id="t7"></tbody>
|
| 177 |
+
</table>
|
| 178 |
+
</div>
|
| 179 |
+
</div>
|
| 180 |
+
|
| 181 |
+
<div class="canvas-container">
|
| 182 |
+
<div class="canvas-title">2D 가상 전장 교전 재현 (350 m × 400 m, 1 px = 1 m)</div>
|
| 183 |
+
<canvas id="battleCanvas" width="350" height="400"></canvas>
|
| 184 |
+
<div id="liveStatus">대기 중</div>
|
| 185 |
+
<div id="liveReward"></div>
|
| 186 |
+
<div class="hint" style="max-width:520px;text-align:center">
|
| 187 |
+
교전 재현의 아군 기동은 학습된 MA-POCA 정책이 아니라, 논문이 서술한 보상 스케일별 정책 경향(+1 소극적 탐색, +3 사거리 우위를 활용한 협력, +5 무리한 돌진)을 단순 규칙으로 표현한 것입니다. 보상은 논문 표 3·4 규칙으로 집계합니다.
|
| 188 |
+
</div>
|
| 189 |
+
</div>
|
| 190 |
+
</div>
|
| 191 |
+
</div>
|
| 192 |
+
</div>
|
| 193 |
+
|
| 194 |
+
<div class="tab-panel" id="panel-review" hidden>
|
| 195 |
+
<div class="review-grid">
|
| 196 |
+
<div class="review-card">
|
| 197 |
+
<h3>논문 내용 확인 결과</h3>
|
| 198 |
+
<ul>
|
| 199 |
+
<li><b class="k">표 6과 표 7의 같은 조건 불일치:</b> 표 7의 보상 3 결과(1대당 73)는 표 6의 4:2 결과(팀 146)를 2로 나눈 값과 같아 같은 조건입니다. 그런데 에피소드 길이(82 / 81)와 정책 엔트로피(0.31 / 0.42)가 서로 다릅니다. 두 표가 별도 실행이라면 그 사실과 시드를 밝혀야 하고, 같은 실행이라면 수치를 맞춰야 합니다. 표 7이 1대당 값이라는 점도 표 제목에 적혀 있지 않습니다.</li>
|
| 200 |
+
<li><b class="k">보상 스케일 간 누적 보상 비교:</b> 처치 보상을 1, 3, 5로 바꾸면 누적 보상의 크기 자체가 달라집니다. 그런데 표 7의 누적 보상은 72, 73, 70으로 거의 같아, 보상 단위가 다른 값을 그대로 비교한 것인지 정규화한 것인지 알 수 없습니다. 스케일 간 우열은 임무 성공률처럼 보상과 독립적인 지표로 비교해야 합니다.</li>
|
| 201 |
+
<li><b class="k">보상 +5의 "협력 약화" 근거:</b> 표 7에서 보상 3과 5의 최종 엔트로피는 0.42로 같고, 누적 보상 차이는 73 대 70(약 4%)입니다. "엔트로피가 높게 유지되고 협력 구조가 약화된다"는 해석은 그림 4의 곡선에 기대고 있어, 수렴 시점이나 분산 같은 정량값이 함께 제시되어야 합니다.</li>
|
| 202 |
+
<li><b class="k">"최적 투입 규모"의 기준:</b> 4:3을 적 4대 환경의 최적으로 보았지만, 팀 누적 보상은 4:4(216)가 더 높고, 1대당 보상은 4:2(73)가 4:3(62)보다 높습니다. 엔트로피, 에피소드 길이, 보상 중 무엇을 우선하는지 판단 기준을 먼저 정의해야 결론이 성립합니다.</li>
|
| 203 |
+
<li><b class="k">적 5대 환경의 해석 부재:</b> 4.2절은 적 4대 조합만 자세히 해석합니다. 적 5대에서는 4대 투입(5:4)이 보상 268, 엔트로피 0.16으로 가장 좋고, 5:3의 엔트로피(0.50)가 5:2(0.39)보다 높습니다. 4대 환경의 "증원 시 간섭" 결론과 반대되는 양상이라 설명이 필요합니다.</li>
|
| 204 |
+
<li><b class="k">보상 항목의 지급 단위:</b> 표 3의 접근 보상(+0.1)은 스텝, 결정 주기, 초 중 무엇마다 지급되는지 없습니다. HP가 1이고 미사일 피해가 1이므로 체력 손실(−0.3)은 곧 파괴(−1.0)와 함께 발생해, 두 항목을 따로 둔 의미가 드러나지 않습니다.</li>
|
| 205 |
+
<li><b class="k">지표의 단위와 정의:</b> 에피소드 길이(75~93)가 스텝, 결정 횟수, 초 중 어느 단위인지, 엔트로피 초기값 2.1이 어떤 행동 공간(이산·연속, 차원)에서 나온 값인지 나와 있지 않습니다. 제한 시간과 적 타겟의 행동 규칙도 기술되지 않았습니다.</li>
|
| 206 |
+
<li><b class="k">표기 오류:</b> 2.2절에서 "Kyungbeom Kim 등[5]"은 참고문헌 [4]입니다([5]는 Hoseong Jung). 첫 쪽의 논문수정·심사완료일 "2026년 14월 24일", "15월 28일"은 영문 표기(April 24, May 28)와 맞지 않습니다.</li>
|
| 207 |
+
</ul>
|
| 208 |
+
</div>
|
| 209 |
+
|
| 210 |
+
<div class="review-card">
|
| 211 |
+
<h3>현재 관점에서의 보완점</h3>
|
| 212 |
+
<ul>
|
| 213 |
+
<li><b class="k">통계적 신뢰성:</b> 다중 시드 검증은 4:2 조합, 5M 스텝 구간에서 3회만 수행되었고, 표 6·7은 단일 값으로만 제시됩니다. 조건별 5개 이상의 시드로 평균, 표준편차, 신뢰구간을 보고하고, 조건 간 차이(예: 보상 73 대 70)에 검정을 적용해야 결론의 무게가 생깁니다. 강화학습 평가에서는 IQM 같은 견고한 집계 지표 사용이 권장됩니다.</li>
|
| 214 |
+
<li><b class="k">보상과 독립적인 성능 지표:</b> 누적 보상은 보상 설계에 따라 달라지므로, 임무 성공률, 아군 생존율, 격추 교환비, 임무 소요 시간(초) 같은 작전 지표를 함께 측정하면 조합 간·스케일 간 비교가 공정해집니다. 논문도 누적 보상을 성공률의 대리 지표로 쓴다고 밝히고 있어, 성공률을 직접 제시하는 편이 명확합니다.</li>
|
| 215 |
+
<li><b class="k">기준선 알고리즘 비교:</b> MA-POCA 단독 결과만 있어 이 알고리즘을 쓴 효과가 분리되지 않습니다. 독립 PPO, MAPPO, 규칙 기반 정책과 같은 환경에서 비교하면 중앙 집중식 신용 할당의 기여를 확인할 수 있습니다.</li>
|
| 216 |
+
<li><b class="k">MA-POCA의 강점 활용:</b> 논문은 MA-POCA가 에이전트의 생성·소멸을 다룬다는 점을 선택 근거로 들었지만, 실험은 조합별로 따로 학습했습니다. 한 정책으로 2~4대를 모두 운용하는 일반화 실험, 교전 중 아군이 소멸할 때의 신용 할당 효과 분석이 추가되면 알고리즘 선택이 실험으로 뒷받침됩니다.</li>
|
| 217 |
+
<li><b class="k">보상 설계 방법:</b> 스케일을 1, 3, 5로 바꾸는 방식 외에, 접근 보상처럼 형성(shaping) 보상은 잠재 함수 기반 보상 형성(PBRS)으로 바꾸면 최적 정책을 바꾸지 않는다는 이론적 보장이 생깁니다. 보상 정규화를 함께 쓰면 스케일 변화가 학습률처럼 작용하는 효과도 분리할 수 있습니다.</li>
|
| 218 |
+
<li><b class="k">적 정책과 환경의 현실성:</b> 적 타겟의 행동이 고정 규칙이면 아군 정책이 그 규칙에 과적합될 수 있습니다. ML-Agents의 셀프 플레이로 적도 함께 학습시키거나, 통신 제약, 센서 오차, 3차원 기동을 단계적으로 넣으면 결과의 전장 적용성이 높아집니다.</li>
|
| 219 |
+
<li><b class="k">재현성:</b> 관측·행동 공간 정의, 보상 지급 주기, 학습 설정 파일(YAML), 환경 빌드와 시드를 공개해야 같은 결과를 다시 얻을 수 있습니다. ML-Agents 버전에 따라 POCA 구현이 바뀔 수 있으므로 버전도 명시해야 합니다.</li>
|
| 220 |
+
<li><b class="k">운용 관점의 검토:</b> 무장 무인기 군집의 자율 교전은 인간의 판단과 통제를 어디에 둘지가 함께 다뤄져야 합니다. 교전 승인 단계, 정책의 설명 가능성, 오인 교전 같은 안전 제약을 시뮬레이션 지표에 포함하면 유인·무인 복합체계(MUM-T) 연구로 이어가기 좋습니다.</li>
|
| 221 |
+
</ul>
|
| 222 |
+
</div>
|
| 223 |
+
</div>
|
| 224 |
+
|
| 225 |
+
<div class="discuss">
|
| 226 |
+
<h3>수업 토의 질문</h3>
|
| 227 |
+
<ol>
|
| 228 |
+
<li>4:3과 4:4 중 어느 쪽이 "더 좋은" 투입 규모인가요? 누적 보상, 1대당 보상, 엔트로피, 에피소드 길이 중 무엇을 기준으로 삼을지 먼저 정해 보세요.</li>
|
| 229 |
+
<li>처치 보상을 5로 올렸는데 누적 보상이 3일 때보다 낮게 나온 이유를 보상 단위와 정책 행동 두 측면에서 설명해 보세요.</li>
|
| 230 |
+
<li>시뮬레이터 탭에서 보상 +1, +3, +5로 여러 번 실행해 보고, 결과가 실행마다 얼마나 달라지는지 관찰해 보세요. 시드 3개로 충분한가요?</li>
|
| 231 |
+
<li>적 5대 환경에서 4:3의 결론(증원 시 간섭)이 5:4에서는 나타나지 않은 이유는 무엇일까요? 전장 밀도 관점에서 가설을 세워 보세요.</li>
|
| 232 |
+
</ol>
|
| 233 |
+
</div>
|
| 234 |
+
</div>
|
| 235 |
+
|
| 236 |
+
<div class="footer">
|
| 237 |
+
박기평·강동수, 「군집 무인기 자율 협력을 위한 멀티 에이전트 강화학습 설계」, 정보과학회 컴퓨팅의 실제 논문지 32(7), pp. 296–303, 2026.<br>
|
| 238 |
+
상단 지표와 표 6·7은 논문 보고값이며, 교전 재현의 보상·시간은 이 데모 에피소드의 값입니다.<br>
|
| 239 |
+
원문: <a href="https://doi.org/10.5626/KTCP.2026.32.7.296" target="_blank" rel="noopener">doi.org/10.5626/KTCP.2026.32.7.296</a>
|
| 240 |
+
</div>
|
| 241 |
+
</div>
|
| 242 |
+
|
| 243 |
+
<script>
|
| 244 |
+
// ================= 논문 데이터 =================
|
| 245 |
+
// 표 6: 에이전트-타겟 조합별 결과 (처치 보상 +3, 팀 누��� 보상)
|
| 246 |
+
const TABLE6 = {
|
| 247 |
+
"4:2": { reward:146, length:82, entropy:0.31 },
|
| 248 |
+
"4:3": { reward:186, length:75, entropy:0.13 },
|
| 249 |
+
"4:4": { reward:216, length:77, entropy:0.33 },
|
| 250 |
+
"5:2": { reward:186, length:93, entropy:0.39 },
|
| 251 |
+
"5:3": { reward:240, length:85, entropy:0.50 },
|
| 252 |
+
"5:4": { reward:268, length:83, entropy:0.16 }
|
| 253 |
+
};
|
| 254 |
+
// 표 7: 보상값 변화에 따른 결과 (적 4 : 아군 2, 1대당 평균 보상)
|
| 255 |
+
const TABLE7 = {
|
| 256 |
+
1: { reward:72, length:79, entropy:1.2 },
|
| 257 |
+
3: { reward:73, length:81, entropy:0.42 },
|
| 258 |
+
5: { reward:70, length:79, entropy:0.42 }
|
| 259 |
+
};
|
| 260 |
+
const ENTROPY_INIT = 2.1;
|
| 261 |
+
|
| 262 |
+
// 논문 본문 해석 (4.2절)
|
| 263 |
+
const COMBO_TEXT = {
|
| 264 |
+
"4:2": "대표 조합입니다. 아군 1대당 평균 보상 73(팀 146)으로 수적 열세에서도 사거리 우위(50 m vs 30 m)를 활용해 임무를 수행했습니다.",
|
| 265 |
+
"4:3": "적 4대 환경의 최적 투입 규모입니다. 정책 엔트로피가 가장 가파르게 떨어져 최저(0.13)로 안정화되었고, 에피소드 길이도 가장 짧은 75로 수렴했습니다.",
|
| 266 |
+
"4:4": "4:3 대비 팀 누적 보상은 소폭 올랐지만 1대 추가에 따른 증가 폭은 줄었습니다. 최종 엔트로피가 약 2.5배(0.33) 높게 유지되고 에피소드 길이도 75 → 77로 늘어, 한정된 공간에서 개체 수 증가가 동선 간섭을 일으켜 협력 효율을 떨어뜨렸습니다.",
|
| 267 |
+
"5:2": "적 5대에 2대만 투입한 조합으로, 에피소드 길이가 93으로 가장 길었습니다.",
|
| 268 |
+
"5:3": "적 5대 환경에서 엔트로피가 0.50으로 가장 높게 남아 정책 수렴이 가장 불안정했습니다.",
|
| 269 |
+
"5:4": "적 5대 환경에서 팀 누적 보상(268)이 가장 높고 엔트로피(0.16)가 가장 낮아, 적 규모가 클 때는 4대 투입이 가장 효율적이었습니다."
|
| 270 |
+
};
|
| 271 |
+
const SCALE_TEXT = {
|
| 272 |
+
1: "처치 보상 +1에서는 개별 행동의 즉각 보상이 낮아 학습 동기가 약해집니다. 에이전트가 최적 행동을 빨리 고정하지 못하고 오래 탐색해 엔트로피가 1.2로 높게 남았습니다.",
|
| 273 |
+
3: "처치 보상 +3에서 누적 보상이 가장 높고(73) 엔트로피 감소가 가장 빨라, 탐험과 수렴의 균형이 가장 좋았습니다. 논문은 이를 적정 보상 스케일로 결론지었습니다.",
|
| 274 |
+
5: "처치 보상 +5에서는 단기 보상에 집중해 무리한 돌진·경쟁적 행동이 나타났습니다. 협력 구조가 약해져 학습 후반 누적 보상(70)이 +3보다 낮았고, 엔트로피도 늦게 안정화되었습니다."
|
| 275 |
+
};
|
| 276 |
+
|
| 277 |
+
// ================= UI =================
|
| 278 |
+
const $ = id => document.getElementById(id);
|
| 279 |
+
const getVal = name => parseInt(document.querySelector(`input[name="${name}"]:checked`).value, 10);
|
| 280 |
+
|
| 281 |
+
function syncScaleAvailability() {
|
| 282 |
+
const combo = getVal("enemy") + ":" + getVal("agent");
|
| 283 |
+
const allow = combo === "4:2";
|
| 284 |
+
document.querySelectorAll('input[name="scale"]').forEach(r => {
|
| 285 |
+
if (r.value !== "3") r.disabled = !allow;
|
| 286 |
+
});
|
| 287 |
+
if (!allow) document.querySelector('input[name="scale"][value="3"]').checked = true;
|
| 288 |
+
$("scaleHint").style.color = allow ? "#1d4ed8" : "#6b7280";
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
function renderTables(combo, scale) {
|
| 292 |
+
const best = { reward: {}, length: {}, entropy: {} };
|
| 293 |
+
[4, 5].forEach(e => {
|
| 294 |
+
const rows = [2, 3, 4].map(a => TABLE6[e + ":" + a]);
|
| 295 |
+
best.reward[e] = Math.max(...rows.map(r => r.reward));
|
| 296 |
+
best.length[e] = Math.min(...rows.map(r => r.length));
|
| 297 |
+
best.entropy[e] = Math.min(...rows.map(r => r.entropy));
|
| 298 |
+
});
|
| 299 |
+
$("t6").innerHTML = Object.entries(TABLE6).map(([k, r]) => {
|
| 300 |
+
const e = +k.split(":")[0];
|
| 301 |
+
const c = (key, v) => (v === best[key][e] ? ' class="best"' : "");
|
| 302 |
+
return `<tr${k === combo ? ' class="sel"' : ""}><td>${k}</td><td${c("reward", r.reward)}>${r.reward}</td>` +
|
| 303 |
+
`<td${c("length", r.length)}>${r.length}</td><td${c("entropy", r.entropy)}>${ENTROPY_INIT} → ${r.entropy}</td></tr>`;
|
| 304 |
+
}).join("");
|
| 305 |
+
$("t7").innerHTML = Object.entries(TABLE7).map(([s, r]) =>
|
| 306 |
+
`<tr${combo === "4:2" && +s === scale ? ' class="sel"' : ""}><td>+${s}</td><td>${r.reward}</td><td>${r.length}</td><td>${ENTROPY_INIT} → ${r.entropy}</td></tr>`
|
| 307 |
+
).join("");
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
function renderResults() {
|
| 311 |
+
const nE = getVal("enemy"), nA = getVal("agent"), scale = getVal("scale");
|
| 312 |
+
const combo = nE + ":" + nA;
|
| 313 |
+
const t6 = TABLE6[combo];
|
| 314 |
+
|
| 315 |
+
if (combo === "4:2" && scale !== 3) {
|
| 316 |
+
const t7 = TABLE7[scale];
|
| 317 |
+
$("resTitle").textContent = `논문 실험 결과 — 적 4 : 아군 2, 처치 보상 +${scale} (표 7)`;
|
| 318 |
+
$("rewardLabel").textContent = "최종 누적 보상 (1대당)";
|
| 319 |
+
$("resReward").textContent = t7.reward;
|
| 320 |
+
$("rewardSub").textContent = `+3 기준 73 대비 ${t7.reward - 73 >= 0 ? "+" : ""}${t7.reward - 73}`;
|
| 321 |
+
$("resLength").textContent = t7.length;
|
| 322 |
+
$("lengthSub").textContent = "+3 기준 81";
|
| 323 |
+
$("resEntropy").textContent = `${ENTROPY_INIT} → ${t7.entropy}`;
|
| 324 |
+
$("entropySub").textContent = "+3 기준 0.42";
|
| 325 |
+
$("resSummary").innerHTML = SCALE_TEXT[scale];
|
| 326 |
+
} else {
|
| 327 |
+
$("resTitle").textContent = `논문 실��� 결과 — 적 ${nE} : 아군 ${nA}, 처치 보상 +3 (표 6)`;
|
| 328 |
+
$("rewardLabel").textContent = "최종 누적 보상 (팀)";
|
| 329 |
+
$("resReward").textContent = t6.reward;
|
| 330 |
+
$("rewardSub").textContent = `1대당 ${(t6.reward / nA).toFixed(1)}`;
|
| 331 |
+
$("resLength").textContent = t6.length;
|
| 332 |
+
$("lengthSub").textContent = "";
|
| 333 |
+
$("resEntropy").textContent = `${ENTROPY_INIT} → ${t6.entropy}`;
|
| 334 |
+
$("entropySub").textContent = "";
|
| 335 |
+
let txt = COMBO_TEXT[combo];
|
| 336 |
+
if (combo === "4:2") txt += "<br>" + SCALE_TEXT[3] + " (표 7, 1대당 73 / 길이 81 / 엔트로피 0.42)";
|
| 337 |
+
$("resSummary").innerHTML = txt;
|
| 338 |
+
}
|
| 339 |
+
renderTables(combo, scale);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
document.querySelectorAll('input[name="enemy"], input[name="agent"], input[name="scale"]').forEach(el =>
|
| 343 |
+
el.addEventListener("change", () => { syncScaleAvailability(); renderResults(); }));
|
| 344 |
+
|
| 345 |
+
// ================= 교전 재현 =================
|
| 346 |
+
const canvas = $("battleCanvas"), ctx = canvas.getContext("2d");
|
| 347 |
+
const W = 350, H = 400; // 1 px = 1 m
|
| 348 |
+
const DT = 0.1; // 시뮬레이션 시간 간격 (s)
|
| 349 |
+
const SPEED = 20, MISSILE_SPEED = 40, RELOAD = 5;
|
| 350 |
+
const RANGE_AGENT = 50, RANGE_TARGET = 30;
|
| 351 |
+
const MISSILE_LIFE = 2.0; // 최대 비행 시간 (s)
|
| 352 |
+
const TIME_LIMIT = 120; // 제한 시간 (s, 데모 설정)
|
| 353 |
+
const HIT_R = 4;
|
| 354 |
+
let animId = null;
|
| 355 |
+
|
| 356 |
+
const rand = (a, b) => a + Math.random() * (b - a);
|
| 357 |
+
const dist = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
| 358 |
+
|
| 359 |
+
function createEpisode(nA, nE, scale) {
|
| 360 |
+
const agents = [], targets = [];
|
| 361 |
+
for (let i = 0; i < nA; i++) { // 아군 구역(하단)에 무작위 배치
|
| 362 |
+
const x = rand(30, W - 30), y = rand(H - 70, H - 20);
|
| 363 |
+
agents.push({ id: i, x, y, vx: 0, vy: 0, alive: true, cd: rand(0, 1), trail: [{ x, y }], detected: new Set(), lastD: null });
|
| 364 |
+
}
|
| 365 |
+
for (let i = 0; i < nE; i++) { // 적 구역(상단)에 무작위 배치
|
| 366 |
+
const x = rand(30, W - 30), y = rand(20, 80);
|
| 367 |
+
const ang = rand(0, Math.PI * 2);
|
| 368 |
+
targets.push({ id: i, x, y, vx: Math.cos(ang) * SPEED, vy: Math.sin(ang) * SPEED, alive: true, cd: rand(0, 1), trail: [{ x, y }] });
|
| 369 |
+
}
|
| 370 |
+
return { agents, targets, missiles: [], scale, t: 0, steps: 0, done: false, success: false,
|
| 371 |
+
rw: { kill: 0, detect: 0, approach: 0, lost: 0, hp: 0, exposure: 0, time: 0, group: 0 } };
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
function totalReward(rw) { return Object.values(rw).reduce((s, v) => s + v, 0); }
|
| 375 |
+
|
| 376 |
+
// 보상 스케일별 정책 경향 (논문 4.2절 서술을 규칙으로 표현)
|
| 377 |
+
function standoff(scale) {
|
| 378 |
+
if (scale === 5) return 36; // 공격적 접근: 적 사거리(30 m) 경계까지 밀착
|
| 379 |
+
return 42; // 사거리 우위 활용: 30~50 m 사이 유지
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
function assignTargets(ep) {
|
| 383 |
+
const alive = ep.targets.filter(t => t.alive), agents = ep.agents.filter(a => a.alive);
|
| 384 |
+
const map = new Map();
|
| 385 |
+
if (!alive.length) return map;
|
| 386 |
+
if (ep.scale === 5) { // 개별 성과 집착: 각자 가장 가까운 적 추격 (중복 허용)
|
| 387 |
+
agents.forEach(a => map.set(a, alive.reduce((b, t) => dist(a, t) < dist(a, b) ? t : b)));
|
| 388 |
+
return map;
|
| 389 |
+
}
|
| 390 |
+
const pairs = []; // 협력 할당: 중복 최소화 그리디
|
| 391 |
+
agents.forEach(a => alive.forEach(t => pairs.push({ a, t, d: dist(a, t) })));
|
| 392 |
+
pairs.sort((p, q) => p.d - q.d);
|
| 393 |
+
const taken = new Set();
|
| 394 |
+
for (const p of pairs) {
|
| 395 |
+
if (map.has(p.a) || taken.has(p.t)) continue;
|
| 396 |
+
map.set(p.a, p.t); taken.add(p.t);
|
| 397 |
+
}
|
| 398 |
+
agents.forEach(a => { if (!map.has(a)) map.set(a, alive.reduce((b, t) => dist(a, t) < dist(a, b) ? t : b)); });
|
| 399 |
+
return map;
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
function reflect(o) { // 외곽 경계 반사
|
| 403 |
+
if (o.x < 5) { o.x = 5; o.vx = Math.abs(o.vx); }
|
| 404 |
+
if (o.x > W - 5) { o.x = W - 5; o.vx = -Math.abs(o.vx); }
|
| 405 |
+
if (o.y < 5) { o.y = 5; o.vy = Math.abs(o.vy); }
|
| 406 |
+
if (o.y > H - 5) { o.y = H - 5; o.vy = -Math.abs(o.vy); }
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
function fire(ep, shooter, target, side) {
|
| 410 |
+
ep.missiles.push({ x: shooter.x, y: shooter.y, target, side, shooter, life: MISSILE_LIFE });
|
| 411 |
+
shooter.cd = RELOAD;
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
function stepEpisode(ep) {
|
| 415 |
+
if (ep.done) return;
|
| 416 |
+
ep.steps++; ep.t += DT;
|
| 417 |
+
const liveAgents = ep.agents.filter(a => a.alive);
|
| 418 |
+
ep.rw.time += -0.001 * DT * liveAgents.length; // 시간 페널티 -0.001×sec
|
| 419 |
+
|
| 420 |
+
// --- 아군 기동 ---
|
| 421 |
+
const assign = assignTargets(ep);
|
| 422 |
+
for (const a of liveAgents) {
|
| 423 |
+
const t = assign.get(a);
|
| 424 |
+
a.cd = Math.max(0, a.cd - DT);
|
| 425 |
+
if (!t) continue;
|
| 426 |
+
let dx = t.x - a.x, dy = t.y - a.y, d = Math.hypot(dx, dy) || 1;
|
| 427 |
+
let ux = dx / d, uy = dy / d;
|
| 428 |
+
if (ep.scale === 1 && Math.random() < 0.6) { // 소극적 탐색: 방향이 자주 흔들림
|
| 429 |
+
const ang = Math.atan2(uy, ux) + rand(-1.6, 1.6);
|
| 430 |
+
ux = Math.cos(ang); uy = Math.sin(ang);
|
| 431 |
+
}
|
| 432 |
+
const want = standoff(ep.scale);
|
| 433 |
+
let sx = ux, sy = uy;
|
| 434 |
+
if (d < want - 4) { sx = -ux; sy = -uy; } // 너무 가까우면 이탈
|
| 435 |
+
else if (d < want + 4) { sx = -uy; sy = ux; } // 거리 ���지하며 선회
|
| 436 |
+
// 아군 간 간섭 회피 (동선 간섭 표현)
|
| 437 |
+
for (const o of liveAgents) if (o !== a) {
|
| 438 |
+
const od = dist(a, o);
|
| 439 |
+
if (od < 25 && od > 0) { sx += (a.x - o.x) / od * 0.8; sy += (a.y - o.y) / od * 0.8; }
|
| 440 |
+
}
|
| 441 |
+
const sn = Math.hypot(sx, sy) || 1;
|
| 442 |
+
a.vx = sx / sn * SPEED; a.vy = sy / sn * SPEED;
|
| 443 |
+
a.x += a.vx * DT; a.y += a.vy * DT; reflect(a);
|
| 444 |
+
|
| 445 |
+
// 표적 접근 +0.1 (1초당 보상으로 적용)
|
| 446 |
+
const nd = dist(a, t);
|
| 447 |
+
if (a.lastD !== null && nd < a.lastD - 0.5 * SPEED * DT) ep.rw.approach += 0.1 * DT;
|
| 448 |
+
a.lastD = nd;
|
| 449 |
+
// 사거리 내 표적 식별 +0.5 (표적별 1회)
|
| 450 |
+
for (const tt of ep.targets) if (tt.alive && !a.detected.has(tt.id) && dist(a, tt) <= RANGE_AGENT) {
|
| 451 |
+
a.detected.add(tt.id); ep.rw.detect += 0.5;
|
| 452 |
+
}
|
| 453 |
+
// 사거리 내 표적에게 발사
|
| 454 |
+
if (a.cd === 0) {
|
| 455 |
+
const inRange = ep.targets.filter(tt => tt.alive && dist(a, tt) <= RANGE_AGENT);
|
| 456 |
+
if (inRange.length) fire(ep, a, inRange.reduce((b, tt) => dist(a, tt) < dist(a, b) ? tt : b), "A");
|
| 457 |
+
}
|
| 458 |
+
// 적 공격 사거리 내 위치 -0.2×sec
|
| 459 |
+
if (ep.targets.some(tt => tt.alive && dist(a, tt) <= RANGE_TARGET)) ep.rw.exposure += -0.2 * DT;
|
| 460 |
+
if (ep.steps % 3 === 0) a.trail.push({ x: a.x, y: a.y });
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
+
// --- 적 기동: 가장 가까운 아군에게 접근, 30 m 내 발사 ---
|
| 464 |
+
for (const t of ep.targets) {
|
| 465 |
+
if (!t.alive) continue;
|
| 466 |
+
t.cd = Math.max(0, t.cd - DT);
|
| 467 |
+
const near = liveAgents.length ? liveAgents.reduce((b, a) => dist(t, a) < dist(t, b) ? a : b) : null;
|
| 468 |
+
if (near) {
|
| 469 |
+
const d = dist(t, near) || 1;
|
| 470 |
+
const zig = Math.sin(ep.t * 1.3 + t.id) * 0.5;
|
| 471 |
+
let ux = (near.x - t.x) / d, uy = (near.y - t.y) / d;
|
| 472 |
+
const vx = ux - uy * zig, vy = uy + ux * zig, n = Math.hypot(vx, vy) || 1;
|
| 473 |
+
t.vx = vx / n * SPEED; t.vy = vy / n * SPEED;
|
| 474 |
+
if (t.cd === 0 && d <= RANGE_TARGET) fire(ep, t, near, "T");
|
| 475 |
+
}
|
| 476 |
+
t.x += t.vx * DT; t.y += t.vy * DT; reflect(t);
|
| 477 |
+
if (ep.steps % 3 === 0) t.trail.push({ x: t.x, y: t.y });
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
// --- 미사일 (유도, 40 m/s) ---
|
| 481 |
+
for (const m of ep.missiles) {
|
| 482 |
+
m.life -= DT;
|
| 483 |
+
if (!m.target.alive) { m.life = 0; continue; }
|
| 484 |
+
const d = dist(m, m.target) || 1;
|
| 485 |
+
m.x += (m.target.x - m.x) / d * MISSILE_SPEED * DT;
|
| 486 |
+
m.y += (m.target.y - m.y) / d * MISSILE_SPEED * DT;
|
| 487 |
+
if (dist(m, m.target) < HIT_R) {
|
| 488 |
+
m.target.alive = false; m.life = 0; // HP 1, 피해 1 → 1회 명중 시 파괴
|
| 489 |
+
if (m.side === "A") ep.rw.kill += ep.scale; // 타겟 처치 +scale
|
| 490 |
+
else { ep.rw.lost += -1.0; ep.rw.hp += -0.3 * 1; } // 에이전트 파괴 -1.0, 체력 손실 -0.3×1
|
| 491 |
+
}
|
| 492 |
+
}
|
| 493 |
+
ep.missiles = ep.missiles.filter(m => m.life > 0);
|
| 494 |
+
|
| 495 |
+
// --- 종료 판정 ---
|
| 496 |
+
const tAlive = ep.targets.some(t => t.alive), aAlive = ep.agents.some(a => a.alive);
|
| 497 |
+
if (!tAlive || !aAlive || ep.t >= TIME_LIMIT) {
|
| 498 |
+
ep.done = true;
|
| 499 |
+
ep.success = !tAlive && aAlive; // 모든 타겟 제거 + 1대 이상 생존
|
| 500 |
+
if (ep.success) ep.rw.group = 5.0 * ep.agents.length; // 그룹 보상 +5.0 (에이전트별)
|
| 501 |
+
}
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
function draw(ep) {
|
| 505 |
+
ctx.fillStyle = "#fff"; ctx.fillRect(0, 0, W, H);
|
| 506 |
+
ctx.strokeStyle = "#eef0f3"; ctx.lineWidth = 1;
|
| 507 |
+
for (let x = 0; x <= W; x += 50) { ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, H); ctx.stroke(); }
|
| 508 |
+
for (let y = 0; y <= H; y += 50) { ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(W, y); ctx.stroke(); }
|
| 509 |
+
ctx.fillStyle = "rgba(220,38,38,0.05)"; ctx.fillRect(0, 0, W, 100);
|
| 510 |
+
ctx.fillStyle = "rgba(37,99,235,0.05)"; ctx.fillRect(0, H - 90, W, 90);
|
| 511 |
+
ctx.fillStyle = "#9ca3af"; ctx.font = "10px sans-serif";
|
| 512 |
+
ctx.fillText("적 구역", 6, 12); ctx.fillText("아군 구역", 6, H - 78);
|
| 513 |
+
|
| 514 |
+
const trail = (tr, c) => { if (tr.length < 2) return; ctx.strokeStyle = c; ctx.lineWidth = 1.2; ctx.beginPath(); ctx.moveTo(tr[0].x, tr[0].y); tr.forEach(p => ctx.lineTo(p.x, p.y)); ctx.stroke(); };
|
| 515 |
+
const cross = (o) => { ctx.strokeStyle = "#9ca3af"; ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(o.x - 5, o.y - 5); ctx.lineTo(o.x + 5, o.y + 5); ctx.moveTo(o.x + 5, o.y - 5); ctx.lineTo(o.x - 5, o.y + 5); ctx.stroke(); };
|
| 516 |
+
|
| 517 |
+
ep.targets.forEach(t => {
|
| 518 |
+
trail(t.trail, "rgba(220,38,38,0.25)");
|
| 519 |
+
if (!t.alive) return cross(t);
|
| 520 |
+
ctx.strokeStyle = "rgba(220,38,38,0.35)"; ctx.setLineDash([3, 3]);
|
| 521 |
+
ctx.beginPath(); ctx.arc(t.x, t.y, RANGE_TARGET, 0, Math.PI * 2); ctx.stroke(); ctx.setLineDash([]);
|
| 522 |
+
ctx.fillStyle = "#dc2626"; ctx.beginPath();
|
| 523 |
+
ctx.moveTo(t.x, t.y + 7); ctx.lineTo(t.x - 6, t.y - 5); ctx.lineTo(t.x + 6, t.y - 5); ctx.closePath(); ctx.fill();
|
| 524 |
+
});
|
| 525 |
+
ep.agents.forEach(a => {
|
| 526 |
+
trail(a.trail, "rgba(37,99,235,0.3)");
|
| 527 |
+
if (!a.alive) return cross(a);
|
| 528 |
+
ctx.fillStyle = "rgba(37,99,235,0.07)"; ctx.beginPath(); ctx.arc(a.x, a.y, RANGE_AGENT, 0, Math.PI * 2); ctx.fill();
|
| 529 |
+
ctx.fillStyle = "#2563eb"; ctx.beginPath(); ctx.arc(a.x, a.y, 5, 0, Math.PI * 2); ctx.fill();
|
| 530 |
+
ctx.fillStyle = "#1e3a8a"; ctx.font = "10px monospace"; ctx.fillText("A" + (a.id + 1), a.x + 7, a.y - 6);
|
| 531 |
+
});
|
| 532 |
+
ep.missiles.forEach(m => { ctx.fillStyle = m.side === "A" ? "#1e3a8a" : "#991b1b"; ctx.fillRect(m.x - 1.5, m.y - 1.5, 3, 3); });
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
function renderLive(ep, nE, nA) {
|
| 536 |
+
const kills = ep.targets.filter(t => !t.alive).length, lost = ep.agents.filter(a => !a.alive).length;
|
| 537 |
+
let s = `t = ${ep.t.toFixed(1)} s | 격추 ${kills}/${nE} | 아군 손실 ${lost}/${nA} | 팀 보상 ${totalReward(ep.rw).toFixed(2)}`;
|
| 538 |
+
if (ep.done) s += ep.success ? " | 임무 성공" : (ep.agents.some(a => a.alive) ? " | 시간 초과" : " | 아군 전멸");
|
| 539 |
+
$("liveStatus").textContent = s;
|
| 540 |
+
const r = ep.rw;
|
| 541 |
+
$("liveReward").textContent =
|
| 542 |
+
`처치 ${r.kill.toFixed(1)} · 식별 ${r.detect.toFixed(1)} · 접근 ${r.approach.toFixed(2)} · 피격 ${(r.lost + r.hp).toFixed(1)} · 사거리 노출 ${r.exposure.toFixed(2)} · 시간 ${r.time.toFixed(3)} · 그룹 ${r.group.toFixed(1)}`;
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
$("runBtn").addEventListener("click", () => {
|
| 546 |
+
if (animId) cancelAnimationFrame(animId);
|
| 547 |
+
renderResults();
|
| 548 |
+
const nE = getVal("enemy"), nA = getVal("agent"), scale = getVal("scale");
|
| 549 |
+
const ep = createEpisode(nA, nE, scale);
|
| 550 |
+
const loop = () => {
|
| 551 |
+
for (let k = 0; k < 3; k++) stepEpisode(ep);
|
| 552 |
+
draw(ep); renderLive(ep, nE, nA);
|
| 553 |
+
if (!ep.done) animId = requestAnimationFrame(loop);
|
| 554 |
+
};
|
| 555 |
+
loop();
|
| 556 |
+
});
|
| 557 |
+
|
| 558 |
+
// 탭 전환
|
| 559 |
+
document.querySelectorAll(".tab").forEach(btn => btn.addEventListener("click", () => {
|
| 560 |
+
document.querySelectorAll(".tab").forEach(b => b.classList.toggle("active", b === btn));
|
| 561 |
+
document.querySelectorAll(".tab-panel").forEach(p => { p.hidden = p.id !== "panel-" + btn.dataset.tab; });
|
| 562 |
+
}));
|
| 563 |
+
|
| 564 |
+
// 초기 화면
|
| 565 |
+
syncScaleAvailability();
|
| 566 |
+
renderResults();
|
| 567 |
+
draw(createEpisode(2, 4, 3));
|
| 568 |
+
</script>
|
| 569 |
+
</body>
|
| 570 |
+
</html>
|