HANSOL commited on
Commit ยท
857bbdd
1
Parent(s): 0f8040e
Fix landform animations: barchan, U-valley, volcanoes, lava plateau; add Lab page, zone overlay
Browse files- app/components/animation_renderer.py +318 -0
- engine/ideal_landforms.py +620 -212
- engine/script_engine.py +18 -1
- pages/1_๐_Gallery.py +84 -36
- pages/3_๐งช_Lab.py +288 -0
app/components/animation_renderer.py
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
๐ฌ Plotly Animation Renderer
|
| 3 |
+
๋ถ๋๋ฌ์ด 3D ์งํ ์ ๋๋ฉ์ด์
(์นด๋ฉ๋ผ ์ ์ง)
|
| 4 |
+
"""
|
| 5 |
+
import numpy as np
|
| 6 |
+
import plotly.graph_objects as go
|
| 7 |
+
from typing import Callable
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def create_animated_terrain_figure(
|
| 11 |
+
landform_func: Callable,
|
| 12 |
+
grid_size: int = 80,
|
| 13 |
+
num_frames: int = 25,
|
| 14 |
+
title: str = "์งํ ํ์ฑ ๊ณผ์ ",
|
| 15 |
+
landform_type: str = "river"
|
| 16 |
+
) -> go.Figure:
|
| 17 |
+
"""Plotly ๋ค์ดํฐ๋ธ ์ ๋๋ฉ์ด์
์ผ๋ก ๋ถ๋๋ฌ์ด 3D ์งํ ์ ๋๋ฉ์ด์
์์ฑ
|
| 18 |
+
|
| 19 |
+
Args:
|
| 20 |
+
landform_func: ์งํ ์์ฑ ํจ์ (grid_size, stage) -> elevation
|
| 21 |
+
grid_size: ๊ทธ๋ฆฌ๋ ํฌ๊ธฐ
|
| 22 |
+
num_frames: ์ ๋๋ฉ์ด์
ํ๋ ์ ์ (๋ง์์๋ก ๋ถ๋๋ฌ์)
|
| 23 |
+
title: ๊ทธ๋ํ ์ ๋ชฉ
|
| 24 |
+
landform_type: ์งํ ์ ํ (colorscale ๊ฒฐ์ )
|
| 25 |
+
|
| 26 |
+
Returns:
|
| 27 |
+
go.Figure: ์ ๋๋ฉ์ด์
์ด ํฌํจ๋ Plotly Figure
|
| 28 |
+
"""
|
| 29 |
+
h, w = grid_size, grid_size
|
| 30 |
+
x = np.arange(w)
|
| 31 |
+
y = np.arange(h)
|
| 32 |
+
|
| 33 |
+
# ์ปฌ๋ฌ์ค์ผ์ผ ์ค์
|
| 34 |
+
colorscale = _get_colorscale(landform_type)
|
| 35 |
+
|
| 36 |
+
# ๋ชจ๋ ํ๋ ์ ๋ฏธ๋ฆฌ ์์ฑ
|
| 37 |
+
frames = []
|
| 38 |
+
all_elevations = []
|
| 39 |
+
|
| 40 |
+
for i in range(num_frames):
|
| 41 |
+
stage = i / (num_frames - 1)
|
| 42 |
+
|
| 43 |
+
try:
|
| 44 |
+
# return_metadata ์ง์ ์ฌ๋ถ ํ์ธ
|
| 45 |
+
result = landform_func(grid_size, stage)
|
| 46 |
+
if isinstance(result, tuple):
|
| 47 |
+
elevation = result[0]
|
| 48 |
+
else:
|
| 49 |
+
elevation = result
|
| 50 |
+
except:
|
| 51 |
+
elevation = landform_func(grid_size, stage)
|
| 52 |
+
|
| 53 |
+
all_elevations.append(elevation)
|
| 54 |
+
|
| 55 |
+
# Biome ๊ณ์ฐ (๊ฐ์ํ)
|
| 56 |
+
dy, dx = np.gradient(elevation)
|
| 57 |
+
slope = np.sqrt(dx**2 + dy**2)
|
| 58 |
+
biome = np.ones_like(elevation) # ๊ธฐ๋ณธ: ํ
|
| 59 |
+
biome[slope > 1.2] = 2 # ์์
|
| 60 |
+
biome[elevation < 5] = 0 # ๋ฌผ/๋ชจ๋
|
| 61 |
+
|
| 62 |
+
frames.append(go.Frame(
|
| 63 |
+
data=[go.Surface(
|
| 64 |
+
z=elevation,
|
| 65 |
+
x=x, y=y,
|
| 66 |
+
surfacecolor=biome,
|
| 67 |
+
colorscale=colorscale,
|
| 68 |
+
cmin=0, cmax=3,
|
| 69 |
+
showscale=False,
|
| 70 |
+
lighting=dict(ambient=0.4, diffuse=0.5, roughness=0.9, specular=0.1)
|
| 71 |
+
)],
|
| 72 |
+
name=f"{int(stage * 100)}%"
|
| 73 |
+
))
|
| 74 |
+
|
| 75 |
+
# ์ด๊ธฐ ํ๋ ์ (stage=0)
|
| 76 |
+
initial_elevation = all_elevations[0]
|
| 77 |
+
dy, dx = np.gradient(initial_elevation)
|
| 78 |
+
slope = np.sqrt(dx**2 + dy**2)
|
| 79 |
+
initial_biome = np.ones_like(initial_elevation)
|
| 80 |
+
initial_biome[slope > 1.2] = 2
|
| 81 |
+
initial_biome[initial_elevation < 5] = 0
|
| 82 |
+
|
| 83 |
+
fig = go.Figure(
|
| 84 |
+
data=[go.Surface(
|
| 85 |
+
z=initial_elevation,
|
| 86 |
+
x=x, y=y,
|
| 87 |
+
surfacecolor=initial_biome,
|
| 88 |
+
colorscale=colorscale,
|
| 89 |
+
cmin=0, cmax=3,
|
| 90 |
+
showscale=False,
|
| 91 |
+
lighting=dict(ambient=0.4, diffuse=0.5, roughness=0.9, specular=0.1)
|
| 92 |
+
)],
|
| 93 |
+
frames=frames
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
# ์ฌ๋ผ์ด๋ (ํ๋ ์ ์ด๋์ฉ)
|
| 97 |
+
sliders = [{
|
| 98 |
+
'active': 0,
|
| 99 |
+
'yanchor': 'top',
|
| 100 |
+
'xanchor': 'left',
|
| 101 |
+
'currentvalue': {
|
| 102 |
+
'font': {'size': 14, 'color': 'white'},
|
| 103 |
+
'prefix': 'ํ์ฑ ๋จ๊ณ: ',
|
| 104 |
+
'suffix': '',
|
| 105 |
+
'visible': True,
|
| 106 |
+
'xanchor': 'center'
|
| 107 |
+
},
|
| 108 |
+
'transition': {'duration': 50, 'easing': 'cubic-in-out'},
|
| 109 |
+
'pad': {'b': 10, 't': 50},
|
| 110 |
+
'len': 0.9,
|
| 111 |
+
'x': 0.05,
|
| 112 |
+
'y': 0,
|
| 113 |
+
'steps': [
|
| 114 |
+
{
|
| 115 |
+
'args': [[f.name], {'frame': {'duration': 50, 'redraw': True}, 'mode': 'immediate', 'transition': {'duration': 50}}],
|
| 116 |
+
'label': f.name,
|
| 117 |
+
'method': 'animate'
|
| 118 |
+
}
|
| 119 |
+
for f in frames
|
| 120 |
+
]
|
| 121 |
+
}]
|
| 122 |
+
|
| 123 |
+
# ์ฌ์/์ ์ง ๋ฒํผ
|
| 124 |
+
updatemenus = [{
|
| 125 |
+
'type': 'buttons',
|
| 126 |
+
'showactive': False,
|
| 127 |
+
'y': 1.15,
|
| 128 |
+
'x': 0.05,
|
| 129 |
+
'xanchor': 'left',
|
| 130 |
+
'yanchor': 'top',
|
| 131 |
+
'pad': {'t': 0, 'r': 10},
|
| 132 |
+
'buttons': [
|
| 133 |
+
{
|
| 134 |
+
'label': 'โถ๏ธ ์ฌ์',
|
| 135 |
+
'method': 'animate',
|
| 136 |
+
'args': [
|
| 137 |
+
None,
|
| 138 |
+
{
|
| 139 |
+
'frame': {'duration': 150, 'redraw': True},
|
| 140 |
+
'fromcurrent': True,
|
| 141 |
+
'transition': {'duration': 100, 'easing': 'quadratic-in-out'}
|
| 142 |
+
}
|
| 143 |
+
]
|
| 144 |
+
},
|
| 145 |
+
{
|
| 146 |
+
'label': 'โธ๏ธ ์ ์ง',
|
| 147 |
+
'method': 'animate',
|
| 148 |
+
'args': [
|
| 149 |
+
[None],
|
| 150 |
+
{
|
| 151 |
+
'frame': {'duration': 0, 'redraw': False},
|
| 152 |
+
'mode': 'immediate',
|
| 153 |
+
'transition': {'duration': 0}
|
| 154 |
+
}
|
| 155 |
+
]
|
| 156 |
+
},
|
| 157 |
+
{
|
| 158 |
+
'label': 'โฎ๏ธ ์ฒ์',
|
| 159 |
+
'method': 'animate',
|
| 160 |
+
'args': [
|
| 161 |
+
['0%'],
|
| 162 |
+
{
|
| 163 |
+
'frame': {'duration': 0, 'redraw': True},
|
| 164 |
+
'mode': 'immediate',
|
| 165 |
+
'transition': {'duration': 0}
|
| 166 |
+
}
|
| 167 |
+
]
|
| 168 |
+
}
|
| 169 |
+
]
|
| 170 |
+
}]
|
| 171 |
+
# ์งํ ์ ํ๋ณ ์ต์ ์นด๋ฉ๋ผ ๊ฐ๋
|
| 172 |
+
camera_settings = _get_optimal_camera(landform_type)
|
| 173 |
+
|
| 174 |
+
# ๋ ์ด์์
|
| 175 |
+
fig.update_layout(
|
| 176 |
+
title=dict(text=title, font=dict(color='white', size=16)),
|
| 177 |
+
scene=dict(
|
| 178 |
+
xaxis=dict(title='X (m)', backgroundcolor='#1a1a2e', gridcolor='#444', color='#cccccc'),
|
| 179 |
+
yaxis=dict(title='Y (m)', backgroundcolor='#1a1a2e', gridcolor='#444', color='#cccccc'),
|
| 180 |
+
zaxis=dict(title='Elevation', backgroundcolor='#1a1a2e', gridcolor='#444', color='#cccccc'),
|
| 181 |
+
bgcolor='#0e1117',
|
| 182 |
+
camera=camera_settings,
|
| 183 |
+
aspectmode='manual',
|
| 184 |
+
aspectratio=dict(x=1, y=1, z=0.4)
|
| 185 |
+
),
|
| 186 |
+
paper_bgcolor='#0e1117',
|
| 187 |
+
plot_bgcolor='#0e1117',
|
| 188 |
+
height=700,
|
| 189 |
+
margin=dict(l=10, r=10, t=80, b=80),
|
| 190 |
+
updatemenus=updatemenus,
|
| 191 |
+
sliders=sliders
|
| 192 |
+
)
|
| 193 |
+
|
| 194 |
+
return fig
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def _get_colorscale(landform_type: str):
|
| 198 |
+
"""์งํ ์ ํ์ ๋ฐ๋ฅธ ์ปฌ๋ฌ์ค์ผ์ผ ๋ฐํ"""
|
| 199 |
+
if landform_type == 'glacial':
|
| 200 |
+
return [
|
| 201 |
+
[0.0, '#4682B4'], [0.33, '#4682B4'],
|
| 202 |
+
[0.33, '#556B2F'], [0.66, '#556B2F'],
|
| 203 |
+
[0.66, '#808080'], [1.0, '#E0FFFF']
|
| 204 |
+
]
|
| 205 |
+
elif landform_type in ['river', 'coastal']:
|
| 206 |
+
return [
|
| 207 |
+
[0.0, '#4682B4'], [0.33, '#4682B4'],
|
| 208 |
+
[0.33, '#556B2F'], [0.66, '#556B2F'],
|
| 209 |
+
[0.66, '#808080'], [1.0, '#D2B48C']
|
| 210 |
+
]
|
| 211 |
+
elif landform_type == 'arid':
|
| 212 |
+
return [
|
| 213 |
+
[0.0, '#EDC9AF'], [0.33, '#EDC9AF'],
|
| 214 |
+
[0.33, '#CD853F'], [0.66, '#CD853F'],
|
| 215 |
+
[0.66, '#808080'], [1.0, '#DAA520']
|
| 216 |
+
]
|
| 217 |
+
else:
|
| 218 |
+
return [
|
| 219 |
+
[0.0, '#E6C288'], [0.33, '#E6C288'],
|
| 220 |
+
[0.33, '#556B2F'], [0.66, '#556B2F'],
|
| 221 |
+
[0.66, '#808080'], [1.0, '#A0522D']
|
| 222 |
+
]
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def _get_optimal_camera(landform_type: str) -> dict:
|
| 226 |
+
"""์งํ ์ ํ๋ณ ์ต์ ์นด๋ฉ๋ผ ๊ฐ๋ ๋ฐํ
|
| 227 |
+
|
| 228 |
+
๊ฐ ์งํ ์ ํ์ ํ์ฑ ๊ณผ์ ์ด ์ ๋ณด์ด๋ ๊ฐ๋๋ก ์ค์
|
| 229 |
+
"""
|
| 230 |
+
if landform_type == 'river':
|
| 231 |
+
# ํ์ฒ/์ ์์ง: ์ฐ์ชฝ(์๋ฅ)์์ ํ์ง(ํ๋ฅ) ๋ฐฉํฅ์ผ๋ก ๋ด๋ ค๋ค๋ด
|
| 232 |
+
# ์ ์์ง๊ฐ ๋ถ์ฑ๊ผด๋ก ํผ์ณ์ง๋ ๋ชจ์ต์ด ์ ๋ณด์ด๋ ๊ฐ๋
|
| 233 |
+
return dict(
|
| 234 |
+
eye=dict(x=-0.3, y=-2.2, z=1.8),
|
| 235 |
+
center=dict(x=0, y=0.2, z=-0.2),
|
| 236 |
+
up=dict(x=0, y=0, z=1)
|
| 237 |
+
)
|
| 238 |
+
elif landform_type == 'glacial':
|
| 239 |
+
# ๋นํ: ์์์ ๋ด๋ ค๋ค๋ณด๋ ๊ฐ๋๋ก U์๊ณก/๊ถ๊ณก ์ ๋ณด์ด๊ฒ
|
| 240 |
+
return dict(
|
| 241 |
+
eye=dict(x=0.8, y=-1.5, z=1.5),
|
| 242 |
+
center=dict(x=0, y=0, z=-0.2),
|
| 243 |
+
up=dict(x=0, y=0, z=1)
|
| 244 |
+
)
|
| 245 |
+
elif landform_type == 'volcanic':
|
| 246 |
+
# ํ์ฐ: ์ธก๋ฉด์์ ๋ด์ ์ฐ์ฒด ํํ ์ ๋ณด์ด๊ฒ
|
| 247 |
+
return dict(
|
| 248 |
+
eye=dict(x=1.8, y=-1.2, z=0.8),
|
| 249 |
+
center=dict(x=0, y=0, z=0),
|
| 250 |
+
up=dict(x=0, y=0, z=1)
|
| 251 |
+
)
|
| 252 |
+
elif landform_type == 'coastal':
|
| 253 |
+
# ํด์: ๋ฐ๋คโ์ก์ง ๋ฐฉํฅ์ผ๋ก ์ ๋ฒฝ ์ ๋ณด์ด๊ฒ
|
| 254 |
+
return dict(
|
| 255 |
+
eye=dict(x=0.5, y=2.0, z=0.8),
|
| 256 |
+
center=dict(x=0, y=0, z=-0.1),
|
| 257 |
+
up=dict(x=0, y=0, z=1)
|
| 258 |
+
)
|
| 259 |
+
elif landform_type == 'arid':
|
| 260 |
+
# ๊ฑด์กฐ: ์ฌ๊ตฌ ํํ ์ ๋ณด์ด๊ฒ ๋ฎ์ ๊ฐ๋
|
| 261 |
+
return dict(
|
| 262 |
+
eye=dict(x=2.0, y=-1.0, z=0.6),
|
| 263 |
+
center=dict(x=0, y=0, z=-0.1),
|
| 264 |
+
up=dict(x=0, y=0, z=1)
|
| 265 |
+
)
|
| 266 |
+
elif landform_type == 'karst':
|
| 267 |
+
# ์นด๋ฅด์คํธ: ์์์ ๋๋ฆฌ๋ค/์ฐ๋ฐ๋ผ ์ ๋ณด์ด๊ฒ
|
| 268 |
+
return dict(
|
| 269 |
+
eye=dict(x=1.0, y=-1.0, z=1.8),
|
| 270 |
+
center=dict(x=0, y=0, z=-0.2),
|
| 271 |
+
up=dict(x=0, y=0, z=1)
|
| 272 |
+
)
|
| 273 |
+
else:
|
| 274 |
+
# ๊ธฐ๋ณธ๊ฐ: ๋๊ฐ์ ๋ฐฉํฅ
|
| 275 |
+
return dict(
|
| 276 |
+
eye=dict(x=1.5, y=-1.5, z=1.0),
|
| 277 |
+
center=dict(x=0, y=0, z=-0.1),
|
| 278 |
+
up=dict(x=0, y=0, z=1)
|
| 279 |
+
)
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
def get_multi_angle_cameras() -> dict:
|
| 283 |
+
"""๋ค์ค ์์ ์นด๋ฉ๋ผ ํ๋ฆฌ์
|
| 284 |
+
|
| 285 |
+
X์ถ(์ ๋ฉด), Y์ถ(์ธก๋ฉด), Z์ถ(ํ๋ฉด๋), ๋ฑ๊ฐํฌ์ 4๊ฐ์ง ์์
|
| 286 |
+
"""
|
| 287 |
+
return {
|
| 288 |
+
"๐ฏ ๋ฑ๊ฐ (๊ธฐ๋ณธ)": dict(
|
| 289 |
+
eye=dict(x=1.5, y=-1.5, z=1.2),
|
| 290 |
+
center=dict(x=0, y=0, z=-0.1),
|
| 291 |
+
up=dict(x=0, y=0, z=1)
|
| 292 |
+
),
|
| 293 |
+
"โก๏ธ X์ถ (์ธก๋ฉด)": dict(
|
| 294 |
+
eye=dict(x=2.5, y=0, z=0.3),
|
| 295 |
+
center=dict(x=0, y=0, z=0),
|
| 296 |
+
up=dict(x=0, y=0, z=1)
|
| 297 |
+
),
|
| 298 |
+
"โฌ๏ธ Y์ถ (์ ๋ฉด)": dict(
|
| 299 |
+
eye=dict(x=0, y=-2.5, z=0.3),
|
| 300 |
+
center=dict(x=0, y=0, z=0),
|
| 301 |
+
up=dict(x=0, y=0, z=1)
|
| 302 |
+
),
|
| 303 |
+
"โฌ๏ธ Z์ถ (ํ๋ฉด๋)": dict(
|
| 304 |
+
eye=dict(x=0, y=0, z=2.5),
|
| 305 |
+
center=dict(x=0, y=0, z=0),
|
| 306 |
+
up=dict(x=0, y=1, z=0)
|
| 307 |
+
),
|
| 308 |
+
"๐ ๋๊ฐ์ ๋ฎ์": dict(
|
| 309 |
+
eye=dict(x=2.0, y=-2.0, z=0.5),
|
| 310 |
+
center=dict(x=0, y=0, z=-0.1),
|
| 311 |
+
up=dict(x=0, y=0, z=1)
|
| 312 |
+
),
|
| 313 |
+
"๐ ์๋ฅโํ๋ฅ": dict(
|
| 314 |
+
eye=dict(x=-0.3, y=-2.5, z=1.5),
|
| 315 |
+
center=dict(x=0, y=0.2, z=-0.2),
|
| 316 |
+
up=dict(x=0, y=0, z=1)
|
| 317 |
+
)
|
| 318 |
+
}
|
engine/ideal_landforms.py
CHANGED
|
@@ -722,80 +722,150 @@ def create_meander_animated(grid_size: int, stage: float,
|
|
| 722 |
|
| 723 |
|
| 724 |
def create_u_valley_animated(grid_size: int, stage: float,
|
| 725 |
-
valley_depth: float = 100.0, valley_width: float = 0.4
|
| 726 |
-
|
|
|
|
| 727 |
|
| 728 |
-
Stage 0
|
| 729 |
-
Stage 0.
|
| 730 |
-
Stage 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 731 |
"""
|
| 732 |
h, w = grid_size, grid_size
|
| 733 |
elevation = np.zeros((h, w))
|
| 734 |
center = w // 2
|
| 735 |
|
| 736 |
-
#
|
| 737 |
-
if stage < 0.
|
| 738 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 739 |
else:
|
| 740 |
-
|
|
|
|
|
|
|
| 741 |
|
| 742 |
-
|
|
|
|
| 743 |
|
|
|
|
| 744 |
for r in range(h):
|
|
|
|
|
|
|
|
|
|
| 745 |
for c in range(w):
|
| 746 |
dx = abs(c - center)
|
| 747 |
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
|
|
|
| 751 |
else:
|
| 752 |
-
#
|
| 753 |
-
|
| 754 |
-
v_height = valley_depth * normalized_x # V shape
|
| 755 |
-
u_height = valley_depth * (normalized_x ** 2) # U shape
|
| 756 |
-
elevation[r, c] = v_height * (1 - u_factor) + u_height * u_factor
|
| 757 |
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
|
|
|
| 767 |
|
| 768 |
-
|
| 769 |
-
|
| 770 |
-
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 782 |
|
| 783 |
-
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
elevation[r, c] += glacier_thickness
|
| 791 |
-
else:
|
| 792 |
-
# ํํด ์ค: ๋นํ ๋์ด ๊ฐ์
|
| 793 |
-
retreat_factor = (stage - 0.6) / 0.4
|
| 794 |
-
elevation[r, c] += glacier_thickness * (1 - retreat_factor)
|
| 795 |
|
| 796 |
return elevation
|
| 797 |
|
| 798 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 799 |
def create_coastal_cliff_animated(grid_size: int, stage: float,
|
| 800 |
cliff_height: float = 30.0, num_stacks: int = 2) -> np.ndarray:
|
| 801 |
"""ํด์ ์ ๋ฒฝ ํํด ๊ณผ์ """
|
|
@@ -880,15 +950,18 @@ def create_v_valley_animated(grid_size: int, stage: float,
|
|
| 880 |
|
| 881 |
|
| 882 |
def create_barchan_animated(grid_size: int, stage: float,
|
| 883 |
-
num_dunes: int = 3) -> np.ndarray:
|
| 884 |
-
"""๋ฐ๋ฅดํ ์ฌ๊ตฌ
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
|
|
|
|
|
|
|
|
|
| 892 |
"""
|
| 893 |
h, w = grid_size, grid_size
|
| 894 |
elevation = np.zeros((h, w))
|
|
@@ -898,75 +971,127 @@ def create_barchan_animated(grid_size: int, stage: float,
|
|
| 898 |
|
| 899 |
np.random.seed(42)
|
| 900 |
|
| 901 |
-
# ์ฌ๊ตฌ ์ด๋
|
| 902 |
-
move_distance = int(h * 0.5 * stage)
|
| 903 |
-
|
| 904 |
for i in range(num_dunes):
|
| 905 |
-
# ์์น
|
| 906 |
-
initial_y = h // 5 + i * (h // (num_dunes + 1))
|
| 907 |
cx = w // 4 + (i % 2) * (w // 2)
|
| 908 |
-
cy =
|
| 909 |
|
| 910 |
-
if cy >= h -
|
| 911 |
continue
|
| 912 |
|
| 913 |
-
#
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 918 |
|
| 919 |
for r in range(h):
|
| 920 |
for c in range(w):
|
| 921 |
dy = r - cy
|
| 922 |
dx = c - cx
|
| 923 |
|
| 924 |
-
|
| 925 |
-
dist_outer = np.sqrt(dx**2 + dy**2)
|
| 926 |
-
|
| 927 |
-
# ์์ชฝ ์ (์ค๋ชฉ๋ฉด - ํ๋จ์ผ๋ก ์คํ์
)
|
| 928 |
-
dist_inner = np.sqrt(dx**2 + (dy - inner_offset)**2)
|
| 929 |
-
|
| 930 |
-
# ์ด์น๋ฌ ์์ญ: ๋ฐ๊นฅ ์ ์ AND ์์ชฝ ์ ๋ฐ
|
| 931 |
-
in_crescent = (dist_outer < outer_r) and (dist_inner > inner_r)
|
| 932 |
|
| 933 |
-
|
| 934 |
-
|
| 935 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 936 |
|
| 937 |
-
#
|
|
|
|
|
|
|
|
|
|
| 938 |
if dy < 0:
|
| 939 |
-
# ๋ฐ๋๋ฐ์ด: ์๋ง
|
| 940 |
-
|
| 941 |
else:
|
| 942 |
-
# ๋ฐ๋๊ทธ๋:
|
| 943 |
-
|
| 944 |
|
| 945 |
-
z =
|
| 946 |
-
|
| 947 |
-
|
| 948 |
-
# ๋ฟ (horn) - ์์ชฝ์ผ๋ก ๋ฐ๋ ๋ฐฉํฅ์ผ๋ก ๋ป์
|
| 949 |
-
horn_width = outer_r * 0.3
|
| 950 |
-
horn_length = outer_r * 0.8
|
| 951 |
|
| 952 |
-
|
| 953 |
-
|
| 954 |
-
|
| 955 |
-
|
| 956 |
-
|
| 957 |
-
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
if abs(dx_horn) < horn_width and 0 < dy_horn < horn_length:
|
| 961 |
-
# ๋ฟ ๋์ด: ๋์ผ๋ก ๊ฐ์๋ก ๋ฎ์์ง
|
| 962 |
-
horn_factor = 1 - dy_horn / horn_length
|
| 963 |
-
width_factor = 1 - abs(dx_horn) / horn_width
|
| 964 |
-
z = dune_height * 0.5 * horn_factor * width_factor
|
| 965 |
|
| 966 |
-
|
| 967 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 968 |
|
| 969 |
return elevation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 970 |
# ============================================
|
| 971 |
# ํ์ฅ ์งํ (Extended Landforms)
|
| 972 |
# ============================================
|
|
@@ -1605,88 +1730,318 @@ def _get_horn_stage_desc(stage: float) -> str:
|
|
| 1605 |
|
| 1606 |
|
| 1607 |
def create_shield_volcano(grid_size: int = 100, stage: float = 1.0,
|
| 1608 |
-
max_height: float = 40.0) -> np.ndarray:
|
| 1609 |
-
"""์์ํ์ฐ (Shield Volcano) -
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1610 |
h, w = grid_size, grid_size
|
| 1611 |
elevation = np.zeros((h, w))
|
| 1612 |
|
| 1613 |
center = (h // 2, w // 2)
|
| 1614 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1615 |
|
| 1616 |
for r in range(h):
|
| 1617 |
for c in range(w):
|
| 1618 |
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1619 |
|
| 1620 |
-
if dist <
|
| 1621 |
-
# ์๋งํ ํฌ๋ฌผ์ ํํ (๊ฒฝ์ฌ 5-10๋)
|
| 1622 |
-
|
| 1623 |
-
|
| 1624 |
-
|
| 1625 |
-
|
| 1626 |
-
|
| 1627 |
-
|
| 1628 |
-
|
| 1629 |
-
|
| 1630 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1631 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1632 |
return elevation
|
| 1633 |
|
| 1634 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1635 |
def create_stratovolcano(grid_size: int = 100, stage: float = 1.0,
|
| 1636 |
-
max_height: float = 80.0) -> np.ndarray:
|
| 1637 |
-
"""์ฑ์ธตํ์ฐ (Stratovolcano) -
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1638 |
h, w = grid_size, grid_size
|
| 1639 |
elevation = np.zeros((h, w))
|
| 1640 |
|
| 1641 |
center = (h // 2, w // 2)
|
| 1642 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1643 |
|
| 1644 |
for r in range(h):
|
| 1645 |
for c in range(w):
|
| 1646 |
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1647 |
|
| 1648 |
-
if dist <
|
| 1649 |
# ๊ธํ ์๋ฟ (๊ฒฝ์ฌ 25-35๋)
|
| 1650 |
-
|
| 1651 |
-
|
| 1652 |
-
|
| 1653 |
-
|
| 1654 |
-
|
| 1655 |
-
|
| 1656 |
-
|
| 1657 |
-
|
| 1658 |
-
|
| 1659 |
-
|
| 1660 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1661 |
return elevation
|
| 1662 |
|
| 1663 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1664 |
def create_caldera(grid_size: int = 100, stage: float = 1.0,
|
| 1665 |
-
rim_height: float = 50.0) -> np.ndarray:
|
| 1666 |
-
"""์นผ๋ฐ๋ผ (Caldera) - ํ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1667 |
h, w = grid_size, grid_size
|
| 1668 |
elevation = np.zeros((h, w))
|
| 1669 |
|
| 1670 |
center = (h // 2, w // 2)
|
| 1671 |
-
|
| 1672 |
-
caldera_radius = int(w * 0.3)
|
| 1673 |
|
| 1674 |
-
|
| 1675 |
-
|
| 1676 |
-
|
| 1677 |
-
|
| 1678 |
-
|
| 1679 |
-
|
| 1680 |
-
|
| 1681 |
-
|
| 1682 |
-
|
| 1683 |
-
|
| 1684 |
-
|
| 1685 |
-
elevation[r, c] =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1686 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1687 |
return elevation
|
| 1688 |
|
| 1689 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1690 |
def create_mesa_butte(grid_size: int = 100, stage: float = 1.0,
|
| 1691 |
num_mesas: int = 2) -> np.ndarray:
|
| 1692 |
"""๋ฉ์ฌ/๋ทฐํธ (Mesa/Butte) - ํ์์ง"""
|
|
@@ -2323,80 +2678,133 @@ def create_crater_lake(grid_size: int = 100, stage: float = 1.0,
|
|
| 2323 |
return elevation
|
| 2324 |
|
| 2325 |
|
| 2326 |
-
def create_lava_plateau(grid_size: int = 100, stage: float = 1.0
|
| 2327 |
-
|
|
|
|
| 2328 |
|
| 2329 |
-
Stage 0
|
| 2330 |
-
Stage 0.
|
| 2331 |
-
Stage 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2332 |
"""
|
| 2333 |
h, w = grid_size, grid_size
|
| 2334 |
elevation = np.zeros((h, w))
|
|
|
|
| 2335 |
center = w // 2
|
| 2336 |
|
| 2337 |
# ๊ธฐ๋ฐ ๊ณ ์ ๋์ด
|
| 2338 |
plateau_base = 30.0
|
| 2339 |
|
| 2340 |
-
if stage < 0.
|
| 2341 |
-
# ์๋ V์๊ณก
|
| 2342 |
-
|
| 2343 |
-
|
| 2344 |
-
|
| 2345 |
-
|
| 2346 |
-
|
| 2347 |
-
|
| 2348 |
-
|
| 2349 |
-
|
| 2350 |
-
|
| 2351 |
-
# ์ ํ๊ณก ํ์ฑ
|
| 2352 |
-
v_factor = 0.0 # ์๋ V์๊ณก ์์ ํ ๋ฎ์
|
| 2353 |
-
lava_fill = 1.0
|
| 2354 |
-
new_valley = (stage - 0.6) / 0.4 # ์ ํ๊ณก ๋ฐ๋ฌ
|
| 2355 |
-
|
| 2356 |
-
for r in range(h):
|
| 2357 |
-
for c in range(w):
|
| 2358 |
-
dx = abs(c - center)
|
| 2359 |
-
|
| 2360 |
-
# ๊ธฐ๋ณธ ๊ณ ์
|
| 2361 |
-
elevation[r, c] = plateau_base
|
| 2362 |
-
|
| 2363 |
-
# ์๋ V์๊ณก (์ดํ๋ถ์ถ ์ )
|
| 2364 |
-
if v_factor > 0:
|
| 2365 |
-
valley_depth = 25.0 * v_factor
|
| 2366 |
-
if dx < 15:
|
| 2367 |
-
v_shape = valley_depth * (1 - dx / 15)
|
| 2368 |
elevation[r, c] -= v_shape
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2369 |
|
| 2370 |
-
|
| 2371 |
-
|
| 2372 |
-
|
| 2373 |
-
|
| 2374 |
-
|
| 2375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2376 |
|
| 2377 |
-
|
| 2378 |
-
|
| 2379 |
-
|
| 2380 |
-
|
| 2381 |
-
|
|
|
|
|
|
|
| 2382 |
|
| 2383 |
-
|
| 2384 |
-
|
| 2385 |
-
|
| 2386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2387 |
|
| 2388 |
-
|
| 2389 |
-
|
| 2390 |
-
|
| 2391 |
-
|
| 2392 |
-
|
| 2393 |
-
|
| 2394 |
-
|
| 2395 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2397 |
return elevation
|
| 2398 |
|
| 2399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2400 |
def create_coastal_dune(grid_size: int = 100, stage: float = 1.0,
|
| 2401 |
num_dunes: int = 3) -> np.ndarray:
|
| 2402 |
"""ํด์์ฌ๊ตฌ (Coastal Dune) - ํด์๊ฐ ๋ชจ๋ ์ธ๋"""
|
|
|
|
| 722 |
|
| 723 |
|
| 724 |
def create_u_valley_animated(grid_size: int, stage: float,
|
| 725 |
+
valley_depth: float = 100.0, valley_width: float = 0.4,
|
| 726 |
+
return_metadata: bool = False) -> np.ndarray:
|
| 727 |
+
"""U์๊ณก ํ์ฑ๊ณผ์ (V์๊ณก โ ๋นํ ์นจ์ โ U์๊ณก ๋
ธ์ถ)
|
| 728 |
|
| 729 |
+
Stage 0~0.2: V์๊ณก ์ํ (ํ์ฒ ์นจ์์ ์ํด ํ์ฑ๋ ์ด๊ธฐ ๊ณ๊ณก)
|
| 730 |
+
Stage 0.2~0.5: ๋นํ ์ฑ์์ง + ์นจ์ ์์ (ํ๋ฌํน, ๋ง์)
|
| 731 |
+
Stage 0.5~0.8: U์ ํํ ๋ฐ๋ฌ (๋ฐ๋ฅ ๋์ด์ง, ๋ฒฝ ๊ธ๊ฒฝ์ฌ)
|
| 732 |
+
Stage 0.8~1.0: ๋นํ ํํด โ U์๊ณก ๋๋ฌ๋จ + ํ์๊ณก + ๋นํํธ
|
| 733 |
+
|
| 734 |
+
ํต์ฌ ๊ณผ์ :
|
| 735 |
+
- ํ๋ฌํน(Plucking): ์์ ํ์ ํ ์ด๋ฐ
|
| 736 |
+
- ๋ง์(Abrasion): ๋นํ ๋ฐ๋ฅ ์ฐ๋ง
|
| 737 |
+
- ํ์๊ณก(Hanging Valley): ์ง๋ฅ ๋นํ๊ฐ ๋ ์นจ์
|
| 738 |
"""
|
| 739 |
h, w = grid_size, grid_size
|
| 740 |
elevation = np.zeros((h, w))
|
| 741 |
center = w // 2
|
| 742 |
|
| 743 |
+
# Stage์ ๋ฐ๋ฅธ U์ ๋ณํ ์ ๋
|
| 744 |
+
if stage < 0.2:
|
| 745 |
+
# V์๊ณก ์ํ
|
| 746 |
+
u_transform = 0
|
| 747 |
+
glacier_visible = False
|
| 748 |
+
elif stage < 0.5:
|
| 749 |
+
# ๋นํ ์ฑ์ฅ + ์ด๊ธฐ ์นจ์
|
| 750 |
+
u_transform = (stage - 0.2) / 0.3 * 0.5
|
| 751 |
+
glacier_visible = True
|
| 752 |
+
elif stage < 0.8:
|
| 753 |
+
# U์ ํํ ๋ฐ๋ฌ
|
| 754 |
+
u_transform = 0.5 + (stage - 0.5) / 0.3 * 0.5
|
| 755 |
+
glacier_visible = True
|
| 756 |
else:
|
| 757 |
+
# ๋นํ ํํด, U์๊ณก ๋
ธ์ถ
|
| 758 |
+
u_transform = 1.0
|
| 759 |
+
glacier_visible = False
|
| 760 |
|
| 761 |
+
# U์ ๋ฐ๋ฅ ๋๋น (์ ์ฐจ ๋์ด์ง)
|
| 762 |
+
floor_width = int(w * valley_width * 0.3 * u_transform)
|
| 763 |
|
| 764 |
+
# ๊ธฐ๋ณธ ์งํ ์์ฑ
|
| 765 |
for r in range(h):
|
| 766 |
+
# ์๋ฅ๋ก ๊ฐ์๋ก ๊ธฐ๋ฐ ๋์์ง
|
| 767 |
+
base_height = (h - r) / h * 40.0
|
| 768 |
+
|
| 769 |
for c in range(w):
|
| 770 |
dx = abs(c - center)
|
| 771 |
|
| 772 |
+
# V์๊ณก โ U์๊ณก ๋จ๋ฉด ๋ณํ
|
| 773 |
+
if dx < floor_width:
|
| 774 |
+
# U์ ๋ฐ๋ฅ (ํํ)
|
| 775 |
+
valley_floor = 0
|
| 776 |
else:
|
| 777 |
+
# ๋ฒฝ๋ฉด
|
| 778 |
+
wall_dist = (dx - floor_width) / max(1, w // 2 - floor_width)
|
|
|
|
|
|
|
|
|
|
| 779 |
|
| 780 |
+
# V์ ๋จ๋ฉด (์ผ๊ฐํ)
|
| 781 |
+
v_profile = valley_depth * wall_dist
|
| 782 |
+
|
| 783 |
+
# U์ ๋จ๋ฉด (ํฌ๋ฌผ์ )
|
| 784 |
+
u_profile = valley_depth * (wall_dist ** 0.5)
|
| 785 |
+
|
| 786 |
+
# ๋ณํ ์ ์ฉ
|
| 787 |
+
valley_floor = v_profile * (1 - u_transform) + u_profile * u_transform
|
| 788 |
+
|
| 789 |
+
elevation[r, c] = base_height + valley_floor
|
| 790 |
|
| 791 |
+
# ํ์๊ณก (Hanging Valley) - stage 0.6 ์ดํ ์๊ฐํ
|
| 792 |
+
if stage > 0.6:
|
| 793 |
+
hanging_valleys = [
|
| 794 |
+
(int(h * 0.3), -1), # ์ข์ธก ํ์๊ณก
|
| 795 |
+
(int(h * 0.6), 1), # ์ฐ์ธก ํ์๊ณก
|
| 796 |
+
]
|
| 797 |
+
|
| 798 |
+
for hy, side in hanging_valleys:
|
| 799 |
+
hx = center + side * int(w * 0.35)
|
| 800 |
+
hang_height = 30.0 * u_transform # ํ์ ๋์ด
|
| 801 |
+
|
| 802 |
+
for dy in range(-10, 11):
|
| 803 |
+
for dx in range(-8, 9):
|
| 804 |
+
r, c = hy + dy, hx + dx
|
| 805 |
+
if 0 <= r < h and 0 <= c < w:
|
| 806 |
+
dist = np.sqrt(dy**2 + dx**2)
|
| 807 |
+
if dist < 10:
|
| 808 |
+
# ํ์๊ณก ์
๊ตฌ (๋๊ฒ ๋งค๋ฌ๋ฆผ)
|
| 809 |
+
notch = 10.0 * (1 - dist / 10)
|
| 810 |
+
elevation[r, c] = max(elevation[r, c], hang_height + notch)
|
| 811 |
+
|
| 812 |
+
# ๋นํ ์๊ฐํ (์ฑ์)
|
| 813 |
+
if glacier_visible:
|
| 814 |
+
glacier_progress = min(1.0, (stage - 0.2) / 0.6)
|
| 815 |
+
glacier_end = int(h * 0.85 * glacier_progress)
|
| 816 |
+
glacier_thickness = 25.0 * glacier_progress
|
| 817 |
+
|
| 818 |
+
for r in range(glacier_end):
|
| 819 |
+
for c in range(w):
|
| 820 |
+
dx = abs(c - center)
|
| 821 |
+
if dx < floor_width + 10:
|
| 822 |
+
# ๋นํ ๋ณผ๋ก ํ๋ฉด
|
| 823 |
+
ice_surface = glacier_thickness * (1 - (dx / (floor_width + 10)) ** 2)
|
| 824 |
+
if stage < 0.8:
|
| 825 |
+
elevation[r, c] += ice_surface
|
| 826 |
+
|
| 827 |
+
# ๋นํํธ(Tarn) - ๋นํ ํํด ํ
|
| 828 |
+
if stage > 0.85:
|
| 829 |
+
tarn_progress = (stage - 0.85) / 0.15
|
| 830 |
+
tarn_y = int(h * 0.15)
|
| 831 |
+
tarn_radius = int(w * 0.12 * tarn_progress)
|
| 832 |
+
|
| 833 |
+
for dy in range(-tarn_radius, tarn_radius + 1):
|
| 834 |
+
for dx in range(-tarn_radius, tarn_radius + 1):
|
| 835 |
+
r, c = tarn_y + dy, center + dx
|
| 836 |
+
if 0 <= r < h and 0 <= c < w:
|
| 837 |
+
dist = np.sqrt(dy**2 + dx**2)
|
| 838 |
+
if dist < tarn_radius:
|
| 839 |
+
# ํธ์ ๋ฐ๋ฅ
|
| 840 |
+
elevation[r, c] = min(elevation[r, c], -5.0 * (1 - dist / tarn_radius))
|
| 841 |
|
| 842 |
+
if return_metadata:
|
| 843 |
+
return elevation, {
|
| 844 |
+
'u_transform': u_transform,
|
| 845 |
+
'glacier_visible': glacier_visible,
|
| 846 |
+
'floor_width': floor_width,
|
| 847 |
+
'stage_description': _get_u_valley_stage_desc(stage)
|
| 848 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 849 |
|
| 850 |
return elevation
|
| 851 |
|
| 852 |
|
| 853 |
+
def _get_u_valley_stage_desc(stage: float) -> str:
|
| 854 |
+
"""U์๊ณก ๋จ๊ณ๋ณ ์ค๋ช
"""
|
| 855 |
+
if stage < 0.15:
|
| 856 |
+
return "๐๏ธ V์๊ณก ์ํ: ํ์ฒ ์นจ์์ ์ํ ์ด๊ธฐ ๊ณ๊ณก"
|
| 857 |
+
elif stage < 0.35:
|
| 858 |
+
return "โ๏ธ ๋นํ ์ฑ์ฅ: ๊ณ๊ณก์ ๋นํ ์ฑ์์ง"
|
| 859 |
+
elif stage < 0.55:
|
| 860 |
+
return "โ๏ธ ๋นํ ์นจ์: ํ๋ฌํน + ๋ง์ โ ๋ฐ๋ฅ ํ์ฅ"
|
| 861 |
+
elif stage < 0.75:
|
| 862 |
+
return "๐ป U์ ํํ: ํํ ๋ฐ๋ฅ + ๊ธ๊ฒฝ์ฌ ๋ฒฝ"
|
| 863 |
+
elif stage < 0.9:
|
| 864 |
+
return "๐ ๋นํ ํํด: ํ์๊ณก(Hanging Valley) ๋๋ฌ๋จ"
|
| 865 |
+
else:
|
| 866 |
+
return "๐ง ๋นํํธ(Tarn): ๋นํ ์ตํด์ ๊ณ ์"
|
| 867 |
+
|
| 868 |
+
|
| 869 |
def create_coastal_cliff_animated(grid_size: int, stage: float,
|
| 870 |
cliff_height: float = 30.0, num_stacks: int = 2) -> np.ndarray:
|
| 871 |
"""ํด์ ์ ๋ฒฝ ํํด ๊ณผ์ """
|
|
|
|
| 950 |
|
| 951 |
|
| 952 |
def create_barchan_animated(grid_size: int, stage: float,
|
| 953 |
+
num_dunes: int = 3, return_metadata: bool = False) -> np.ndarray:
|
| 954 |
+
"""๋ฐ๋ฅดํ ์ฌ๊ตฌ ํ์ฑ ๊ณผ์ ์ ๋๋ฉ์ด์
|
| 955 |
+
|
| 956 |
+
Stage 0~0.25: ๋ชจ๋ ์ถ์ (์์ ์ํ ์ธ๋ ํ์ฑ)
|
| 957 |
+
Stage 0.25~0.5: ๋น๋์นญ ๋ฐ๋ฌ (๋ฐ๋๋ฐ์ด ์๊ฒฝ์ฌ, ๋ฐ๋๊ทธ๋ ๊ธ๊ฒฝ์ฌ)
|
| 958 |
+
Stage 0.5~0.75: ์ด์น๋ฌ ํํ ๋ฐ๋ฌ (์ค๋ชฉ๋ฉด ํ์ฑ)
|
| 959 |
+
Stage 0.75~1.0: ๋ฟ(horn) ์์ฑ (๋ฐ๋ ๋ฐฉํฅ์ผ๋ก ์ฐ์ฅ)
|
| 960 |
+
|
| 961 |
+
ํ์ฑ ์๋ฆฌ:
|
| 962 |
+
- ๋ฐ๋์ด ๋ชจ๋๋ฅผ ๋ฐ๋๋ฐ์ด ์ฌ๋ฉด์ผ๋ก ์ด๋ฐ
|
| 963 |
+
- ์ ์ ๋์ด ๋ฐ๋๊ทธ๋์ ํด์ (๋์ฌ๋ฉด, slip face)
|
| 964 |
+
- ๊ฐ์ฅ์๋ฆฌ ๋ชจ๋๊ฐ ๋ ๋นจ๋ฆฌ ์ด๋ โ ๋ฟ ํ์ฑ
|
| 965 |
"""
|
| 966 |
h, w = grid_size, grid_size
|
| 967 |
elevation = np.zeros((h, w))
|
|
|
|
| 971 |
|
| 972 |
np.random.seed(42)
|
| 973 |
|
|
|
|
|
|
|
|
|
|
| 974 |
for i in range(num_dunes):
|
| 975 |
+
# ์ฌ๊ตฌ ์์น (๊ณ ์ )
|
|
|
|
| 976 |
cx = w // 4 + (i % 2) * (w // 2)
|
| 977 |
+
cy = int(h * 0.3) + i * (h // (num_dunes + 1))
|
| 978 |
|
| 979 |
+
if cy >= h - 15:
|
| 980 |
continue
|
| 981 |
|
| 982 |
+
# Stage์ ๋ฐ๋ฅธ ํฌ๊ธฐ ๋ฐ๋ฌ
|
| 983 |
+
max_height = 12.0 + i * 3.0
|
| 984 |
+
max_radius = int(w * 0.12)
|
| 985 |
+
|
| 986 |
+
# Stage 0~0.25: ์์ ์ํ ์ธ๋
|
| 987 |
+
if stage < 0.25:
|
| 988 |
+
progress = stage / 0.25
|
| 989 |
+
current_height = max_height * 0.3 * progress
|
| 990 |
+
current_radius = int(max_radius * 0.4 * progress)
|
| 991 |
+
asymmetry = 0 # ๋์นญ
|
| 992 |
+
horn_length = 0
|
| 993 |
+
|
| 994 |
+
# Stage 0.25~0.5: ๋น๋์นญ ๋ฐ๋ฌ
|
| 995 |
+
elif stage < 0.5:
|
| 996 |
+
progress = (stage - 0.25) / 0.25
|
| 997 |
+
current_height = max_height * (0.3 + 0.4 * progress)
|
| 998 |
+
current_radius = int(max_radius * (0.4 + 0.3 * progress))
|
| 999 |
+
asymmetry = progress # ์ ์ฐจ ๋น๋์นญ
|
| 1000 |
+
horn_length = 0
|
| 1001 |
+
|
| 1002 |
+
# Stage 0.5~0.75: ์ด์น๋ฌ ํํ
|
| 1003 |
+
elif stage < 0.75:
|
| 1004 |
+
progress = (stage - 0.5) / 0.25
|
| 1005 |
+
current_height = max_height * (0.7 + 0.2 * progress)
|
| 1006 |
+
current_radius = int(max_radius * (0.7 + 0.2 * progress))
|
| 1007 |
+
asymmetry = 1.0
|
| 1008 |
+
horn_length = int(max_radius * 0.4 * progress)
|
| 1009 |
+
|
| 1010 |
+
# Stage 0.75~1.0: ๋ฟ ์์ฑ
|
| 1011 |
+
else:
|
| 1012 |
+
progress = (stage - 0.75) / 0.25
|
| 1013 |
+
current_height = max_height * (0.9 + 0.1 * progress)
|
| 1014 |
+
current_radius = max_radius
|
| 1015 |
+
asymmetry = 1.0
|
| 1016 |
+
horn_length = int(max_radius * (0.4 + 0.4 * progress))
|
| 1017 |
+
|
| 1018 |
+
if current_radius < 2:
|
| 1019 |
+
continue
|
| 1020 |
+
|
| 1021 |
+
# ์ด์น๋ฌ ํ๋ผ๋ฏธํฐ
|
| 1022 |
+
inner_ratio = 0.5 + 0.2 * asymmetry # ์์ชฝ ์ ๋น์จ
|
| 1023 |
+
inner_offset = current_radius * 0.4 * asymmetry # ์คํ์
|
| 1024 |
|
| 1025 |
for r in range(h):
|
| 1026 |
for c in range(w):
|
| 1027 |
dy = r - cy
|
| 1028 |
dx = c - cx
|
| 1029 |
|
| 1030 |
+
dist = np.sqrt(dx**2 + dy**2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1031 |
|
| 1032 |
+
# ๋ฐ๊นฅ ์ ์์ญ
|
| 1033 |
+
if dist < current_radius:
|
| 1034 |
+
# ์์ชฝ ์ (์ค๋ชฉ๋ฉด) - ๋น๋์นญ์ผ ๋๋ง
|
| 1035 |
+
dist_inner = np.sqrt(dx**2 + (dy - inner_offset)**2)
|
| 1036 |
+
inner_r = current_radius * inner_ratio
|
| 1037 |
+
|
| 1038 |
+
if asymmetry > 0.5 and dist_inner < inner_r:
|
| 1039 |
+
# ์ค๋ชฉ๋ฉด ์์ชฝ์ ๋ฎ๊ฒ
|
| 1040 |
+
continue
|
| 1041 |
|
| 1042 |
+
# ๋์ด ๊ณ์ฐ
|
| 1043 |
+
radial_factor = 1 - (dist / current_radius) ** 1.5
|
| 1044 |
+
|
| 1045 |
+
# ๋ฐ๋๋ฐ์ด(์๋จ) vs ๋ฐ๋๊ทธ๋(ํ๋จ) ๋น๋์นญ
|
| 1046 |
if dy < 0:
|
| 1047 |
+
# ๋ฐ๋๋ฐ์ด: ์๋ง (5-12ยฐ ๊ฒฝ์ฌ)
|
| 1048 |
+
slope_factor = 0.6 + 0.4 * (1 - asymmetry)
|
| 1049 |
else:
|
| 1050 |
+
# ๋ฐ๋๊ทธ๋: ๊ธ๊ฒฝ์ฌ (30-34ยฐ ์์๊ฐ)
|
| 1051 |
+
slope_factor = 0.8 + 0.5 * asymmetry
|
| 1052 |
|
| 1053 |
+
z = current_height * radial_factor * slope_factor
|
| 1054 |
+
if z > 0.5:
|
| 1055 |
+
elevation[r, c] = max(elevation[r, c], 5.0 + z)
|
|
|
|
|
|
|
|
|
|
| 1056 |
|
| 1057 |
+
# ๋ฟ (horns) - stage 0.5 ์ดํ
|
| 1058 |
+
if horn_length > 2:
|
| 1059 |
+
for side in [-1, 1]:
|
| 1060 |
+
horn_cx = cx + side * (current_radius * 0.7)
|
| 1061 |
+
horn_cy = cy + inner_offset
|
| 1062 |
+
|
| 1063 |
+
dx_h = c - horn_cx
|
| 1064 |
+
dy_h = r - horn_cy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1065 |
|
| 1066 |
+
# ๋ฟ ์์ญ: ๋ฐ๋ ๋ฐฉํฅ์ผ๋ก ๊ธธ์ญ
|
| 1067 |
+
horn_width = max(2, current_radius * 0.25)
|
| 1068 |
+
if abs(dx_h) < horn_width and 0 < dy_h < horn_length:
|
| 1069 |
+
horn_factor = (1 - dy_h / horn_length) ** 0.7
|
| 1070 |
+
width_factor = 1 - (abs(dx_h) / horn_width) ** 2
|
| 1071 |
+
z = current_height * 0.4 * horn_factor * width_factor
|
| 1072 |
+
if z > 0.3:
|
| 1073 |
+
elevation[r, c] = max(elevation[r, c], 5.0 + z)
|
| 1074 |
+
|
| 1075 |
+
if return_metadata:
|
| 1076 |
+
return elevation, {
|
| 1077 |
+
'stage_description': _get_barchan_stage_desc(stage)
|
| 1078 |
+
}
|
| 1079 |
|
| 1080 |
return elevation
|
| 1081 |
+
|
| 1082 |
+
|
| 1083 |
+
def _get_barchan_stage_desc(stage: float) -> str:
|
| 1084 |
+
"""๋ฐ๋ฅดํ ๋จ๊ณ๋ณ ์ค๋ช
"""
|
| 1085 |
+
if stage < 0.2:
|
| 1086 |
+
return "๐๏ธ ๋ชจ๋ ์ถ์ : ์ฅ์ ๋ฌผ ์ฃผ๋ณ ๋ชจ๋ ์์ ์์"
|
| 1087 |
+
elif stage < 0.4:
|
| 1088 |
+
return "โฌ๏ธ ์ธ๋ ์ฑ์ฅ: ์ํ ๋ชจ๋์ธ๋ ํ์ฑ"
|
| 1089 |
+
elif stage < 0.6:
|
| 1090 |
+
return "โ๏ธ ๋น๋์นญ ๋ฐ๋ฌ: ๋ฐ๋๋ฐ์ด ์๊ฒฝ์ฌ, ๋ฐ๋๊ทธ๋ ๊ธ๊ฒฝ์ฌ"
|
| 1091 |
+
elif stage < 0.8:
|
| 1092 |
+
return "๐ ์ด์น๋ฌ ํํ: ์ค๋ชฉ๋ฉด ํ์ฑ, ๋ฟ ๋ฐ๋ฌ ์์"
|
| 1093 |
+
else:
|
| 1094 |
+
return "๐๏ธ ๋ฐ๋ฅดํ ์์ฑ: ๋ฟ์ด ๋ฐ๋ ๋ฐฉํฅ์ผ๋ก ์ฐ์ฅ"
|
| 1095 |
# ============================================
|
| 1096 |
# ํ์ฅ ์งํ (Extended Landforms)
|
| 1097 |
# ============================================
|
|
|
|
| 1730 |
|
| 1731 |
|
| 1732 |
def create_shield_volcano(grid_size: int = 100, stage: float = 1.0,
|
| 1733 |
+
max_height: float = 40.0, return_metadata: bool = False) -> np.ndarray:
|
| 1734 |
+
"""์์ํ์ฐ (Shield Volcano) - ํ์์ดํ
|
| 1735 |
+
|
| 1736 |
+
Stage 0~0.3: ํด์ ๋ถ์ถ โ ํด์๋ฉด ๋๋ฌ
|
| 1737 |
+
Stage 0.3~0.6: ์ฉ์๋ฅ ๋ฐ๋ณต โ ์๋งํ ์์ ํ์ฑ
|
| 1738 |
+
Stage 0.6~0.8: ์ ์๋ถ ํ์ฅ + ์ค์ ํ๊ตฌ ํ์ฑ
|
| 1739 |
+
Stage 0.8~1.0: ์ ์ ์นผ๋ฐ๋ผ + ์ฉ์ ํ๋ฆ ํ์
|
| 1740 |
+
|
| 1741 |
+
ํน์ง:
|
| 1742 |
+
- ํ๋ฌด์์ง ์ฉ์ (์ ๋์ฑ ๋์)
|
| 1743 |
+
- ๊ฒฝ์ฌ 5-10ยฐ
|
| 1744 |
+
- ์ฉ์๋ฅ๊ฐ ๋๊ฒ ํผ์ง
|
| 1745 |
+
"""
|
| 1746 |
h, w = grid_size, grid_size
|
| 1747 |
elevation = np.zeros((h, w))
|
| 1748 |
|
| 1749 |
center = (h // 2, w // 2)
|
| 1750 |
+
max_radius = int(w * 0.45)
|
| 1751 |
+
|
| 1752 |
+
# Stage์ ๋ฐ๋ฅธ ๋ฐ๊ฒฝ ์ฑ์ฅ
|
| 1753 |
+
current_radius = int(max_radius * min(1.0, stage * 1.3))
|
| 1754 |
+
current_height = max_height * stage
|
| 1755 |
|
| 1756 |
for r in range(h):
|
| 1757 |
for c in range(w):
|
| 1758 |
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1759 |
|
| 1760 |
+
if dist < current_radius and current_radius > 0:
|
| 1761 |
+
# ์๋งํ ํฌ๋ฌผ์ ํํ (๊ฒฝ์ฌ 5-10๋)
|
| 1762 |
+
radial_factor = 1 - (dist / current_radius) ** 1.8
|
| 1763 |
+
elevation[r, c] = current_height * radial_factor
|
| 1764 |
+
|
| 1765 |
+
# ์ฉ์๋ฅ ํ์ (๋ฐฉ์ฌ์) - stage 0.4 ์ดํ
|
| 1766 |
+
if stage > 0.4:
|
| 1767 |
+
np.random.seed(42)
|
| 1768 |
+
num_flows = 6
|
| 1769 |
+
for i in range(num_flows):
|
| 1770 |
+
angle = 2 * np.pi * i / num_flows + np.random.random() * 0.3
|
| 1771 |
+
flow_length = int(current_radius * (0.6 + 0.4 * stage))
|
| 1772 |
+
flow_width = 3 + int(2 * stage)
|
| 1773 |
+
|
| 1774 |
+
for d in range(10, flow_length):
|
| 1775 |
+
fx = int(center[1] + d * np.cos(angle))
|
| 1776 |
+
fy = int(center[0] + d * np.sin(angle))
|
| 1777 |
|
| 1778 |
+
for dw in range(-flow_width, flow_width + 1):
|
| 1779 |
+
tx = int(fx + dw * np.sin(angle))
|
| 1780 |
+
ty = int(fy - dw * np.cos(angle))
|
| 1781 |
+
|
| 1782 |
+
if 0 <= ty < h and 0 <= tx < w:
|
| 1783 |
+
# ์ฉ์๋ฅ ์ต๊ธฐ
|
| 1784 |
+
flow_height = 2.0 * (1 - abs(dw) / flow_width) * (1 - d / flow_length)
|
| 1785 |
+
elevation[ty, tx] += flow_height
|
| 1786 |
+
|
| 1787 |
+
# ์ ์๋ถ ํ๊ตฌ/์นผ๋ฐ๋ผ - stage 0.6 ์ดํ
|
| 1788 |
+
if stage > 0.6:
|
| 1789 |
+
caldera_progress = (stage - 0.6) / 0.4
|
| 1790 |
+
crater_radius = int(max_radius * 0.08 * (1 + caldera_progress))
|
| 1791 |
+
crater_depth = 5.0 * caldera_progress
|
| 1792 |
+
|
| 1793 |
+
for r in range(h):
|
| 1794 |
+
for c in range(w):
|
| 1795 |
+
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1796 |
+
if dist < crater_radius:
|
| 1797 |
+
# ํจ๋ชฐ ์นผ๋ฐ๋ผ
|
| 1798 |
+
depression = crater_depth * (1 - (dist / crater_radius) ** 2)
|
| 1799 |
+
elevation[r, c] = max(elevation[r, c] - depression, current_height * 0.85)
|
| 1800 |
+
|
| 1801 |
+
if return_metadata:
|
| 1802 |
+
return elevation, {
|
| 1803 |
+
'current_radius': current_radius,
|
| 1804 |
+
'current_height': current_height,
|
| 1805 |
+
'stage_description': _get_shield_stage_desc(stage)
|
| 1806 |
+
}
|
| 1807 |
+
|
| 1808 |
return elevation
|
| 1809 |
|
| 1810 |
|
| 1811 |
+
def _get_shield_stage_desc(stage: float) -> str:
|
| 1812 |
+
"""์์ํ์ฐ ๋จ๊ณ๋ณ ์ค๋ช
"""
|
| 1813 |
+
if stage < 0.2:
|
| 1814 |
+
return "๐ ํด์ ๋ถ์ถ: ํ๋ฌด์ ์ฉ์ ๋ถ์ถ ์์"
|
| 1815 |
+
elif stage < 0.4:
|
| 1816 |
+
return "๐๏ธ ํด์๋ฉด ๋๋ฌ: ํ์ฐ์ฌ ํ์ฑ"
|
| 1817 |
+
elif stage < 0.6:
|
| 1818 |
+
return "๐ฅ ์ฉ์๋ฅ ํ์ฅ: ํํธ์ดํธ์ด ์ฉ์ ํ๋ฆ"
|
| 1819 |
+
elif stage < 0.8:
|
| 1820 |
+
return "โฐ๏ธ ์์ ํ์ฑ: ์๋งํ ๊ฒฝ์ฌ (5-10ยฐ)"
|
| 1821 |
+
else:
|
| 1822 |
+
return "๐ณ๏ธ ์ ์ ์นผ๋ฐ๋ผ: ๋ง๊ทธ๋ง ๋น ์ง โ ํจ๋ชฐ"
|
| 1823 |
+
|
| 1824 |
+
|
| 1825 |
def create_stratovolcano(grid_size: int = 100, stage: float = 1.0,
|
| 1826 |
+
max_height: float = 80.0, return_metadata: bool = False) -> np.ndarray:
|
| 1827 |
+
"""์ฑ์ธตํ์ฐ (Stratovolcano) - ๋ณตํฉํ์ฐ
|
| 1828 |
+
|
| 1829 |
+
Stage 0~0.25: ์ด๊ธฐ ๋ถ์ถ โ ์๋ฟ ํ์ฑ ์์
|
| 1830 |
+
Stage 0.25~0.5: ์ฉ์+ํ์๋ฌผ ๊ต๋ โ ๊ธ๊ฒฝ์ฌ ์๋ฟ
|
| 1831 |
+
Stage 0.5~0.75: ๊ณ ๋ ์์น + ๋ถํ๊ตฌ ๋ฐ๋ฌ
|
| 1832 |
+
Stage 0.75~1.0: ์ ์ ๋ถํ๊ตฌ + ํ์ฐ์์ค๋ฌผ ์ฌ๋ฉด
|
| 1833 |
+
|
| 1834 |
+
ํน์ง:
|
| 1835 |
+
- ์์ฐ์์ง/์ ๋ฌธ์์ง ๋ง๊ทธ๋ง
|
| 1836 |
+
- ๊ฒฝ์ฌ 25-35ยฐ
|
| 1837 |
+
- ์ฉ์๋ฅ + ํ์๋ฅ ๊ต๋์ธต
|
| 1838 |
+
"""
|
| 1839 |
h, w = grid_size, grid_size
|
| 1840 |
elevation = np.zeros((h, w))
|
| 1841 |
|
| 1842 |
center = (h // 2, w // 2)
|
| 1843 |
+
max_radius = int(w * 0.4)
|
| 1844 |
+
|
| 1845 |
+
# Stage์ ๋ฐ๋ฅธ ์ฑ์ฅ
|
| 1846 |
+
current_radius = int(max_radius * min(1.0, stage * 1.2))
|
| 1847 |
+
current_height = max_height * stage
|
| 1848 |
|
| 1849 |
for r in range(h):
|
| 1850 |
for c in range(w):
|
| 1851 |
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1852 |
|
| 1853 |
+
if dist < current_radius and current_radius > 0:
|
| 1854 |
# ๊ธํ ์๋ฟ (๊ฒฝ์ฌ 25-35๋)
|
| 1855 |
+
radial_factor = 1 - (dist / current_radius) ** 0.8
|
| 1856 |
+
elevation[r, c] = current_height * radial_factor
|
| 1857 |
+
|
| 1858 |
+
# ์ธต๋ฆฌ ํํ (์์ ์์ฒ ) - stage 0.3 ์ดํ
|
| 1859 |
+
if stage > 0.3:
|
| 1860 |
+
np.random.seed(42)
|
| 1861 |
+
num_layers = int(5 * stage)
|
| 1862 |
+
for layer in range(num_layers):
|
| 1863 |
+
layer_radius = current_radius * (0.3 + 0.7 * layer / max(1, num_layers))
|
| 1864 |
+
layer_height = current_height * (0.2 + 0.6 * layer / max(1, num_layers))
|
| 1865 |
+
|
| 1866 |
+
for r in range(h):
|
| 1867 |
+
for c in range(w):
|
| 1868 |
+
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1869 |
+
if abs(dist - layer_radius) < 3:
|
| 1870 |
+
# ์ธต๋ฆฌ ๊ฒฝ๊ณ์ ์ฝ๊ฐ์ ์์ฒ
|
| 1871 |
+
bump = 1.5 * np.sin(np.arctan2(r - center[0], c - center[1]) * 8)
|
| 1872 |
+
elevation[r, c] += bump
|
| 1873 |
+
|
| 1874 |
+
# ์ ์๋ถ ๋ถํ๊ตฌ - stage 0.5 ์ดํ
|
| 1875 |
+
if stage > 0.5:
|
| 1876 |
+
crater_progress = (stage - 0.5) / 0.5
|
| 1877 |
+
crater_radius = int(max_radius * 0.06 * (1 + crater_progress * 0.5))
|
| 1878 |
+
crater_depth = 12.0 * crater_progress
|
| 1879 |
+
|
| 1880 |
+
for r in range(h):
|
| 1881 |
+
for c in range(w):
|
| 1882 |
+
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1883 |
+
if dist < crater_radius:
|
| 1884 |
+
# ๋ถํ๊ตฌ
|
| 1885 |
+
if dist < crater_radius * 0.7:
|
| 1886 |
+
elevation[r, c] = current_height - crater_depth
|
| 1887 |
+
else:
|
| 1888 |
+
# ๋ถํ๊ตฌ ํ
๋๋ฆฌ
|
| 1889 |
+
rim_factor = (dist - crater_radius * 0.7) / (crater_radius * 0.3)
|
| 1890 |
+
elevation[r, c] = current_height - crater_depth + crater_depth * rim_factor
|
| 1891 |
+
|
| 1892 |
+
if return_metadata:
|
| 1893 |
+
return elevation, {
|
| 1894 |
+
'current_height': current_height,
|
| 1895 |
+
'stage_description': _get_strato_stage_desc(stage)
|
| 1896 |
+
}
|
| 1897 |
+
|
| 1898 |
return elevation
|
| 1899 |
|
| 1900 |
|
| 1901 |
+
def _get_strato_stage_desc(stage: float) -> str:
|
| 1902 |
+
"""์ฑ์ธตํ์ฐ ๋จ๊ณ๋ณ ์ค๋ช
"""
|
| 1903 |
+
if stage < 0.2:
|
| 1904 |
+
return "๐ ์ด๊ธฐ ๋ถ์ถ: ํ์ฐ์์ค๋ฌผ ๋ถ์ถ"
|
| 1905 |
+
elif stage < 0.4:
|
| 1906 |
+
return "๐ฅ ์๋ฟ ํ์ฑ: ์ฉ์ + ํ์๋ฅ ๊ต๋"
|
| 1907 |
+
elif stage < 0.6:
|
| 1908 |
+
return "โฐ๏ธ ๊ธ๊ฒฝ์ฌ ๋ฐ๋ฌ: ์ฑ์ธต ๊ตฌ์กฐ ํ์ฑ"
|
| 1909 |
+
elif stage < 0.8:
|
| 1910 |
+
return "๐ป ๊ณ ๋ ์์น: ๋ถํ๊ตฌ ๋ฐ๋ฌ"
|
| 1911 |
+
else:
|
| 1912 |
+
return "๐จ ์ ์ ๋ถํ๊ตฌ: ๋ถ์ฐ ํ๋ ๊ฐ๋ฅ"
|
| 1913 |
+
|
| 1914 |
+
|
| 1915 |
def create_caldera(grid_size: int = 100, stage: float = 1.0,
|
| 1916 |
+
rim_height: float = 50.0, return_metadata: bool = False) -> np.ndarray:
|
| 1917 |
+
"""์นผ๋ฐ๋ผ (Caldera) - ํ์ฐ ์ ์๋ถ ํจ๋ชฐ
|
| 1918 |
+
|
| 1919 |
+
Stage 0~0.3: ์ฑ์ธตํ์ฐ ์ฑ์ฅ (๋ถํ ํ๋)
|
| 1920 |
+
Stage 0.3~0.5: ๋๋ถํ โ ๋ง๊ทธ๋ง๋ฐฉ ๊ณต๋ํ
|
| 1921 |
+
Stage 0.5~0.8: ์ ์๋ถ ํจ๋ชฐ (์นผ๋ฐ๋ผ ํ์ฑ)
|
| 1922 |
+
Stage 0.8~1.0: ์นผ๋ฐ๋ผ ํ์ฅ + ํธ์ ํ์ฑ (๋ฐฑ๋์ฐ ์ฒ์ง)
|
| 1923 |
+
|
| 1924 |
+
ํต์ฌ ๊ณผ์ :
|
| 1925 |
+
- ๋ง๊ทธ๋ง๋ฐฉ ๋น์์ง โ ์ง์ง๋ ฅ ์์ค
|
| 1926 |
+
- ์ ์๋ถ ํจ๋ชฐ โ ๋์ ์ํ ๋ถ์ง
|
| 1927 |
+
- ์นผ๋ฐ๋ผ ์ง๊ฒฝ ์ km ~ ์์ญ km
|
| 1928 |
+
"""
|
| 1929 |
h, w = grid_size, grid_size
|
| 1930 |
elevation = np.zeros((h, w))
|
| 1931 |
|
| 1932 |
center = (h // 2, w // 2)
|
| 1933 |
+
max_outer = int(w * 0.45)
|
|
|
|
| 1934 |
|
| 1935 |
+
if stage < 0.3:
|
| 1936 |
+
# Stage 0~0.3: ์ฑ์ธตํ์ฐ ์ฑ์ฅ
|
| 1937 |
+
progress = stage / 0.3
|
| 1938 |
+
volcano_height = rim_height * 1.5 * progress
|
| 1939 |
+
volcano_radius = int(max_outer * 0.8 * progress)
|
| 1940 |
+
|
| 1941 |
+
for r in range(h):
|
| 1942 |
+
for c in range(w):
|
| 1943 |
+
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1944 |
+
if dist < volcano_radius and volcano_radius > 0:
|
| 1945 |
+
# ์ฑ์ธตํ์ฐ ํํ
|
| 1946 |
+
elevation[r, c] = volcano_height * (1 - (dist / volcano_radius) ** 0.9)
|
| 1947 |
+
|
| 1948 |
+
# ์์ ๋ถํ๊ตฌ
|
| 1949 |
+
crater_r = max(2, int(volcano_radius * 0.08))
|
| 1950 |
+
for r in range(h):
|
| 1951 |
+
for c in range(w):
|
| 1952 |
+
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1953 |
+
if dist < crater_r:
|
| 1954 |
+
elevation[r, c] = volcano_height * 0.85
|
| 1955 |
|
| 1956 |
+
elif stage < 0.5:
|
| 1957 |
+
# Stage 0.3~0.5: ๋๋ถํ ์์, ํจ๋ชฐ ์์
|
| 1958 |
+
progress = (stage - 0.3) / 0.2
|
| 1959 |
+
volcano_height = rim_height * 1.5
|
| 1960 |
+
collapse_depth = rim_height * 0.5 * progress
|
| 1961 |
+
collapse_radius = int(max_outer * 0.15 * (1 + progress))
|
| 1962 |
+
|
| 1963 |
+
for r in range(h):
|
| 1964 |
+
for c in range(w):
|
| 1965 |
+
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1966 |
+
if dist < max_outer * 0.8:
|
| 1967 |
+
# ํ์ฐ์ฒด
|
| 1968 |
+
base = volcano_height * (1 - (dist / (max_outer * 0.8)) ** 0.9)
|
| 1969 |
+
|
| 1970 |
+
if dist < collapse_radius:
|
| 1971 |
+
# ํจ๋ชฐ ์์
|
| 1972 |
+
elevation[r, c] = base - collapse_depth * (1 - (dist / collapse_radius) ** 2)
|
| 1973 |
+
else:
|
| 1974 |
+
elevation[r, c] = base
|
| 1975 |
+
|
| 1976 |
+
elif stage < 0.8:
|
| 1977 |
+
# Stage 0.5~0.8: ์นผ๋ฐ๋ผ ํ์ฅ
|
| 1978 |
+
progress = (stage - 0.5) / 0.3
|
| 1979 |
+
caldera_radius = int(max_outer * (0.2 + 0.25 * progress)) # ์ ์ ๋์ด์ง
|
| 1980 |
+
collapse_depth = rim_height * (0.5 + 0.4 * progress)
|
| 1981 |
+
|
| 1982 |
+
for r in range(h):
|
| 1983 |
+
for c in range(w):
|
| 1984 |
+
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 1985 |
+
|
| 1986 |
+
if dist < max_outer:
|
| 1987 |
+
if dist < caldera_radius:
|
| 1988 |
+
# ์นผ๋ฐ๋ผ ๋ฐ๋ฅ (ํํ)
|
| 1989 |
+
elevation[r, c] = rim_height * 1.5 - collapse_depth
|
| 1990 |
+
else:
|
| 1991 |
+
# ์นผ๋ฐ๋ผ ๋ฒฝ + ์ธ๋ฅ์ฐ
|
| 1992 |
+
wall_progress = (dist - caldera_radius) / (max_outer - caldera_radius)
|
| 1993 |
+
if wall_progress < 0.3:
|
| 1994 |
+
# ๊ธ๊ฒฝ์ฌ ๋ฒฝ
|
| 1995 |
+
elevation[r, c] = (rim_height * 1.5 - collapse_depth) + rim_height * 0.8 * (wall_progress / 0.3)
|
| 1996 |
+
else:
|
| 1997 |
+
# ์ธ๋ฅ์ฐ ์ฌ๋ฉด
|
| 1998 |
+
elevation[r, c] = rim_height * (1 - (wall_progress - 0.3) / 0.7) * 1.2
|
| 1999 |
+
|
| 2000 |
+
else:
|
| 2001 |
+
# Stage 0.8~1.0: ์นผ๋ฐ๋ผ ์์ฑ + ํธ์
|
| 2002 |
+
progress = (stage - 0.8) / 0.2
|
| 2003 |
+
caldera_radius = int(max_outer * 0.45) # ์ต์ข
ํฌ๊ธฐ
|
| 2004 |
+
|
| 2005 |
+
for r in range(h):
|
| 2006 |
+
for c in range(w):
|
| 2007 |
+
dist = np.sqrt((r - center[0])**2 + (c - center[1])**2)
|
| 2008 |
+
|
| 2009 |
+
if dist < max_outer:
|
| 2010 |
+
if dist < caldera_radius:
|
| 2011 |
+
# ์นผ๋ฐ๋ผ ๋ฐ๋ฅ (ํธ์)
|
| 2012 |
+
water_level = 5.0
|
| 2013 |
+
elevation[r, c] = water_level - 3.0 * (1 - (dist / caldera_radius) ** 2)
|
| 2014 |
+
elif dist < caldera_radius + 8:
|
| 2015 |
+
# ๊ธ๊ฒฝ์ฌ ๋ฒฝ
|
| 2016 |
+
wall_t = (dist - caldera_radius) / 8
|
| 2017 |
+
elevation[r, c] = 5.0 + rim_height * 0.9 * wall_t
|
| 2018 |
+
else:
|
| 2019 |
+
# ์ธ๋ฅ์ฐ
|
| 2020 |
+
outer_t = (dist - caldera_radius - 8) / (max_outer - caldera_radius - 8)
|
| 2021 |
+
elevation[r, c] = rim_height * (1 - outer_t ** 0.8) * 0.9
|
| 2022 |
+
|
| 2023 |
+
if return_metadata:
|
| 2024 |
+
return elevation, {
|
| 2025 |
+
'stage_description': _get_caldera_stage_desc(stage)
|
| 2026 |
+
}
|
| 2027 |
+
|
| 2028 |
return elevation
|
| 2029 |
|
| 2030 |
|
| 2031 |
+
def _get_caldera_stage_desc(stage: float) -> str:
|
| 2032 |
+
"""์นผ๋ฐ๋ผ ๋จ๊ณ๋ณ ์ค๋ช
"""
|
| 2033 |
+
if stage < 0.2:
|
| 2034 |
+
return "๐ ์ฑ์ธตํ์ฐ ์ฑ์ฅ: ๋ถํ ํ๋์ผ๋ก ์ฐ์ฒด ํ์ฑ"
|
| 2035 |
+
elif stage < 0.4:
|
| 2036 |
+
return "๐ฅ ๋๋ถํ: ๋ง๊ทธ๋ง ๋๋ ๋ถ์ถ"
|
| 2037 |
+
elif stage < 0.6:
|
| 2038 |
+
return "๐ณ๏ธ ํจ๋ชฐ ์์: ๋ง๊ทธ๋ง๋ฐฉ ๋น์์ง โ ์ง์ง๋ ฅ ์์ค"
|
| 2039 |
+
elif stage < 0.8:
|
| 2040 |
+
return "โฌ๏ธ ์นผ๋ฐ๋ผ ํ์ฅ: ์ ์๋ถ ํจ๋ชฐ ํ๋"
|
| 2041 |
+
else:
|
| 2042 |
+
return "๐ง ์นผ๋ฐ๋ผ ํธ์: ์ตํด์ ๊ณ ์ (๋ฐฑ๋์ฐ ์ฒ์ง)"
|
| 2043 |
+
|
| 2044 |
+
|
| 2045 |
def create_mesa_butte(grid_size: int = 100, stage: float = 1.0,
|
| 2046 |
num_mesas: int = 2) -> np.ndarray:
|
| 2047 |
"""๋ฉ์ฌ/๋ทฐํธ (Mesa/Butte) - ํ์์ง"""
|
|
|
|
| 2678 |
return elevation
|
| 2679 |
|
| 2680 |
|
| 2681 |
+
def create_lava_plateau(grid_size: int = 100, stage: float = 1.0,
|
| 2682 |
+
return_metadata: bool = False) -> np.ndarray:
|
| 2683 |
+
"""์ฉ์๋์ง (Lava Plateau) - ํํ๊ฐ/์ ์ฃผ๋ํ
|
| 2684 |
|
| 2685 |
+
Stage 0~0.25: ์๋ V์๊ณก ์กด์ฌ (ํ์ฒ ํ๋ฆ)
|
| 2686 |
+
Stage 0.25~0.5: ์ดํ๋ถ์ถ โ ์ฉ์์ด V์๊ณก ๋ฉ์ (์ฉ์๋ฅ)
|
| 2687 |
+
Stage 0.5~0.75: ์ฉ์๋์ง ํ์ฑ (ํํํ)
|
| 2688 |
+
Stage 0.75~1.0: ํ์ฒ ์ฌ์นจ์ โ ์๋ก์ด ํ๊ณก ํ์ฑ
|
| 2689 |
+
|
| 2690 |
+
ํต์ฌ ๊ณผ์ :
|
| 2691 |
+
- ์ดํ๋ถ์ถ(fissure eruption): ์ ์์ผ๋ก ์ฉ์ ๋ถ์ถ
|
| 2692 |
+
- ํ์ํ๋ฌด์(flood basalt): ๋์ ์ง์ญ ๋ค๋ฎ์
|
| 2693 |
+
- ์ฌ์นจ์(rejuvenation): ์ ํ์ฒ์ด ํ๊ณก ํ์ฑ
|
| 2694 |
"""
|
| 2695 |
h, w = grid_size, grid_size
|
| 2696 |
elevation = np.zeros((h, w))
|
| 2697 |
+
lava_mask = np.zeros((h, w), dtype=bool) # ์ฉ์ ์์น ํ์
|
| 2698 |
center = w // 2
|
| 2699 |
|
| 2700 |
# ๊ธฐ๋ฐ ๊ณ ์ ๋์ด
|
| 2701 |
plateau_base = 30.0
|
| 2702 |
|
| 2703 |
+
if stage < 0.25:
|
| 2704 |
+
# Stage 0~0.25: ์๋ V์๊ณก (ํ์ฒ ํ๋ฆ)
|
| 2705 |
+
v_depth = 30.0
|
| 2706 |
+
for r in range(h):
|
| 2707 |
+
for c in range(w):
|
| 2708 |
+
dx = abs(c - center)
|
| 2709 |
+
elevation[r, c] = plateau_base
|
| 2710 |
+
|
| 2711 |
+
# V์๊ณก
|
| 2712 |
+
if dx < 18:
|
| 2713 |
+
v_shape = v_depth * (1 - dx / 18) ** 1.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2714 |
elevation[r, c] -= v_shape
|
| 2715 |
+
|
| 2716 |
+
elif stage < 0.5:
|
| 2717 |
+
# Stage 0.25~0.5: ์ฉ์ ๋ถ์ถ โ ๊ณจ์ง๊ธฐ ๋ฉ์
|
| 2718 |
+
progress = (stage - 0.25) / 0.25
|
| 2719 |
+
v_depth = 30.0 * (1 - progress * 0.9) # V์๊ณก ์ ์ ๋ฉ์์ง
|
| 2720 |
+
lava_thickness = 25.0 * progress
|
| 2721 |
+
|
| 2722 |
+
for r in range(h):
|
| 2723 |
+
# ์ฉ์ ํ๋ฆ ๋ฒ์ (์๋ฅ์์ ํ๋ฅ๋ก ์งํ)
|
| 2724 |
+
flow_reach = int(h * progress)
|
| 2725 |
|
| 2726 |
+
for c in range(w):
|
| 2727 |
+
dx = abs(c - center)
|
| 2728 |
+
elevation[r, c] = plateau_base
|
| 2729 |
+
|
| 2730 |
+
# ์์ฌ V์๊ณก
|
| 2731 |
+
if dx < 18:
|
| 2732 |
+
v_shape = v_depth * (1 - dx / 18) ** 1.2
|
| 2733 |
+
elevation[r, c] -= v_shape
|
| 2734 |
+
|
| 2735 |
+
# ์ฉ์ ์ฑ์
|
| 2736 |
+
if r < flow_reach and dx < 20:
|
| 2737 |
+
lava_fill = lava_thickness * (1 - dx / 20) ** 0.8
|
| 2738 |
+
elevation[r, c] += lava_fill
|
| 2739 |
+
lava_mask[r, c] = True
|
| 2740 |
|
| 2741 |
+
elif stage < 0.75:
|
| 2742 |
+
# Stage 0.5~0.75: ์ฉ์๋์ง ํํํ
|
| 2743 |
+
progress = (stage - 0.5) / 0.25
|
| 2744 |
+
|
| 2745 |
+
for r in range(h):
|
| 2746 |
+
for c in range(w):
|
| 2747 |
+
dx = abs(c - center)
|
| 2748 |
|
| 2749 |
+
# ํํํ ์ฉ์๋์ง
|
| 2750 |
+
if dx < 25:
|
| 2751 |
+
elevation[r, c] = plateau_base + 5.0
|
| 2752 |
+
lava_mask[r, c] = True
|
| 2753 |
+
else:
|
| 2754 |
+
# ๊ฐ์ฅ์๋ฆฌ ๊ฒฝ์ฌ
|
| 2755 |
+
edge_t = (dx - 25) / (w // 2 - 25)
|
| 2756 |
+
elevation[r, c] = (plateau_base + 5.0) * (1 - edge_t ** 0.7)
|
| 2757 |
|
| 2758 |
+
else:
|
| 2759 |
+
# Stage 0.75~1.0: ์ ํ๊ณก ํ์ฑ
|
| 2760 |
+
progress = (stage - 0.75) / 0.25
|
| 2761 |
+
gorge_width = int(6 + 6 * progress)
|
| 2762 |
+
gorge_depth = 35.0 * progress
|
| 2763 |
+
|
| 2764 |
+
for r in range(h):
|
| 2765 |
+
for c in range(w):
|
| 2766 |
+
dx = abs(c - center)
|
| 2767 |
+
|
| 2768 |
+
# ์ฉ์๋์ง ๊ธฐ๋ฐ
|
| 2769 |
+
if dx < 25:
|
| 2770 |
+
elevation[r, c] = plateau_base + 5.0
|
| 2771 |
+
lava_mask[r, c] = True
|
| 2772 |
+
else:
|
| 2773 |
+
edge_t = (dx - 25) / (w // 2 - 25)
|
| 2774 |
+
elevation[r, c] = (plateau_base + 5.0) * (1 - edge_t ** 0.7)
|
| 2775 |
|
| 2776 |
+
# ์๋ก์ด ํ๊ณก (ํ์ฒ ์ฌ์นจ์)
|
| 2777 |
+
if dx < gorge_width:
|
| 2778 |
+
gorge_shape = gorge_depth * (1 - (dx / gorge_width) ** 2)
|
| 2779 |
+
elevation[r, c] -= gorge_shape
|
| 2780 |
+
|
| 2781 |
+
# ์์ง ์ ๋ฒฝ ํ์ฑ (์ฃผ์์ ๋ฆฌ ํจ๊ณผ)
|
| 2782 |
+
if dx > gorge_width * 0.7:
|
| 2783 |
+
elevation[r, c] -= 3.0 # ๊ธ๊ฒฝ์ฌ
|
| 2784 |
+
|
| 2785 |
+
if return_metadata:
|
| 2786 |
+
return elevation, {
|
| 2787 |
+
'lava_mask': lava_mask,
|
| 2788 |
+
'stage_description': _get_lava_plateau_stage_desc(stage)
|
| 2789 |
+
}
|
| 2790 |
+
|
| 2791 |
return elevation
|
| 2792 |
|
| 2793 |
|
| 2794 |
+
def _get_lava_plateau_stage_desc(stage: float) -> str:
|
| 2795 |
+
"""์ฉ์๋์ง ๋จ๊ณ๋ณ ์ค๋ช
"""
|
| 2796 |
+
if stage < 0.2:
|
| 2797 |
+
return "๐๏ธ ์๋ V์๊ณก: ํ์ฒ ์นจ์์ ์ํ ๊ณ๊ณก"
|
| 2798 |
+
elif stage < 0.4:
|
| 2799 |
+
return "๐ ์ดํ๋ถ์ถ: ์ฉ์์ด ๊ณ๊ณก์ ๋ฐ๋ผ ํ๋ฆ"
|
| 2800 |
+
elif stage < 0.6:
|
| 2801 |
+
return "๐ฅ ์ฉ์ ํ์: ๊ณ๊ณก์ ์์ ํ ๋ฉ์"
|
| 2802 |
+
elif stage < 0.8:
|
| 2803 |
+
return "โฌ ์ฉ์๋์ง ํ์ฑ: ํํํ ํ๋ฌด์ ๋์ง"
|
| 2804 |
+
else:
|
| 2805 |
+
return "๐๏ธ ์ฌ์นจ์: ์๋ก์ด ํ์ฒ์ด ํ๊ณก ํ์ฑ (์ฃผ์์ ๋ฆฌ)"
|
| 2806 |
+
|
| 2807 |
+
|
| 2808 |
def create_coastal_dune(grid_size: int = 100, stage: float = 1.0,
|
| 2809 |
num_dunes: int = 3) -> np.ndarray:
|
| 2810 |
"""ํด์์ฌ๊ตฌ (Coastal Dune) - ํด์๊ฐ ๋ชจ๋ ์ธ๋"""
|
engine/script_engine.py
CHANGED
|
@@ -54,7 +54,24 @@ class ScriptExecutor:
|
|
| 54 |
'min': min,
|
| 55 |
'abs': abs,
|
| 56 |
'pow': pow,
|
| 57 |
-
'print': print
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
|
| 60 |
# 2. ๊ธ์ง๋ ํค์๋ ์ฒดํฌ (๊ธฐ๋ณธ์ ์ธ ๋ณด์)
|
|
|
|
| 54 |
'min': min,
|
| 55 |
'abs': abs,
|
| 56 |
'pow': pow,
|
| 57 |
+
'print': print, # ๋๋ฒ๊น
์ฉ
|
| 58 |
+
'range': range,
|
| 59 |
+
'len': len,
|
| 60 |
+
'int': int,
|
| 61 |
+
'float': float,
|
| 62 |
+
'round': round,
|
| 63 |
+
'sum': sum,
|
| 64 |
+
'enumerate': enumerate,
|
| 65 |
+
'zip': zip,
|
| 66 |
+
'list': list,
|
| 67 |
+
'tuple': tuple,
|
| 68 |
+
'dict': dict,
|
| 69 |
+
'set': set,
|
| 70 |
+
'str': str,
|
| 71 |
+
'bool': bool,
|
| 72 |
+
'True': True,
|
| 73 |
+
'False': False,
|
| 74 |
+
'None': None,
|
| 75 |
}
|
| 76 |
|
| 77 |
# 2. ๊ธ์ง๋ ํค์๋ ์ฒดํฌ (๊ธฐ๋ณธ์ ์ธ ๋ณด์)
|
pages/1_๐_Gallery.py
CHANGED
|
@@ -14,6 +14,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspa
|
|
| 14 |
|
| 15 |
from engine.ideal_landforms import IDEAL_LANDFORM_GENERATORS, ANIMATED_LANDFORM_GENERATORS
|
| 16 |
from app.components.renderer import render_terrain_plotly
|
|
|
|
| 17 |
|
| 18 |
st.header("๐ ์ด์์ ์งํ ๊ฐค๋ฌ๋ฆฌ")
|
| 19 |
st.markdown("_๊ต๊ณผ์์ ์ธ ์งํ ํํ๋ฅผ ๊ธฐํํ์ ๋ชจ๋ธ๋ก ์๊ฐํํฉ๋๋ค._")
|
|
@@ -239,11 +240,44 @@ if landform_key in ANIMATED_LANDFORM_GENERATORS:
|
|
| 239 |
# ๋จ๊ณ๋ณ ์ค๋ช
ํ์
|
| 240 |
st.success(metadata.get('stage_description', ''))
|
| 241 |
|
| 242 |
-
# ์ ์์ง ์กด ์ ๋ณด
|
| 243 |
if landform_key == 'alluvial_fan' and 'zone_info' in metadata:
|
| 244 |
-
with st.expander("๐ ์ธ๋ถ ๊ตฌ์กฐ ๋ณด๊ธฐ"):
|
| 245 |
-
|
| 246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
|
| 248 |
# ํผ์ค๋ฅด๋ ํ๋ก์ธ์ค ์ ๋ณด
|
| 249 |
if landform_key == 'fjord' and 'process_info' in metadata:
|
|
@@ -309,38 +343,52 @@ if landform_key in ANIMATED_LANDFORM_GENERATORS:
|
|
| 309 |
if 0 <= c < gallery_grid_size:
|
| 310 |
stage_water[r, c] = 3.0
|
| 311 |
|
| 312 |
-
#
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
force_camera=False, # ์นด๋ฉ๋ผ ์ด๋ ํ์ฉ
|
| 320 |
-
landform_type=landform_type
|
| 321 |
)
|
| 322 |
-
st.plotly_chart(fig_stage, use_container_width=True, key="stage_view")
|
| 323 |
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
st.
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
|
| 346 |
-
st.caption("๐ก **Tip:** ์นด๋ฉ๋ผ
|
|
|
|
| 14 |
|
| 15 |
from engine.ideal_landforms import IDEAL_LANDFORM_GENERATORS, ANIMATED_LANDFORM_GENERATORS
|
| 16 |
from app.components.renderer import render_terrain_plotly
|
| 17 |
+
from app.components.animation_renderer import create_animated_terrain_figure
|
| 18 |
|
| 19 |
st.header("๐ ์ด์์ ์งํ ๊ฐค๋ฌ๋ฆฌ")
|
| 20 |
st.markdown("_๊ต๊ณผ์์ ์ธ ์งํ ํํ๋ฅผ ๊ธฐํํ์ ๋ชจ๋ธ๋ก ์๊ฐํํฉ๋๋ค._")
|
|
|
|
| 240 |
# ๋จ๊ณ๋ณ ์ค๋ช
ํ์
|
| 241 |
st.success(metadata.get('stage_description', ''))
|
| 242 |
|
| 243 |
+
# ์ ์์ง ์กด ์ ๋ณด + ์์ ํ์ด๋ผ์ดํธ
|
| 244 |
if landform_key == 'alluvial_fan' and 'zone_info' in metadata:
|
| 245 |
+
with st.expander("๐ ์ธ๋ถ ๊ตฌ์กฐ ๋ณด๊ธฐ", expanded=True):
|
| 246 |
+
col_z1, col_z2, col_z3 = st.columns(3)
|
| 247 |
+
col_z1.markdown("๐ด **์ ์ (Apex)**<br>๊ฒฝ์ฌ 5-15ยฐ, ์ญ๋ ฅ", unsafe_allow_html=True)
|
| 248 |
+
col_z2.markdown("๐ก **์ ์(Mid)**<br>๊ฒฝ์ฌ 2-5ยฐ, ์ฌ์ง", unsafe_allow_html=True)
|
| 249 |
+
col_z3.markdown("๐ต **์ ๋จ(Toe)**<br>๊ฒฝ์ฌ <2ยฐ, ๋์ง", unsafe_allow_html=True)
|
| 250 |
+
|
| 251 |
+
show_zones = st.checkbox("๐จ ์กด ์์ ์ค๋ฒ๋ ์ด ํ์", value=False, key="show_zone_colors")
|
| 252 |
+
|
| 253 |
+
if show_zones and 'zone_mask' in metadata:
|
| 254 |
+
# ์กด ๋ง์คํฌ๋ฅผ ์์์ผ๋ก ํ์
|
| 255 |
+
st.info("๐ด ์ ์ | ๐ก ์ ์ | ๐ต ์ ๋จ")
|
| 256 |
+
|
| 257 |
+
import matplotlib.pyplot as plt
|
| 258 |
+
from matplotlib.colors import ListedColormap
|
| 259 |
+
|
| 260 |
+
zone_mask = metadata['zone_mask']
|
| 261 |
+
cmap = ListedColormap(['#4682B4', '#FFD700', '#FF6347', '#228B22']) # ๋ฐฐ๊ฒฝ, ์ ๋จ, ์ ์, ์ ์
|
| 262 |
+
|
| 263 |
+
fig_zone, ax = plt.subplots(figsize=(8, 6))
|
| 264 |
+
im = ax.imshow(zone_mask, cmap=cmap, origin='lower', alpha=0.8)
|
| 265 |
+
ax.contour(stage_elev, levels=10, colors='white', linewidths=0.5, alpha=0.5)
|
| 266 |
+
ax.set_title("์ ์์ง ์กด ๊ตฌ๋ถ")
|
| 267 |
+
ax.set_xlabel("X")
|
| 268 |
+
ax.set_ylabel("Y")
|
| 269 |
+
|
| 270 |
+
# ๋ฒ๋ก
|
| 271 |
+
from matplotlib.patches import Patch
|
| 272 |
+
legend_elements = [
|
| 273 |
+
Patch(facecolor='#FF6347', label='์ ์ (Apex)'),
|
| 274 |
+
Patch(facecolor='#FFD700', label='์ ์(Mid)'),
|
| 275 |
+
Patch(facecolor='#4682B4', label='์ ๋จ(Toe)')
|
| 276 |
+
]
|
| 277 |
+
ax.legend(handles=legend_elements, loc='upper right')
|
| 278 |
+
|
| 279 |
+
st.pyplot(fig_zone)
|
| 280 |
+
plt.close(fig_zone)
|
| 281 |
|
| 282 |
# ํผ์ค๋ฅด๋ ํ๋ก์ธ์ค ์ ๋ณด
|
| 283 |
if landform_key == 'fjord' and 'process_info' in metadata:
|
|
|
|
| 343 |
if 0 <= c < gallery_grid_size:
|
| 344 |
stage_water[r, c] = 3.0
|
| 345 |
|
| 346 |
+
# ์ ๋๋ฉ์ด์
๋ชจ๋ ์ ํ
|
| 347 |
+
st.markdown("---")
|
| 348 |
+
animation_mode = st.radio(
|
| 349 |
+
"์ ๋๋ฉ์ด์
๋ชจ๋",
|
| 350 |
+
["๐ฌ ๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
(์ถ์ฒ)", "๐ ์ฌ๋ผ์ด๋ ์๋ ์กฐ์"],
|
| 351 |
+
horizontal=True,
|
| 352 |
+
key="anim_mode"
|
|
|
|
|
|
|
| 353 |
)
|
|
|
|
| 354 |
|
| 355 |
+
if animation_mode == "๐ฌ ๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
(์ถ์ฒ)":
|
| 356 |
+
# Plotly ๋ค์ดํฐ๋ธ ์ ๋๋ฉ์ด์
(์นด๋ฉ๋ผ ์ ์ง!)
|
| 357 |
+
st.info("โถ๏ธ **์ฌ์** ๋ฒํผ์ ๋๋ฅด๋ฉด ์ ๋๋ฉ์ด์
์ด ์์๋ฉ๋๋ค. **์นด๋ฉ๋ผ๋ฅผ ์์ ๋กญ๊ฒ ์กฐ์**ํ ์ ์์ต๋๋ค!")
|
| 358 |
+
|
| 359 |
+
try:
|
| 360 |
+
fig_animated = create_animated_terrain_figure(
|
| 361 |
+
landform_func=anim_func,
|
| 362 |
+
grid_size=gallery_grid_size,
|
| 363 |
+
num_frames=20,
|
| 364 |
+
title=f"{selected_landform} ํ์ฑ ๊ณผ์ ",
|
| 365 |
+
landform_type=landform_type
|
| 366 |
+
)
|
| 367 |
+
st.plotly_chart(fig_animated, use_container_width=True, key="animated_view")
|
| 368 |
+
except Exception as e:
|
| 369 |
+
st.error(f"์ ๋๋ฉ์ด์
์์ฑ ์ค๋ฅ: {e}")
|
| 370 |
+
# ํด๋ฐฑ: ์ ์ ๋ ๋๋ง
|
| 371 |
+
fig_stage = render_terrain_plotly(
|
| 372 |
+
stage_elev,
|
| 373 |
+
f"{selected_landform} - {int(stage_value*100)}%",
|
| 374 |
+
add_water=True,
|
| 375 |
+
water_depth_grid=stage_water,
|
| 376 |
+
water_level=-999,
|
| 377 |
+
force_camera=False,
|
| 378 |
+
landform_type=landform_type
|
| 379 |
+
)
|
| 380 |
+
st.plotly_chart(fig_stage, use_container_width=True, key="stage_view_fallback")
|
| 381 |
+
else:
|
| 382 |
+
# ๊ธฐ์กด ์ฌ๋ผ์ด๋ ๋ฐฉ์
|
| 383 |
+
fig_stage = render_terrain_plotly(
|
| 384 |
+
stage_elev,
|
| 385 |
+
f"{selected_landform} - {int(stage_value*100)}%",
|
| 386 |
+
add_water=True,
|
| 387 |
+
water_depth_grid=stage_water,
|
| 388 |
+
water_level=-999,
|
| 389 |
+
force_camera=False,
|
| 390 |
+
landform_type=landform_type
|
| 391 |
+
)
|
| 392 |
+
st.plotly_chart(fig_stage, use_container_width=True, key="stage_view")
|
| 393 |
|
| 394 |
+
st.caption("๐ก **Tip:** '๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
' ๋ชจ๋์์๋ ์นด๋ฉ๋ผ๋ฅผ ์์ ๋กญ๊ฒ ์กฐ์ํ๋ฉด์ ์ฌ์ํ ์ ์์ต๋๋ค!")
|
pages/3_๐งช_Lab.py
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
๐งช Geo-Lab Script: ์ฌ์ฉ์ ์ฝ๋๋ก ์งํ ์์ฑ
|
| 3 |
+
Python ์ฝ๋๋ก ์ง์ ์งํ์ ์์ฑํ๊ณ ์กฐ์ํฉ๋๋ค.
|
| 4 |
+
"""
|
| 5 |
+
import streamlit as st
|
| 6 |
+
import numpy as np
|
| 7 |
+
import sys
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
# ์์ ๋๋ ํ ๋ฆฌ ๊ฒฝ๋ก ์ถ๊ฐ
|
| 11 |
+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 12 |
+
|
| 13 |
+
from engine.grid import WorldGrid
|
| 14 |
+
from engine.script_engine import ScriptExecutor
|
| 15 |
+
from app.components.renderer import render_terrain_plotly
|
| 16 |
+
from app.components.animation_renderer import create_animated_terrain_figure
|
| 17 |
+
from engine.ideal_landforms import IDEAL_LANDFORM_GENERATORS
|
| 18 |
+
|
| 19 |
+
st.set_page_config(page_title="๐งช Lab Script", page_icon="๐งช", layout="wide")
|
| 20 |
+
|
| 21 |
+
st.header("๐งช Geo-Lab Script")
|
| 22 |
+
st.markdown("_Python ์ฝ๋๋ก ์ง์ ์งํ์ ์์ฑํ๊ณ ์กฐ์ํฉ๋๋ค._")
|
| 23 |
+
|
| 24 |
+
# ์ฌ์ด๋๋ฐ ์ค์
|
| 25 |
+
st.sidebar.subheader("โ๏ธ ๊ทธ๋ฆฌ๋ ์ค์ ")
|
| 26 |
+
grid_size = st.sidebar.slider("๊ทธ๋ฆฌ๋ ํฌ๊ธฐ", 50, 200, 100)
|
| 27 |
+
|
| 28 |
+
# ํญ ๊ตฌ์ฑ
|
| 29 |
+
tab1, tab2, tab3 = st.tabs(["๐ ์ฝ๋ ํธ์ง", "๐ ์์ ์ฝ๋", "๐ ๋์๋ง"])
|
| 30 |
+
|
| 31 |
+
with tab1:
|
| 32 |
+
st.subheader("๐ ์ฝ๋ ํธ์ง๊ธฐ")
|
| 33 |
+
|
| 34 |
+
# ๊ธฐ๋ณธ ์ฝ๋ ํ
ํ๋ฆฟ
|
| 35 |
+
default_code = '''# Geo-Lab Script ์์
|
| 36 |
+
# ์ฌ์ฉ ๊ฐ๋ฅํ ๋ณ์: elevation, bedrock, sediment, water_depth, np, math
|
| 37 |
+
|
| 38 |
+
# 1. ๊ธฐ๋ณธ ์งํ ์์ฑ (ํํํ ํ์)
|
| 39 |
+
h, w = elevation.shape
|
| 40 |
+
elevation[:, :] = 10.0
|
| 41 |
+
|
| 42 |
+
# 2. ์ค์์ ์๋ฟํ ์ฐ ์ถ๊ฐ
|
| 43 |
+
center_y, center_x = h // 2, w // 2
|
| 44 |
+
for y in range(h):
|
| 45 |
+
for x in range(w):
|
| 46 |
+
dist = np.sqrt((y - center_y)**2 + (x - center_x)**2)
|
| 47 |
+
if dist < 30:
|
| 48 |
+
peak_height = 50.0 * (1 - dist / 30)
|
| 49 |
+
elevation[y, x] += peak_height
|
| 50 |
+
|
| 51 |
+
# 3. ํ์ฒ ์ถ๊ฐ (์ผ์ชฝ์์ ์ค๋ฅธ์ชฝ์ผ๋ก)
|
| 52 |
+
for x in range(w):
|
| 53 |
+
river_y = int(center_y + 10 * np.sin(x * 0.1))
|
| 54 |
+
for dy in range(-2, 3):
|
| 55 |
+
if 0 <= river_y + dy < h:
|
| 56 |
+
elevation[river_y + dy, x] -= 5.0
|
| 57 |
+
water_depth[river_y + dy, x] = 3.0
|
| 58 |
+
|
| 59 |
+
print("์งํ ์์ฑ ์๋ฃ!")
|
| 60 |
+
'''
|
| 61 |
+
|
| 62 |
+
# ์ธ์
์ํ์ ์ฝ๋ ์ ์ฅ
|
| 63 |
+
if 'user_script' not in st.session_state:
|
| 64 |
+
st.session_state['user_script'] = default_code
|
| 65 |
+
|
| 66 |
+
# ์ฝ๋ ํธ์ง๊ธฐ
|
| 67 |
+
user_code = st.text_area(
|
| 68 |
+
"Python ์ฝ๋",
|
| 69 |
+
value=st.session_state.get('user_script', default_code),
|
| 70 |
+
height=400,
|
| 71 |
+
key="code_editor"
|
| 72 |
+
)
|
| 73 |
+
st.session_state['user_script'] = user_code
|
| 74 |
+
|
| 75 |
+
col1, col2 = st.columns(2)
|
| 76 |
+
|
| 77 |
+
with col1:
|
| 78 |
+
run_button = st.button("โถ๏ธ ์คํ", type="primary", use_container_width=True)
|
| 79 |
+
with col2:
|
| 80 |
+
reset_button = st.button("๐ ์ด๊ธฐํ", use_container_width=True)
|
| 81 |
+
|
| 82 |
+
if reset_button:
|
| 83 |
+
st.session_state['user_script'] = default_code
|
| 84 |
+
st.rerun()
|
| 85 |
+
|
| 86 |
+
if run_button:
|
| 87 |
+
with st.spinner("์ฝ๋ ์คํ ์ค..."):
|
| 88 |
+
try:
|
| 89 |
+
# ๊ทธ๋ฆฌ๋ ์์ฑ
|
| 90 |
+
grid = WorldGrid(grid_size, grid_size)
|
| 91 |
+
executor = ScriptExecutor(grid)
|
| 92 |
+
|
| 93 |
+
# ์คํฌ๋ฆฝํธ ์คํ
|
| 94 |
+
success, message = executor.execute(user_code)
|
| 95 |
+
|
| 96 |
+
if success:
|
| 97 |
+
st.success(f"โ
{message}")
|
| 98 |
+
|
| 99 |
+
# ๊ฒฐ๊ณผ ์๊ฐํ
|
| 100 |
+
st.subheader("๐ ๊ฒฐ๊ณผ")
|
| 101 |
+
|
| 102 |
+
# 2D / 3D ์ ํ
|
| 103 |
+
view_mode = st.radio("๋ทฐ ๋ชจ๋", ["3D", "2D"], horizontal=True)
|
| 104 |
+
|
| 105 |
+
if view_mode == "3D":
|
| 106 |
+
fig = render_terrain_plotly(
|
| 107 |
+
grid.elevation,
|
| 108 |
+
"์คํฌ๋ฆฝํธ ๊ฒฐ๊ณผ",
|
| 109 |
+
add_water=True,
|
| 110 |
+
water_depth_grid=grid.water_depth,
|
| 111 |
+
water_level=-999,
|
| 112 |
+
force_camera=False
|
| 113 |
+
)
|
| 114 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 115 |
+
else:
|
| 116 |
+
import matplotlib.pyplot as plt
|
| 117 |
+
fig, ax = plt.subplots(figsize=(10, 8))
|
| 118 |
+
im = ax.imshow(grid.elevation, cmap='terrain', origin='lower')
|
| 119 |
+
plt.colorbar(im, ax=ax, label='Elevation (m)')
|
| 120 |
+
ax.set_title("2D ๊ณ ๋ ๋งต")
|
| 121 |
+
st.pyplot(fig)
|
| 122 |
+
|
| 123 |
+
# ํต๊ณ
|
| 124 |
+
st.markdown("**๐ ํต๊ณ:**")
|
| 125 |
+
col_s1, col_s2, col_s3, col_s4 = st.columns(4)
|
| 126 |
+
col_s1.metric("์ต์ ๊ณ ๋", f"{grid.elevation.min():.1f}m")
|
| 127 |
+
col_s2.metric("์ต๊ณ ๊ณ ๋", f"{grid.elevation.max():.1f}m")
|
| 128 |
+
col_s3.metric("ํ๊ท ๊ณ ๋", f"{grid.elevation.mean():.1f}m")
|
| 129 |
+
col_s4.metric("์์ญ ๋น์จ", f"{(grid.water_depth > 0).sum() / grid.water_depth.size * 100:.1f}%")
|
| 130 |
+
|
| 131 |
+
else:
|
| 132 |
+
st.error(f"โ {message}")
|
| 133 |
+
|
| 134 |
+
except Exception as e:
|
| 135 |
+
st.error(f"โ ์ค๋ฅ: {str(e)}")
|
| 136 |
+
|
| 137 |
+
with tab2:
|
| 138 |
+
st.subheader("๐ ๊ฒ์ฆ๋ ์งํ ๋ถ๋ฌ์ค๊ธฐ")
|
| 139 |
+
st.markdown("_์ด๋ฏธ ๊ตฌํ๋ ์งํ์ ๋ถ๋ฌ์์ ๋ณํํ๊ฑฐ๋ ํ์ตํ ์ ์์ต๋๋ค._")
|
| 140 |
+
|
| 141 |
+
# ์นดํ
๊ณ ๋ฆฌ๋ณ ์งํ ๋ชฉ๋ก
|
| 142 |
+
landform_categories = {
|
| 143 |
+
"๐ ํ์ฒ ์งํ": ["v_valley", "meander", "free_meander", "alluvial_fan", "incised_meander", "delta", "waterfall"],
|
| 144 |
+
"๐บ ์ผ๊ฐ์ฃผ": ["bird_foot_delta", "arcuate_delta", "cuspate_delta"],
|
| 145 |
+
"โ๏ธ ๋นํ ์งํ": ["u_valley", "cirque", "horn", "arete", "fjord", "drumlin"],
|
| 146 |
+
"๐ ํ์ฐ ์งํ": ["shield_volcano", "stratovolcano", "caldera", "cinder_cone"],
|
| 147 |
+
"๐ฆ ์นด๋ฅด์คํธ": ["karst_doline", "uvala", "tower_karst"],
|
| 148 |
+
"๐๏ธ ๊ฑด์กฐ ์งํ": ["barchan_dune", "mesa", "pedestal_rock", "wadi", "playa"],
|
| 149 |
+
"๐๏ธ ํด์ ์งํ": ["coastal_cliff", "spit", "lagoon", "tombolo"]
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
selected_cat = st.selectbox("์นดํ
๊ณ ๋ฆฌ ์ ํ", list(landform_categories.keys()))
|
| 153 |
+
available_landforms = [lf for lf in landform_categories[selected_cat] if lf in IDEAL_LANDFORM_GENERATORS]
|
| 154 |
+
|
| 155 |
+
if available_landforms:
|
| 156 |
+
selected_landform = st.selectbox("์งํ ์ ํ", available_landforms)
|
| 157 |
+
|
| 158 |
+
col1, col2 = st.columns(2)
|
| 159 |
+
|
| 160 |
+
with col1:
|
| 161 |
+
load_size = st.slider("๊ทธ๋ฆฌ๋ ํฌ๊ธฐ", 50, 150, 100, key="load_size")
|
| 162 |
+
with col2:
|
| 163 |
+
load_stage = st.slider("ํ์ฑ ๋จ๊ณ", 0.0, 1.0, 1.0, 0.1, key="load_stage")
|
| 164 |
+
|
| 165 |
+
if st.button("๐ ์งํ ๋ถ๋ฌ์ค๊ธฐ", type="primary", use_container_width=True):
|
| 166 |
+
try:
|
| 167 |
+
# ์งํ ์์ฑ ํจ์ ํธ์ถ
|
| 168 |
+
landform_func = IDEAL_LANDFORM_GENERATORS[selected_landform]
|
| 169 |
+
|
| 170 |
+
# stage ํ๋ผ๋ฏธํฐ ์ง์ ์ฌ๋ถ ํ์ธ
|
| 171 |
+
import inspect
|
| 172 |
+
sig = inspect.signature(landform_func)
|
| 173 |
+
params = list(sig.parameters.keys())
|
| 174 |
+
|
| 175 |
+
if 'stage' in params:
|
| 176 |
+
result = landform_func(load_size, load_stage)
|
| 177 |
+
else:
|
| 178 |
+
result = landform_func(load_size)
|
| 179 |
+
|
| 180 |
+
# ๊ฒฐ๊ณผ ์ฒ๋ฆฌ (tuple์ธ ๊ฒฝ์ฐ elevation๋ง ์ถ์ถ)
|
| 181 |
+
if isinstance(result, tuple):
|
| 182 |
+
elevation = result[0]
|
| 183 |
+
else:
|
| 184 |
+
elevation = result
|
| 185 |
+
|
| 186 |
+
st.success(f"โ
{selected_landform} ์งํ ๋ถ๋ฌ์ค๊ธฐ ์๋ฃ!")
|
| 187 |
+
|
| 188 |
+
# 3D ์๊ฐํ
|
| 189 |
+
fig = render_terrain_plotly(
|
| 190 |
+
elevation,
|
| 191 |
+
f"{selected_landform} (Stage {int(load_stage*100)}%)",
|
| 192 |
+
add_water=True,
|
| 193 |
+
water_level=-999,
|
| 194 |
+
force_camera=False
|
| 195 |
+
)
|
| 196 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 197 |
+
|
| 198 |
+
# ํต๊ณ
|
| 199 |
+
col_s1, col_s2, col_s3 = st.columns(3)
|
| 200 |
+
col_s1.metric("์ต์ ๊ณ ๋", f"{elevation.min():.1f}m")
|
| 201 |
+
col_s2.metric("์ต๊ณ ๊ณ ๋", f"{elevation.max():.1f}m")
|
| 202 |
+
col_s3.metric("ํ๊ท ๊ณ ๋", f"{elevation.mean():.1f}m")
|
| 203 |
+
|
| 204 |
+
# ์ฝ๋ ํ์ธ
|
| 205 |
+
with st.expander("๐ป ์ด ์งํ์ ์ฝ๋ ๋ณด๊ธฐ"):
|
| 206 |
+
st.markdown(f"""
|
| 207 |
+
```python
|
| 208 |
+
from engine.ideal_landforms import IDEAL_LANDFORM_GENERATORS
|
| 209 |
+
|
| 210 |
+
# ์งํ ์์ฑ
|
| 211 |
+
landform_func = IDEAL_LANDFORM_GENERATORS['{selected_landform}']
|
| 212 |
+
elevation = landform_func(grid_size={load_size}, stage={load_stage})
|
| 213 |
+
|
| 214 |
+
# ๊ฒฐ๊ณผ: {elevation.shape} ํฌ๊ธฐ์ ๊ณ ๋ ๋ฐฐ์ด
|
| 215 |
+
# ์ต์ : {elevation.min():.1f}m, ์ต๊ณ : {elevation.max():.1f}m
|
| 216 |
+
```
|
| 217 |
+
|
| 218 |
+
**ํจ์ ์์ค ์์น:** `engine/ideal_landforms.py` โ `create_{selected_landform}()`
|
| 219 |
+
""")
|
| 220 |
+
|
| 221 |
+
except Exception as e:
|
| 222 |
+
st.error(f"โ ์ค๋ฅ: {str(e)}")
|
| 223 |
+
else:
|
| 224 |
+
st.warning("์ด ์นดํ
๊ณ ๋ฆฌ์ ์ฌ์ฉ ๊ฐ๋ฅํ ์งํ์ด ์์ต๋๋ค.")
|
| 225 |
+
|
| 226 |
+
st.markdown("---")
|
| 227 |
+
st.markdown("""
|
| 228 |
+
### ๐ก ํ: ์ง์ ์ฝ๋ ์ง๋ ๋ฒ
|
| 229 |
+
|
| 230 |
+
**๊ธฐ๋ณธ ํจํด:**
|
| 231 |
+
```python
|
| 232 |
+
h, w = elevation.shape
|
| 233 |
+
center_y, center_x = h // 2, w // 2
|
| 234 |
+
|
| 235 |
+
for y in range(h):
|
| 236 |
+
for x in range(w):
|
| 237 |
+
dist = np.sqrt((y - center_y)**2 + (x - center_x)**2)
|
| 238 |
+
# ๊ฑฐ๋ฆฌ ๊ธฐ๋ฐ ๋์ด ๊ณ์ฐ
|
| 239 |
+
elevation[y, x] = ๋์ด๊ณต์(dist)
|
| 240 |
+
```
|
| 241 |
+
|
| 242 |
+
**ํต์ฌ ์์น:**
|
| 243 |
+
1. `elevation[:, :]`๋ก ์ ์ฒด ์ด๊ธฐํ
|
| 244 |
+
2. for ๋ฃจํ๋ก ๊ฐ ์
์ํ
|
| 245 |
+
3. ๊ฑฐ๋ฆฌ ๊ธฐ๋ฐ ๋์ด ๊ณต์ ์ ์ฉ
|
| 246 |
+
4. `water_depth`๋ก ๋ฌผ ํ์
|
| 247 |
+
""")
|
| 248 |
+
|
| 249 |
+
with tab3:
|
| 250 |
+
st.subheader("๐ ๋์๋ง")
|
| 251 |
+
|
| 252 |
+
st.markdown("""
|
| 253 |
+
### ์ฌ์ฉ ๊ฐ๋ฅํ ๋ณ์
|
| 254 |
+
|
| 255 |
+
| ๋ณ์ | ํ์
| ์ค๋ช
|
|
| 256 |
+
|------|------|------|
|
| 257 |
+
| `elevation` | np.ndarray | ๊ณ ๋ ๋ฐฐ์ด (์์ ๊ฐ๋ฅ) |
|
| 258 |
+
| `bedrock` | np.ndarray | ๊ธฐ๋ฐ์ ๋ฐฐ์ด |
|
| 259 |
+
| `sediment` | np.ndarray | ํด์ ๋ฌผ ๋ฐฐ์ด |
|
| 260 |
+
| `water_depth` | np.ndarray | ์์ฌ ๋ฐฐ์ด |
|
| 261 |
+
| `np` | module | NumPy ๋ชจ๋ |
|
| 262 |
+
| `math` | module | math ๋ชจ๋ |
|
| 263 |
+
|
| 264 |
+
### ๊ธฐ๋ณธ ํจํด
|
| 265 |
+
|
| 266 |
+
```python
|
| 267 |
+
# ๊ทธ๋ฆฌ๋ ํฌ๊ธฐ ๊ฐ์ ธ์ค๊ธฐ
|
| 268 |
+
h, w = elevation.shape
|
| 269 |
+
|
| 270 |
+
# ์ ์ฒด ๊ณ ๋ ์ค์
|
| 271 |
+
elevation[:, :] = 10.0
|
| 272 |
+
|
| 273 |
+
# ํน์ ์์ญ ์์
|
| 274 |
+
elevation[10:20, 30:40] = 50.0
|
| 275 |
+
|
| 276 |
+
# ๊ฑฐ๋ฆฌ ๊ธฐ๋ฐ ์งํ
|
| 277 |
+
for y in range(h):
|
| 278 |
+
for x in range(w):
|
| 279 |
+
dist = np.sqrt((y - center_y)**2 + (x - center_x)**2)
|
| 280 |
+
elevation[y, x] = some_function(dist)
|
| 281 |
+
```
|
| 282 |
+
|
| 283 |
+
### ์ฃผ์์ฌํญ
|
| 284 |
+
|
| 285 |
+
- `import` ๋ฌธ์ ์ฌ์ฉํ ์ ์์ต๋๋ค (๋ณด์)
|
| 286 |
+
- `open()`, `exec()`, `eval()` ์ฌ์ฉ ๋ถ๊ฐ
|
| 287 |
+
- ๋ฌดํ ๋ฃจํ ์ฃผ์ (๋ธ๋ผ์ฐ์ ๊ฐ ๋ฉ์ถ ์ ์์)
|
| 288 |
+
""")
|