Last active
June 7, 2026 00:32
-
-
Save kvpb/f882f3df9c340bc2bd6e31800c20a3e4 to your computer and use it in GitHub Desktop.
Calculate Red, Green, Blue, Yellow legal wild 'mon DV combinations for a given encounter 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 | |
| rate_encounter: int # Nidorans' encounter rate is 25. | |
| game: str # values: "Red" or "Green" or "Blue" and "Yellow"; | |
| DV_ATKDEF: int | |
| DV_SPDSPC: int | |
| spread_DV: list[ int ] | |
| spread_DV_possible: list[ bool ] # 'array' of false, table of slots for every spread. | |
| positions_SPDSPC: list[ int ] | |
| positions_ATKDEF: list[ int ] | |
| positions_encounter: list[ int ] | |
| overflow_SPDSPC: int | |
| overflow_ATKDEF: int | |
| value_encounter: int | |
| value_random: int | |
| index_SPDSPC: int | |
| index_ATKDEF: int | |
| index_encounter: int | |
| position_SPDSPC: int | |
| position_ATKDEF: int | |
| position_encounter: int | |
| value_encounter_random: int | |
| value_random_SPDSPC: int | |
| value_ATKDEF_random: int | |
| rate_encounter = 25 #5 #10 #15 #20 #30 | |
| game = "Green" | |
| spread_DV_possible = ( 16 * 16 * 16 * 16 ) * [ False ] # == [ False, False, False, ... ] | |
| if game == "Yellow": | |
| positions_SPDSPC = [ 47, 48, 49 ] | |
| positions_ATKDEF = [ 1, 2, 3 ] | |
| positions_encounter = [ 0, 1 ] | |
| elif game == "Red" or game == "Green" or game == "Blue": | |
| positions_SPDSPC = [ 45, 46, 47 ] | |
| positions_ATKDEF = [ 1, 2, 3 ] | |
| positions_encounter = [ 0 ] | |
| else: | |
| print("Couldn't validate the game.") | |
| exit() | |
| overflow_SPDSPC = 1 | |
| overflow_ATKDEF = 1 | |
| value_encounter = 0 | |
| while value_encounter < rate_encounter: | |
| value_random = 0 | |
| while value_random < 256: | |
| index_SPDSPC = 0 | |
| while index_SPDSPC < len( positions_SPDSPC ): | |
| index_ATKDEF = 0 | |
| while index_ATKDEF < len( positions_ATKDEF ): | |
| index_encounter = 0 | |
| while index_encounter < len( positions_encounter ): | |
| position_SPDSPC = positions_SPDSPC[ index_SPDSPC ] | |
| position_ATKDEF = positions_ATKDEF[ index_ATKDEF ] | |
| position_encounter = positions_encounter[ index_encounter ] | |
| value_encounter_random = ( value_encounter + value_random + position_encounter ) % 256 | |
| value_random_SPDSPC = ( value_random + position_SPDSPC ) % 256 | |
| DV_SPDSPC = ( value_encounter_random + value_random_SPDSPC + overflow_SPDSPC ) % 256 | |
| value_ATKDEF_random = ( value_random_SPDSPC + position_ATKDEF ) % 256 | |
| DV_ATKDEF = ( DV_SPDSPC + value_ATKDEF_random + overflow_ATKDEF ) % 256 | |
| spread_DV_possible[ ( DV_ATKDEF << 8 ) + DV_SPDSPC ] = True # When a possible spread has been found, mark its slot True. | |
| index_encounter += 1 | |
| index_ATKDEF += 1 | |
| index_SPDSPC += 1 | |
| value_random += 1 | |
| value_encounter += 1 | |
| DV_ATKDEF = 0 | |
| while DV_ATKDEF < 256: | |
| DV_SPDSPC = 0 | |
| while DV_SPDSPC < 256: | |
| if spread_DV_possible[ ( DV_ATKDEF << 8 ) + DV_SPDSPC ]: | |
| spread_DV = [ | |
| ( 0b11110000 & DV_ATKDEF ) >> 4, | |
| 0b00001111 & DV_ATKDEF, | |
| ( 0b11110000 & DV_SPDSPC ) >> 4, | |
| 0b00001111 & DV_SPDSPC | |
| ] | |
| print( "[ " + f"{spread_DV[ 0 ]:2d}" + ", " + f"{spread_DV[ 1 ]:2d}" + ", " + f"{spread_DV[ 2 ]:2d}" + ", " + f"{spread_DV[ 3 ]:2d}" + " ]" ) # Green, trainer escape glitch, here I come. | |
| DV_SPDSPC += 1 | |
| DV_ATKDEF += 1 | |
| # calculatergbywildmondv.py | |
| # G1 Wild DV Calculator | |
| # | |
| # Karl V. P. B. `kvpb` AKA Karl Thomas George West `ktgw` | |
| # +33 A BB BB BB BB +1 (DDD) DDD-DDDD | |
| # local-part@domain local-part@domain | |
| # https://x.com/ktgwkvpb | |
| # https://github.com/kvpb | |
| # Copyright 2024 Karl Vincent Pierre Bertin | |
| # | |
| # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | |
| # | |
| # 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | |
| # | |
| # 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | |
| # | |
| # 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | |
| # | |
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment