ポケモンの代表的な数学をPythonでまとめました。
# プログラム名: garchomp_statistical_analysis.py
# 概要: ガブリアスの種族値を統計学的に分析(平均、分散、標準偏差、Zスコア)し、プロットで可視化する
# Purpose: Analyze Garchomp's base stats using descriptive statistics and visualize them
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# --- スタイル設定 / Optional style settings ---
sns.set(style="whitegrid")
# --- ガブリアスの種族値 / Garchomp's base stats ---
stats = {
'HP': 108,
'Attack': 130,
'Defense': 95,
'Sp.Atk': 80,
'Sp.Def': 85,
'Speed': 102
}
# --- 配列に変換 / Convert to arrays ---
labels = list(stats.keys()) # 能力名 / Stat names
values = np.array(list(stats.values())) # 種族値配列 / Stat values
# --- 統計量計算 / Calculate statistics ---
mean_val = np.mean(values) # 平均 / Mean
var_val = np.var(values) # 分散 / Variance
std_val = np.std(values) # 標準偏差 / Standard Deviation
z_scores = (values - mean_val) / std_val # Zスコア / Z-scores
# --- 統計情報出力 / Print statistics ---
print(" Garchomp Base Stat Analysis")
print(f"Mean: {mean_val:.2f}")
print(f"Variance: {var_val:.2f}")
print(f"Standard Deviation: {std_val:.2f}")
print("Z-scores:")
for label, z in zip(labels, z_scores):
print(f" {label}: {z:.2f}")
# --- プロット①:種族値の棒グラフ / Bar plot of base stats ---
plt.figure(figsize=(10, 4))
sns.barplot(x=labels, y=values, palette="rocket")
plt.title("Garchomp's Base Stats")
plt.xlabel("Stat")
plt.ylabel("Value")
plt.ylim(0, 150)
plt.tight_layout()
plt.show()
# --- プロット②:Zスコアの棒グラフ / Z-score bar plot ---
plt.figure(figsize=(10, 4))
sns.barplot(x=labels, y=z_scores, palette="viridis")
plt.title("Garchomp's Base Stat Z-scores")
plt.xlabel("Stat")
plt.ylabel("Z-score")
plt.axhline(0, color='black', linestyle='--')
plt.tight_layout()
plt.show()
# プログラム名: stat_calc_quick_formula.py
# 概要: ポケモンの種族値から実数値を簡易計算(個体値31、努力値252、性格補正あり)
# Purpose: Quick calculation of real stats with IV=31, EV=252, and nature boost (×1.1)
def quick_stat_calc(base_stat: int) -> int:
"""
個体値31・努力値252振り・性格補正1.1倍のときの実数値を即時計算
Calculate the real stat under the assumptions: IV=31, EV=252, nature boost (+10%)
Parameters:
base_stat (int): 種族値 / Base stat
Returns:
int: 実数値(小数点以下切り捨て)/ Final stat
"""
raw = base_stat + 52 # 努力値+個体値による補正合計(簡略化)
boost = raw + int(raw * 0.1) # 性格補正 +10%
return boost
# --- 使用例 / Example usage ---
example_stats = [130, 125, 100, 95, 80]
print(" 実数値(個体値31・努力値252・性格補正あり)")
for base in example_stats:
result = quick_stat_calc(base)
print(f"種族値 {base} → 実数値 {result}")
# プログラム名: garchomp_max_roll_damage.py
# 概要: ガブリアスがクレセリアに逆鱗を撃った際の最大乱数ダメージを計算
# Purpose: Calculate max roll damage from Garchomp's Outrage to defensive Cresselia
import math
# --- パラメータ定義 / Define parameters ---
level = 50 # レベル / Level
power = 120 # 技の威力 / Move power (Outrage)
attack = 182 # ガブリアス攻撃実数値 / Garchomp's Attack
defense = 189 # クレセリア防御実数値 / Cresselia's Defense
stab = 1.5 # タイプ一致補正 / STAB
modifiers = stab * 1.0 # その他補正なし(乱数最大 → ×1.0)
# --- ダメージ計算 / Damage formula ---
def calculate_damage(level, power, attack, defense, modifier):
base = ((2 * level / 5 + 2) * power * attack / defense) / 50 + 2
damage = math.floor(base * modifier)
return damage
# --- 計算実行 / Compute max roll damage ---
max_damage = calculate_damage(level, power, attack, defense, modifiers)
# --- 出力 / Output ---
print(f" Maximum Damage (乱数最大): {max_damage}")