Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """duels"""
- import random as r
- DMG = 40
- GLOBAL_CTH = 1.0
- CTH_BODY = 1.0*GLOBAL_CTH
- CTH_HEAD = 0.25*GLOBAL_CTH
- ARMOUR = 50
- HP = 100+ARMOUR
- def duel(sim=0):
- player_4_body = HP
- player_4_head = HP
- while(player_4_body > 0 and player_4_head > 0):
- #players shooting at the same time.
- if sim==0:
- player_4_head -= DMG*1 if r.random()<CTH_BODY else 0
- player_4_body -= DMG*4 if r.random()<CTH_HEAD else 0
- #print(f"{player_4_head=}, {player_4_body=}")
- #player going for body goes first
- if sim==1:
- player_4_head -= DMG*1 if r.random()<CTH_BODY else 0
- if player_4_head <= 0:
- break
- player_4_body -= DMG*4 if r.random()<CTH_HEAD else 0
- #player going for head goes first
- if sim==2:
- player_4_body -= DMG*4 if r.random()<CTH_HEAD else 0
- if player_4_body <= 0:
- break
- player_4_head -= DMG*1 if r.random()<CTH_BODY else 0
- return "Head" if player_4_body<=0 else "Body"
- if __name__ == "__main__":
- stats = [duel(sim=1) for i in range(123456)]
- #print(stats)
- heads = stats.count("Head")
- total = len(stats)
- print(f"{heads} of {total} is {round((heads/total)*100)}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement