Created
November 28, 2014 22:05
-
-
Save aclissold/9301a199e4a8bf93bb0d to your computer and use it in GitHub Desktop.
Pokéball success rate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from math import sqrt | |
| def main(): | |
| '''Display the probability of successfully capturing a Pokémon.''' | |
| # Read in the formulae parameters. | |
| max_hp = int(input('Max HP: ')) | |
| hp = int(input('Remaining HP: ')) | |
| catch_rate = int(input('Catch rate: ')) | |
| ball_modifier = int(input('Ball modifier: ')) | |
| status_modifier = int(input('Status modifier: ')) | |
| # Compute and print the results. | |
| a = ((((3*max_hp - 2*hp ) * (catch_rate*ball_modifier )) / | |
| (3*max_hp)) * status_modifier) | |
| b = 1048560 / sqrt(sqrt(16711680 / a)) | |
| p = ((b+1)/2**16)**4 | |
| print(str(100*p) + '% chance.') | |
| if __name__ == '__main__': | |
| try: | |
| main() | |
| except KeyboardInterrupt: | |
| exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment