Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- #Yes, this was drafted by chat gpt initially
- #I modified few parts like scale, armor and Player/PC
- #it looks right? maybe?
- #https://pastebin.com/7MhuWAZk
- class Player:
- def __init__(self, name, tier, hp, stress, evasion, bt_minor, bt_major, bs, scales=1):
- self.name = name
- self.tier = tier
- self.base_hp = hp
- self.base_stress = stress
- self.evasion = evasion
- self.bt_minor = bt_minor
- self.bt_major = bt_major
- self.bs = bs
- self.scales = scales #scales feature
- def reset(self):
- self.hp = self.base_hp
- self.stress = self.base_stress
- self.armor = self.bs
- self.hits_taken = 0
- def take_hit(self, hit_value):
- if hit_value < self.evasion:
- self.hits_taken += 1
- return #Evade
- #dmg range
- dmg = 0
- if hit_value < self.bt_minor:
- dmg = 1
- elif hit_value < self.bt_major:
- dmg = 2
- elif hit_value < 2 * self.bt_major:
- dmg = 3
- else:
- dmg = 4
- #reduce armor using scales ancestry stress+bs
- if self.scales and dmg>(3-self.scales) and self.armor and self.stress:
- dmg -= 1
- self.stress -= 1
- self.armor -= 1
- #reduce dmg by armor
- if dmg and self.armor:
- dmg -= 1
- self.armor -= 1
- self.hp -= dmg
- self.hits_taken += 1
- class NPC:
- def __init__(self, difficulty, tier, dice_count, dice_sides, bonus):
- self.difficulty = difficulty
- self.tier = tier
- self.dice_count = dice_count
- self.dice_sides = dice_sides
- self.bonus = bonus
- def roll_hit(self):
- return sum(random.randint(1, self.dice_sides) for _ in range(self.dice_count)) + self.bonus
- # Variants
- pc_variants = [
- # Natural
- Player("natural", tier=1, hp=4, stress=6, evasion=14, bt_minor=4, bt_major=8, bs=4, scales=1 ),
- Player("natural", tier=3, hp=6, stress=7, evasion=16, bt_minor=8, bt_major=22, bs=6, scales=1 ),
- Player("natural", tier=4, hp=7, stress=8, evasion=19, bt_minor=10, bt_major=29, bs=7, scales=1 ),
- # Gambeson
- Player("gambeson", tier=1, hp=4, stress=6, evasion=13, bt_minor=5, bt_major=11, bs=3, scales=1),
- Player("gambeson", tier=3, hp=6, stress=7, evasion=14, bt_minor=9, bt_major=23, bs=5, scales=1),
- Player("gambeson", tier=4, hp=7, stress=8, evasion=16, bt_minor=11, bt_major=32, bs=6, scales=1),
- # miscArmor
- Player("miscArmor", tier=1, hp=4, stress=6, evasion=12, bt_minor=6, bt_major=13, bs=3, scales=1), #Leather
- Player("miscArmor", tier=3, hp=6, stress=7, evasion=14, bt_minor=11, bt_major=27, bs=5, scales=1), #Bellamoi Fine Armor
- Player("miscArmor", tier=4, hp=7, stress=8, evasion=16, bt_minor=13, bt_major=36, bs=5, scales=1), #channeling armor
- ]
- npc_variants = [
- #tier 1
- NPC("Patc", tier=1, dice_count=1, dice_sides=20, bonus=0),
- NPC("Toug", tier=1, dice_count=3, dice_sides=8, bonus=2),
- NPC("Hard", tier=1, dice_count=2, dice_sides=12, bonus=6),
- #tier 3
- NPC("Flic", tier=3, dice_count=3, dice_sides=20, bonus=0),
- NPC("Jeal", tier=3, dice_count=3, dice_sides=8, bonus=3),
- NPC("Hubr", tier=3, dice_count=3, dice_sides=10, bonus=0),
- NPC("Eart", tier=3, dice_count=2, dice_sides=12, bonus=5),
- NPC("Head", tier=4, dice_count=2, dice_sides=20, bonus=4),
- #tier 4
- NPC("Oute", tier=4, dice_count=4, dice_sides=6, bonus=13),
- NPC("Hall", tier=4, dice_count=4, dice_sides=8, bonus=8),
- NPC("High", tier=4, dice_count=4, dice_sides=10, bonus=10),
- NPC("Fall", tier=4, dice_count=4, dice_sides=12, bonus=13),
- ]
- SIMULATIONS = 1000 #No. simulation repeats per scenario
- hit_cap = 25 #Quit current scenario after hit_cap. By then we likely got enough data or the scenario always evades
- results = []
- for pc in pc_variants:
- for npc in npc_variants:
- if npc.tier != pc.tier:
- continue # Only match same-tier NPCs
- total_hits = 0
- sim_count = 0
- full_evade_count = 0
- for _ in range(SIMULATIONS):
- pc.reset()
- while pc.hp > 0 and pc.hits_taken < hit_cap:
- roll = npc.roll_hit()
- pc.take_hit(roll)
- if pc.hits_taken >= hit_cap and pc.hp > 0:
- full_evade_count += 1
- continue
- else:
- total_hits += pc.hits_taken
- sim_count += 1
- avg_hits = (total_hits / sim_count) if sim_count > 0 else float('nan')
- results.append({
- "pc": pc.name,
- "tier": pc.tier,
- "npc": npc.difficulty,
- "avg_hits_survived": avg_hits,
- "always_evaded": full_evade_count
- })
- # Detailed results
- for r in results:
- print(f"Player: {r['pc']:9} | Tier: {r['tier']} | NPC: {r['npc']:6} | "
- f"Avg Hits: {r['avg_hits_survived']:.2f} | Evaded: {r['always_evaded']}")
- # Summary per Player variant
- summary = {}
- evade_summary = {}
- for r in results:
- summary.setdefault(r["pc"], []).append(r["avg_hits_survived"])
- evade_summary.setdefault(r["pc"], 0)
- evade_summary[r["pc"]] += r["always_evaded"]
- print("\nArmor type : avg hits survived | Evade counter")
- for pc_name, hits_list in summary.items():
- valid_hits = [h for h in hits_list if not isinstance(h, float) or not (h != h)] # exclude NaN
- if valid_hits:
- avg = sum(valid_hits) / len(valid_hits) if valid_hits else 0
- avg_str = f"{avg:.2f}"
- else:
- avg_str = "--"
- print(f"{pc_name:9}: {avg_str:>5} | Evaded: {evade_summary[pc_name]}")
Advertisement
Add Comment
Please, Sign In to add comment