Talk:Size and weight variation

Add topic
Active discussions

Gen III-IV min/max size odds

Decided to run calcs on the chances of min/max sizes in gen II-IV and here are my results;

Total personality values checked: 1099511627776
Number of personality values with maximum size: 436207616
Number of personality values with minimum size: 167772160
Values processed per minute: 235767534.877467
Total time elapsed: 279812.47588157654 seconds

Calculated odds

Smallest Size: 1/6553.6

Largest Size: 1/2,520.6153846153846153846153846154

My code just in case anyone is curious how these were calculated, I iterated through all the s values of all 16bitPID/ID' combos and sorted the values accordingly

Code

    import time
    
    def calculate_size():
        # Constants for the calculation
        h = 10  # Species' height in tenths of a meter
    
        # Initialize counters for maximum and minimum size counts
        max_size_count = 0
        min_size_count = 0
        total_values_checked = 0
   
       # Start time
       start_time = time.time()
    
        # Iterate through all possible combinations of the last 16 bits of the PID
        for last_16_bits in range(65536):
            # Iterate through all possible IV prime combinations
            for HP_prime in range(16):
                for Atk_prime in range(16):
                    for Def_prime in range(16):
                        for Spd_prime in range(16):
                            for SpAtk_prime in range(16):
                                for SpDef_prime in range(16):
                                    # Calculate the intermediate value 's'
                                    p1 = last_16_bits % 256
                                    p2 = (last_16_bits // 256) % 256
                                    s = 256 * (p1 ^ (HP_prime * (Atk_prime ^ Def_prime))) + (p2 ^ (Spd_prime * (SpAtk_prime ^ SpDef_prime)))
    
                                    # Check if s is within the range [0, 9] for minimum size
                                    if 0 <= s <= 9:
                                        min_size_count += 1
    
                                    # Check if s is within the range [65510, 65535] for maximum size
                                    if 65510 <= s <= 65535:
                                        max_size_count += 1
    
                                    total_values_checked += 1
    
                                    # Print progress update for every 1 billion values checked
                                    if total_values_checked % 1000000000 == 0:
                                        completion_percentage = (total_values_checked / (65536 * 16**6)) * 100
                                        elapsed_time = time.time() - start_time
                                        print(f"Progress: Checked {total_values_checked} values. Completion: {completion_percentage:.2f}%. Elapsed Time: {elapsed_time:.2f} seconds. Maximum values found: {max_size_count}. Minimum values found: {min_size_count}")
    
        # End time
        end_time = time.time()
    
        # Calculate elapsed time in seconds
        elapsed_time = end_time - start_time
    
        print("Total personality values checked:", total_values_checked)
        print("Number of personality values with maximum size:", max_size_count)
        print("Number of personality values with minimum size:", min_size_count)
        print("Values processed per minute:", total_values_checked / (elapsed_time / 60))
    
        return max_size_count, min_size_count, total_values_checked, elapsed_time
    
    
    # Call the function to calculate the count of maximum and minimum size personality values
    max_count, min_count, total_checked, elapsed_time = calculate_size()
    
    # Write output to file
    with open("output.txt", "w") as file:
        file.write(f"Total personality values checked: {total_checked}\n")
        file.write(f"Number of personality values with maximum size: {max_count}\n")
        file.write(f"Number of personality values with minimum size: {min_count}\n")
        file.write(f"Values processed per minute: {total_checked / (elapsed_time / 60)}\n")
        file.write(f"Total time elapsed: {elapsed_time} seconds\n")
    
    # Prompt to keep the window open
    input("Execution complete. Press Enter to exit.")

Joshiki (talk) 15:10, 19 July 2023 (UTC)

Return to "Size and weight variation" page.