Pārlūkot izejas kodu

Add scripts about factory wage

JoostSijm 6 gadi atpakaļ
vecāks
revīzija
3b1bb81712

+ 82 - 0
factory_wage/factory_wage.py

@@ -0,0 +1,82 @@
+"""Calculate wage"""
+
+from rival_regions_calc import Item, WorkProduction
+
+
+RESOURCEPRICE = 2500
+RESOURCE = Item("uranium")
+WP = WorkProduction(RESOURCE)
+WP.factory_level = 165
+WP.resource_max = 25
+WP.department_bonus = 6.9
+WP.wage_percentage = 100
+WP.tax_rate = 0
+
+def main():
+    """Main function"""
+
+    # WP.user_level = 30
+    # WP.work_exp = 80000 + 200 * 30
+    # WP.calculate()
+    # base_wage = WP.wage() * RESOURCEPRICE
+    base_wage = 190000000
+    base_wage = int(round(base_wage, -len("%i" % base_wage)+2))
+
+    user_bonus = 2500000
+    education_bonus = 900000
+    # education_bonus = int(user_bonus * 0.4)
+
+    print("resource price   : $ {:9}".format(RESOURCEPRICE))
+    print("tax rate         :   {:9} %".format(WP.tax_rate))
+    print("factory level    :   {:9}".format(WP.factory_level))
+    print("department bonus :   {:9} %".format(WP.department_bonus))
+    print()
+    print("base wage        : $ {:9}".format(base_wage))
+    print("user bonus       : $ {:9}".format(user_bonus))
+    print("education bonus  : $ {:9}".format(education_bonus))
+
+    print("LVL EDU       %      HOUR PROFIT          WAGE")
+    for level in range(60, 101, 5):
+        calc_procentage(base_wage, user_bonus, education_bonus, level, (level - 30) * 14 - 350)
+    calc_procentage(base_wage, user_bonus, education_bonus, 93, 606)
+    calc_procentage(base_wage, user_bonus, education_bonus, 88, 491)
+    calc_procentage(base_wage, user_bonus, education_bonus, 88, 344)
+
+    print_wages(base_wage, user_bonus, education_bonus)
+
+
+def calc_procentage(base_wage, user_bonus, education_bonus, user_level, education_level):
+    """Calculate procentage"""
+    WP.user_level = user_level
+    WP.work_exp = 80000 + 200 * education_level
+    WP.calculate()
+
+    calculated_wage = WP.wage() * RESOURCEPRICE
+    fixed_wage = base_wage + user_level * user_bonus + education_level * education_bonus
+    procent = 100 / calculated_wage * fixed_wage - 100
+    hour_difference = round(calculated_wage - fixed_wage) * 180
+    # print("fixed wage      : {}".format(fixed_wage))
+    # print("calculated wage : {}".format(calculated_wage))
+    # print("procent         : {}".format(procent))
+    print("{:3} {:3}: {:6.2f} {:16,} {:13,}".format(
+        user_level, education_level, procent, hour_difference, fixed_wage
+    ).replace(',', '.'))
+
+def print_wages(base_wage, user_bonus, education_bonus):
+    """Print wages"""
+    print("Cash wage in kk")
+    print("Level  education")
+    education_range = range(50, 401, 25)
+    top_row = "      "
+    for education in education_range:
+        top_row += ",{:>4}".format(education)
+    print(top_row)
+    for level in range(60, 101, 2):
+        wage_row = "{:>5} ".format(level)
+        for education in education_range:
+            wage = base_wage + user_bonus * (level + 1) + education_bonus * (education+ 1)
+            wage_row += ",{}".format(int(round(wage, -6)/1000000))
+        print(wage_row)
+
+if __name__ == "__main__":
+    main()

+ 80 - 0
factory_wage/new_factory_wage.py

@@ -0,0 +1,80 @@
+"""Calculate wage"""
+
+from rival_regions_calc import Item, WorkProduction
+
+
+RESOURCEPRICE = 2300
+RESOURCE = Item("uranium")
+WP = WorkProduction(RESOURCE)
+WP.factory_level = 165
+WP.resource_max = 25
+WP.department_bonus = 6.9
+WP.wage_percentage = 100
+WP.tax_rate = 0
+
+def main():
+    """Main function"""
+
+    # WP.user_level = 30
+    # WP.work_exp = 80000 + 200 * 30
+    # WP.calculate()
+    # base_wage = WP.wage() * RESOURCEPRICE
+    base_wage = 160000000
+    base_wage = int(round(base_wage, -len("%i" % base_wage)+2))
+
+    user_bonus = 1900000
+    education_bonus = 800000
+    # education_bonus = int(user_bonus * 0.4)
+
+    print("resource price   : $ {:9}".format(RESOURCEPRICE))
+    print("tax rate         :   {:9} %".format(WP.tax_rate))
+    print("factory level    :   {:9}".format(WP.factory_level))
+    print("department bonus :   {:9} %".format(WP.department_bonus))
+    print()
+    print("base wage        : $ {:9}".format(base_wage))
+    print("user bonus       : $ {:9}".format(user_bonus))
+    print("education bonus  : $ {:9}".format(education_bonus))
+
+    print("LVL EDU       %      HOUR PROFIT         WAGE")
+    for level in range(60, 101, 5):
+        calc_procentage(base_wage, user_bonus, education_bonus, level, (level - 30) * 8 - 150)
+    calc_procentage(base_wage, user_bonus, education_bonus, 93, 606)
+
+    print_wages(base_wage, user_bonus, education_bonus)
+
+
+def calc_procentage(base_wage, user_bonus, education_bonus, user_level, education_level):
+    """Calculate procentage"""
+    WP.user_level = user_level
+    WP.work_exp = 80000 + 200 * education_level
+    WP.calculate()
+
+    calculated_wage = WP.wage() * RESOURCEPRICE
+    fixed_wage = base_wage + user_level * user_bonus + education_level * education_bonus
+    procent = 100 / calculated_wage * fixed_wage - 100
+    hour_difference = round(calculated_wage - fixed_wage) * 180
+    # print("fixed wage      : {}".format(fixed_wage))
+    # print("calculated wage : {}".format(calculated_wage))
+    # print("procent         : {}".format(procent))
+    print("{:3} {:3}: {:6.2f} {:16,} {:12,}".format(
+        user_level, education_level, procent, hour_difference, fixed_wage
+    ).replace(',', '.'))
+
+def print_wages(base_wage, user_bonus, education_bonus):
+    """Print wages"""
+    print("Cash wage in kk")
+    print("Level  education")
+    education_range = range(50, 401, 25)
+    top_row = "      "
+    for education in education_range:
+        top_row += ",{:>4}".format(education)
+    print(top_row)
+    for level in range(60, 101, 2):
+        wage_row = "{:>5} ".format(level)
+        for education in education_range:
+            wage = base_wage + user_bonus * (level + 1) + education_bonus * (education+ 1)
+            wage_row += ",{}".format(int(round(wage, -6)/1000000))
+        print(wage_row)
+
+if __name__ == "__main__":
+    main()

+ 76 - 0
factory_wage/reworked_factory_wage.py

@@ -0,0 +1,76 @@
+"""Calculate wage"""
+
+from rival_regions_calc import Item, WorkProduction
+
+
+RESOURCEPRICE = 2500
+RESOURCE = Item("uranium")
+WP = WorkProduction(RESOURCE)
+WP.factory_level = 165
+WP.resource_max = 25
+WP.department_bonus = 6.9
+WP.wage_percentage = 100
+WP.tax_rate = 0
+
+def main():
+    """Main function"""
+    profit = 1
+
+    print("resource price   : $ {:9}".format(RESOURCEPRICE))
+    print("tax rate         :   {:9} %".format(WP.tax_rate))
+    print("factory level    :   {:9}".format(WP.factory_level))
+    print("department bonus :   {:9} %".format(WP.department_bonus))
+    print()
+    print("profit           :   {:9} %".format(profit))
+    print()
+
+    print("LVL EDU       %   PROFIT      WAGE")
+    for level in range(60, 101, 5):
+        calc_wage(profit, level, (level - 30) * 14 - 350)
+    calc_wage(profit, 93, 606)
+    calc_wage(profit, 88, 491)
+    calc_wage(profit, 88, 344)
+    calc_wage(profit, 60, 30)
+
+    # print_wages(base_wage, user_bonus, education_bonus)
+
+
+def calc_wage(profit, user_level, education_level):
+    """Calculate procentage"""
+    WP.user_level = user_level
+    WP.work_exp = 80000 + 200 * education_level
+    WP.calculate()
+
+    calculated_wage = WP.wage() * RESOURCEPRICE
+    fixed_wage = round(calculated_wage / 100 * (100 - profit))
+    procent = 100 / calculated_wage * fixed_wage - 100
+    hour_difference = round(calculated_wage - fixed_wage) * 180
+    # print("fixed wage      : {}".format(fixed_wage))
+    # print("calculated wage : {}".format(calculated_wage))
+    # print("procent         : {}".format(procent))
+    print("{:3} {:3}: {:6.2f} {:6,}kk {:8,}k".format(
+        user_level,
+        education_level,
+        procent,
+        round(hour_difference / 1000000),
+        round(fixed_wage / 1000),
+    ).replace(',', '.'))
+
+def print_wages(base_wage, user_bonus, education_bonus):
+    """Print wages"""
+    print("Cash wage in kk")
+    print("Level  education")
+    education_range = range(50, 401, 25)
+    top_row = "      "
+    for education in education_range:
+        top_row += ",{:>4}".format(education)
+    print(top_row)
+    for level in range(60, 101, 2):
+        wage_row = "{:>5} ".format(level)
+        for education in education_range:
+            wage = base_wage + user_bonus * (level + 1) + education_bonus * (education+ 1)
+            wage_row += ",{}".format(int(round(wage, -6)/1000000))
+        print(wage_row)
+
+if __name__ == "__main__":
+    main()

+ 19 - 0
factory_wage/test.py

@@ -0,0 +1,19 @@
+"""Test"""
+
+BASELEVEL = 0
+BASEPERK = 0
+
+LEVELRANGE = range(30, 101)
+PERKRANGE = range(30, 401)
+
+for i in LEVELRANGE:
+    BASELEVEL += pow(i+1, 0.8)-pow(i, 0.8)
+
+for i in PERKRANGE:
+    BASEPERK += pow(80000+(200*(i+1))/10, 0.6)-pow(80000+(200*i)/10, 0.6)
+
+BASELEVEL /= len(LEVELRANGE)
+BASEPERK /= len(PERKRANGE)
+print(BASELEVEL)
+print(BASEPERK)
+print(BASEPERK/BASELEVEL)

+ 12 - 0
factory_wage/wage_calc.py

@@ -0,0 +1,12 @@
+
+BASE = 190000000
+LEVEL = 2500000
+EDUCATION = 900000
+
+print('Level         Kennis                          Wage')
+for stat in range(60, 86, 5):
+    print('{:2}               {:3}                $ {:,}'.format(
+        stat,
+        (stat - 35) * 10 - 200,
+        BASE + LEVEL * stat + EDUCATION * ((stat - 25) * 10 - 200)
+    ).replace(',', '.'))

+ 7 - 0
factory_workers/example_prices.json

@@ -0,0 +1,7 @@
+{
+    "oil": 255,
+    "gold": 0,
+    "diamond": 1650000,
+    "uranium": 2300,
+    "ore": 235
+}

+ 82 - 0
factory_workers/factory_wage.py

@@ -0,0 +1,82 @@
+"""Calculate wage"""
+
+from rival_regions_calc import Item, WorkProduction
+
+
+RESOURCEPRICE = 2500
+RESOURCE = Item("uranium")
+WP = WorkProduction(RESOURCE)
+WP.factory_level = 165
+WP.resource_max = 25
+WP.department_bonus = 6.9
+WP.wage_percentage = 100
+WP.tax_rate = 0
+
+def main():
+    """Main function"""
+
+    # WP.user_level = 30
+    # WP.work_exp = 80000 + 200 * 30
+    # WP.calculate()
+    # base_wage = WP.wage() * RESOURCEPRICE
+    base_wage = 190000000
+    base_wage = int(round(base_wage, -len("%i" % base_wage)+2))
+
+    user_bonus = 2500000
+    education_bonus = 900000
+    # education_bonus = int(user_bonus * 0.4)
+
+    print("resource price   : $ {:9}".format(RESOURCEPRICE))
+    print("tax rate         :   {:9} %".format(WP.tax_rate))
+    print("factory level    :   {:9}".format(WP.factory_level))
+    print("department bonus :   {:9} %".format(WP.department_bonus))
+    print()
+    print("base wage        : $ {:9}".format(base_wage))
+    print("user bonus       : $ {:9}".format(user_bonus))
+    print("education bonus  : $ {:9}".format(education_bonus))
+
+    print("LVL EDU       %      HOUR PROFIT          WAGE")
+    for level in range(60, 101, 5):
+        calc_procentage(base_wage, user_bonus, education_bonus, level, (level - 30) * 14 - 350)
+    calc_procentage(base_wage, user_bonus, education_bonus, 93, 606)
+    calc_procentage(base_wage, user_bonus, education_bonus, 88, 491)
+    calc_procentage(base_wage, user_bonus, education_bonus, 88, 344)
+
+    print_wages(base_wage, user_bonus, education_bonus)
+
+
+def calc_procentage(base_wage, user_bonus, education_bonus, user_level, education_level):
+    """Calculate procentage"""
+    WP.user_level = user_level
+    WP.work_exp = 80000 + 200 * education_level
+    WP.calculate()
+
+    calculated_wage = WP.wage() * RESOURCEPRICE
+    fixed_wage = base_wage + user_level * user_bonus + education_level * education_bonus
+    procent = 100 / calculated_wage * fixed_wage - 100
+    hour_difference = round(calculated_wage - fixed_wage) * 180
+    # print("fixed wage      : {}".format(fixed_wage))
+    # print("calculated wage : {}".format(calculated_wage))
+    # print("procent         : {}".format(procent))
+    print("{:3} {:3}: {:6.2f} {:16,} {:13,}".format(
+        user_level, education_level, procent, hour_difference, fixed_wage
+    ).replace(',', '.'))
+
+def print_wages(base_wage, user_bonus, education_bonus):
+    """Print wages"""
+    print("Cash wage in kk")
+    print("Level  education")
+    education_range = range(50, 401, 25)
+    top_row = "      "
+    for education in education_range:
+        top_row += ",{:>4}".format(education)
+    print(top_row)
+    for level in range(60, 101, 2):
+        wage_row = "{:>5} ".format(level)
+        for education in education_range:
+            wage = base_wage + user_bonus * (level + 1) + education_bonus * (education+ 1)
+            wage_row += ",{}".format(int(round(wage, -6)/1000000))
+        print(wage_row)
+
+if __name__ == "__main__":
+    main()

+ 72 - 0
factory_workers/factory_workers.py

@@ -0,0 +1,72 @@
+"""Calculate wage"""
+
+import json
+import operator
+
+from rival_regions_calc import Item, WorkProduction
+
+
+RESOURCEPRICE = 2500
+RESOURCE = Item("uranium")
+WP = WorkProduction(RESOURCE)
+WP.factory_level = 165
+WP.resource_max = 25
+WP.department_bonus = 7.2
+WP.wage_percentage = 100
+WP.tax_rate = 0
+
+def main():
+    """Main function"""
+
+    print("resource price   : $ {:9}".format(RESOURCEPRICE))
+    print("tax rate         :   {:9} %".format(WP.tax_rate))
+    print("factory level    :   {:9}".format(WP.factory_level))
+    print("department bonus :   {:9} %".format(WP.department_bonus))
+    print()
+
+    workers = None
+    with open('workers.json') as file:
+        workers = json.load(file)
+
+    for worker in workers.values():
+        WP.user_level = worker['level']
+        WP.work_exp = 80000 + 200 * worker['education']
+        WP.calculate()
+        worker['production'] = round(WP.wage())
+        print(worker['production'])
+
+    print('WORKER WAGE')
+    print_worker_wage(workers)
+
+    print()
+    print('WORKER PRODUCTION')
+    print_worker_production(workers)
+
+def print_worker_wage(workers):
+    """Print worker wage percentage"""
+    print("NAME                       %   H PROFIT")
+
+    for worker in workers.values():
+        calculated_wage = worker['production'] * RESOURCEPRICE
+        worker['procent'] = 100 / calculated_wage * worker['wage'] - 100
+        worker['hour_difference'] = round(calculated_wage - worker['wage']) * 180
+
+    for worker in sorted(workers.values(), key=operator.itemgetter('procent'), reverse=True):
+        print("{:20}: {:6.2f} {:8,}kk".format(
+            worker['name'],
+            worker['procent'],
+            round(worker['hour_difference'] / 1000000),
+        ).replace(',', '.'))
+
+def print_worker_production(workers):
+    """Calculate production"""
+    print("NAME                      24 H PROD      %")
+    for worker in sorted(workers.values(), key=operator.itemgetter('production'), reverse=True):
+        print("{:20}: {:6,.0f} {:6.2f}".format(
+            worker['name'],
+            worker['production'] * 4320,
+            100 / 2400000000 * (worker['production'] * 4320),
+        ).replace(',', '.'))
+
+if __name__ == "__main__":
+    main()