File size: 2,057 Bytes
2afa69c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import numpy as np
import plotly.graph_objects as go
# Mock functions from main.py
def simulate_stream_piracy(time_years: int, params: dict, grid_size: int = 100):
"""ํ์ฒ์ํ ์๋ฎฌ๋ ์ด์
- ๊ต๊ณผ์์ ์ด์์ ๋ชจ์ต"""
x = np.linspace(0, 1000, grid_size)
y = np.linspace(0, 1000, grid_size)
X, Y = np.meshgrid(x, y)
elevation = 150 - Y * 0.1
ridge_x = 500
ridge = 20 * np.exp(-((X - ridge_x)**2) / (80**2))
elevation += ridge
river1_x = 300
river1_valley = 30 * np.exp(-((X - river1_x)**2) / (40**2))
elevation -= river1_valley
river2_x = 700
erosion_diff = params.get('erosion_diff', 0.7)
river2_depth = 50 * erosion_diff
river2_valley = river2_depth * np.exp(-((X - river2_x)**2) / (50**2))
elevation -= river2_valley
# ... logic ...
# Simplified logic for t=5000 (not captured)
return {'elevation': elevation, 'captured': False}
def render_terrain_plotly_debug(elevation):
print(f"Elevation stats: Min={elevation.min()}, Max={elevation.max()}, NaNs={np.isnan(elevation).sum()}")
dy, dx = np.gradient(elevation)
print(f"Gradient stats: dx_NaN={np.isnan(dx).sum()}, dy_NaN={np.isnan(dy).sum()}")
slope = np.sqrt(dx**2 + dy**2)
print(f"Slope stats: Min={slope.min()}, Max={slope.max()}, NaNs={np.isnan(slope).sum()}")
biome = np.zeros_like(elevation)
biome[:] = 1
# ...
noise = np.random.normal(0, 0.2, elevation.shape)
biome_noisy = np.clip(biome + noise, 0, 3)
print(f"Biome Noisy stats: Min={biome_noisy.min()}, Max={biome_noisy.max()}, NaNs={np.isnan(biome_noisy).sum()}")
realistic_colorscale = [
[0.0, '#E6C288'], [0.25, '#E6C288'],
[0.25, '#2E8B57'], [0.5, '#2E8B57'],
[0.5, '#696969'], [0.75, '#696969'],
[0.75, '#FFFFFF'], [1.0, '#FFFFFF']
]
print("Colorscale:", realistic_colorscale)
if __name__ == "__main__":
res = simulate_stream_piracy(5000, {'erosion_diff': 0.7})
elev = res['elevation']
render_terrain_plotly_debug(elev)
|