Advertisement
UF6

Panzer III Serials Generator/CSV File

UF6
Aug 4th, 2024
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.60 KB | Source Code | 0 0
  1. import pandas as pd
  2. import random
  3.  
  4. # Define Panzer III variants with their production numbers
  5. variants_production = {
  6.     'Ausf. A': 10,
  7.     'Ausf. B': 10,
  8.     'Ausf. C': 15,
  9.     'Ausf. D': 75,
  10.     'Ausf. E': 96,
  11.     'Ausf. F': 450,
  12.     'Ausf. G': 594,
  13.     'Ausf. H': 286,
  14.     'Ausf. J': 1521,
  15.     'Ausf. L': 1470,
  16.     'Ausf. M': 517,
  17.     'Ausf. N': 614,
  18.     'Command D': 30,
  19.     'Command E': 45,
  20.     'Command H': 175,
  21.     'Command J': 81,
  22.     'Command K': 50,
  23.     'Flame Tank': 100
  24. }
  25.  
  26. # Total production limit
  27. total_production_limit = 5774
  28.  
  29. # Define the production periods with their overlaps
  30. production_periods = {
  31.     'Ausf. A': ('1937-01', '1937-12'),
  32.     'Ausf. B': ('1937-01', '1937-12'),
  33.     'Ausf. C': ('1937-07', '1938-06'),
  34.     'Ausf. D': ('1938-01', '1940-12'),
  35.     'Ausf. E': ('1939-01', '1941-12'),
  36.     'Ausf. F': ('1939-06', '1941-12'),
  37.     'Ausf. G': ('1940-06', '1943-06'),
  38.     'Ausf. H': ('1941-06', '1943-12'),
  39.     'Ausf. J': ('1942-01', '1943-12'),
  40.     'Ausf. L': ('1941-01', '1942-12'),
  41.     'Ausf. M': ('1942-01', '1943-12'),
  42.     'Ausf. N': ('1942-01', '1943-12'),
  43.     'Command D': ('1938-01', '1939-12'),
  44.     'Command E': ('1939-01', '1940-12'),
  45.     'Command H': ('1940-01', '1941-12'),
  46.     'Command J': ('1941-01', '1942-12'),
  47.     'Command K': ('1942-01', '1943-12'),
  48.     'Flame Tank': ('1943-01', '1943-12')
  49. }
  50.  
  51. def generate_serial_numbers(start_serial_number, total_produced, limit):
  52.     """Generate a range of unique serial numbers based on total production."""
  53.     end_serial_number = min(start_serial_number + total_produced - 1, limit)
  54.     if end_serial_number < start_serial_number:
  55.         return []
  56.     num_serials = min(4, end_serial_number - start_serial_number + 1)
  57.     return random.sample(range(start_serial_number, end_serial_number + 1), num_serials)
  58.  
  59. # Create an empty DataFrame to hold the serial numbers
  60. serials_data = {
  61.     'Variant': [],
  62.     'Serial Numbers': []
  63. }
  64.  
  65. # Initialize the starting serial number
  66. current_serial_number = 1
  67.  
  68. for variant, total_produced in variants_production.items():
  69.     # Adjust total_produced if it exceeds the remaining production limit
  70.     if current_serial_number + total_produced - 1 > total_production_limit:
  71.         total_produced = total_production_limit - current_serial_number + 1
  72.    
  73.     # Generate serial numbers for the current variant
  74.     if total_produced > 0:
  75.         serial_numbers = generate_serial_numbers(current_serial_number, total_produced, total_production_limit)
  76.     else:
  77.         # If total_produced is 0 or the range is too small, generate 4 random serial numbers within the remaining limit
  78.         remaining_range = range(current_serial_number, total_production_limit + 1)
  79.         if len(remaining_range) < 4:
  80.             serial_numbers = list(remaining_range)[:4]
  81.         else:
  82.             serial_numbers = random.sample(remaining_range, 4)
  83.    
  84.     # Handle case when there are fewer than 4 available numbers
  85.     if len(serial_numbers) < 4:
  86.         additional_numbers = random.sample(range(1, total_production_limit + 1), 4 - len(serial_numbers))
  87.         serial_numbers.extend(additional_numbers)
  88.  
  89.     # Store the serial numbers in the DataFrame
  90.     serials_data['Variant'].append(variant)
  91.     serials_data['Serial Numbers'].append(serial_numbers)
  92.    
  93.     # Update the current serial number to the next available number
  94.     current_serial_number += total_produced
  95.  
  96. # Create a DataFrame to hold the serial numbers
  97. serials_df = pd.DataFrame(serials_data)
  98.  
  99. # Save the DataFrame to a CSV file
  100. serials_df.to_csv('panzer_iii_serials.csv', index=False)
  101.  
  102. # Print the DataFrame
  103. print(serials_df)
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement