import random def battle(): # CHANGE THE BELOW VALUES TO TEST FOR EACH STAT THEN HIT "RUN" AND CHECK THE RESULTS AT THE BOTTOM u_atk = 7 u_hp = 3 # CHANGE THE ABOVE VALUES TO TEST FOR EACH STAT THEN HIT "RUN" AND CHECK THE RESULTS AT THE BOTTOM o_atk = 5 o_hp = 5 u_exp = 0 o_exp = 0 u_streak = 0 o_streak = 0 match = 0 rnd = 0 u_hp_left = u_hp o_hp_left = o_hp while match < 100000: while (u_hp_left > 0 and o_hp_left > 0) and rnd < 3: u_hit = random.randint(0, u_atk) o_hit = random.randint(0, o_atk) u_hp_left -= o_hit o_hp_left -= u_hit rnd += 1 else: if ((u_hp_left > 0 and o_hp_left > 0) or (u_hp_left == 0 and o_hp_left == 0)): u_exp += 5 o_exp += 5 elif u_hp_left <= 0 and o_hp_left > 0: o_streak += 1 o_exp += 14 + o_streak u_streak = 0 elif o_hp_left <= 0 and u_hp_left > 0: u_streak += 1 u_exp += 14 + u_streak o_streak = 0 u_hp_left = u_hp o_hp_left = o_hp rnd = 0 match += 1 print("Tested EXP after 100k battles: " + str(u_exp)) print("Average opponent's EXP after 100k battles: " + str(o_exp)) battle()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question