Advertisement
Arathun

Housamo Scripts

Jul 12th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.83 KB | None | 0 0
  1. #import pandas as pd
  2. #import numpy as np
  3. #import re
  4. #import datetime
  5. #import math as m
  6. #from pathlib import Path
  7. #
  8.  
  9. def skillCost(rarity=1):
  10.     SALVsteps = [1, 25, 49, 67, 79, 88, 94, 97]
  11.     skillBoostsUsed = [4, 5, 5, 5, 5, 5, 5, 5]
  12.  
  13.     totalCost = 0
  14.     for i, j in zip(SALVsteps, skillBoostsUsed):
  15.         costStipend = j*(rarity * i**2 + 100)
  16.         #print(i, j)
  17.         totalCost += costStipend
  18.         print(str(costStipend) + " added to " + str(totalCost - costStipend) + " → total " + str(totalCost))
  19.     print(totalCost)
  20.  
  21. def levelCost(rarity=5,
  22.     myLV=False,
  23.     expToNextLV = False,
  24.     preseeded = True,
  25.     refTableName = "levelXP.tsv",
  26.     boostTableName = "boostXP.tsv"):
  27.     #make XP-per-level table
  28.     if not Path(refTableName).exists():
  29.         levels = range(1, 81)
  30.         XPreq = [12, 15, 27, 36, 50, 80, 100, 130, 150, 200,
  31.         250, 350, 400, 550, 650, 700, 750, 800, 850, 900,
  32.         950, 1000, 1050, 1100, 1150, 1250, 1400, 1500, 1600, 1700,
  33.         1700, 1800, 1800, 1800, 1800, 1800, 1800, 1900, 1900, 1950,
  34.         2000, 2150, 2200, 2300, 2400, 2600, 2600, 2800, 3000, 3200,
  35.         3600, 4200, 5000, 5800, 6600, 7600, 8600, 9600, 10800, 11600,
  36.         12800, 14000, 15200, 16400, 17600, 19000, 20400, 23200, 24800, 26800,
  37.         28800, 31000, 33200, 35400, 37600, 39600, 42300, 45200, 47400, 50000]
  38.         cumXP = [sum(XPreq[0:x+1]) - XPreq[x] for x in range(len(XPreq))]
  39.  
  40.         print(len(XPreq), len(levels))
  41.  
  42.         data = {"LV":levels, "XP to LV+1":XPreq, "Cumulative XP":cumXP }
  43.         refTable = pd.DataFrame(data)
  44.         print(refTable)
  45.         refTable.to_csv(refTableName, sep="\t", index = False)
  46.     #make Boost XP table
  47.     if not Path(boostTableName).exists():
  48.         boostLevel = ["S", "M", "L", "G"]
  49.         boost1XP = 20
  50.         XPboosts = [(4**x)*boost1XP for x in range(0,4)]
  51.         XPmatchMultiplier = 1.2
  52.         XPboosts2 = [int(x*XPmatchMultiplier) for x in XPboosts]
  53.    
  54.         data = {"Boost Size":boostLevel, "Boost XP":XPboosts, "Boost XP (match)":XPboosts2}
  55.    
  56.         boostTable = pd.DataFrame(data)
  57.         print(boostTable)
  58.         boostTable.to_csv(boostTableName, sep="\t", index = False)
  59.  
  60.  
  61.     RT = pd.read_table(refTableName, sep="\t")
  62.     BT = pd.read_table(boostTableName, sep="\t")
  63.  
  64.     LB0Cap = 20 + (rarity-1)*5
  65.     if preseeded == False:
  66.         LBcaps = [LB0Cap + 10*x for x in range(0, 4)]
  67.         LVseedCaps = [LBcaps[-1] + x for x in range(1, 11)]
  68.         caps = LBcaps + LVseedCaps
  69.  
  70.         LBlist = ["LB" + str(x) for x in range(0, 4)]
  71.         LVseedList = ["LV+" + str(x) for x in range(1, 11)]
  72.         capList = LBlist + LVseedList
  73.     elif preseeded == True:
  74.         LBcaps = [LB0Cap + 10*x for x in range(0, 3)]
  75.         caps = LBcaps + [LBcaps[-1] + 20]
  76.  
  77.         LBlist = ["LB" + str(x) for x in range(0, 3)]
  78.         capList = LBlist + ["Final LB and preseeded"]
  79.  
  80.  
  81.     else:
  82.         print("error preseeded status")
  83.         return
  84.  
  85.  
  86.     print(caps, capList)
  87.     data = {"Cap Label":capList, "Level Cap":caps}
  88.  
  89.     capTable = pd.DataFrame(data)
  90.  
  91.  
  92.     XPcumLB = [RT.loc[(RT["LV"] == x), "Cumulative XP"].tolist()[0] for x in capTable["Level Cap"].tolist()]
  93.     XPbyLB = [XPcumLB[x] - XPcumLB[x-1] if x != 0 else XPcumLB[x] for x in range(len(XPcumLB))]
  94.     print(XPcumLB)
  95.     print(XPbyLB)
  96.  
  97.     def coinCalc(LV, slotted=5):
  98.         coins = slotted*(20*LV + 100)
  99.         return coins
  100.  
  101.     maxBoostMatchXP = BT["Boost XP (match)"].max()
  102.     maxBoostXP = BT["Boost XP"].max()
  103.     totalCost = 0
  104.  
  105.     print("☆☆ Batching begins here")
  106.  
  107.     OP = ""
  108.    
  109.     totalBoosts = 0
  110.     totalNonMatches = 0
  111.     for i in range(len(XPbyLB)):
  112.         #determine how many matching boosts are required to reach the next LV cap
  113.         XPremaining = XPbyLB[i]
  114.         maxBoostMatches = 0
  115.         if myLV == False:
  116.             if i != 0:
  117.                 floorLV = caps[i-1]
  118.             else:
  119.                 floorLV = 1
  120.         else:
  121.             floorLV = myLV
  122.         capLV = caps[i]
  123.         while XPremaining > 0:
  124.             maxBoostMatches += 1
  125.             XPremaining -= maxBoostMatchXP
  126.         print("☾☾ Leveling from " + str(floorLV) + " to " + str(capLV))
  127.         print("Matched max boosts used: " + str(maxBoostMatches))
  128.         print("XP wasted: " + str(-XPremaining))
  129.  
  130.         #minimize how many matching boosts can be subbed with nonmatchers
  131.         nonmatchBoosts = 0
  132.         if XPremaining != 0 and maxBoostMatchXP - maxBoostXP > 0:
  133.             tempMaxBoostMatches = maxBoostMatches
  134.             while XPremaining < 0 and tempMaxBoostMatches > 0:
  135.                 nonmatchBoosts += 1
  136.                 tempMaxBoostMatches -= 1
  137.                 XPremaining = -(-XPremaining - (maxBoostMatchXP - maxBoostXP))
  138.             if XPremaining != 0:
  139.                 nonmatchBoosts -= 1
  140.         nonmatchBoostsStable = nonmatchBoosts
  141.                 #if XPremaining ends up being positive from subbing with nonmatchers, this indicates subbing has become inefficient enough for ≥1 more boost to be required
  142.  
  143.         print("Non-matching boosts: " + str(nonmatchBoosts))
  144.         # a max of 4 nonmatch subs is possible
  145.         #subbing for any more even in the most extreme wasteful situation (G at 1XP left, for 1535 wasted) will lead to needing more boosts
  146.  
  147.         matchBoosts = maxBoostMatches - nonmatchBoosts
  148.  
  149.         #cost
  150.         LVrangeCost = 0
  151.         currentLV = floorLV
  152.         currentXP = RT.loc[(RT["LV"] == currentLV), "Cumulative XP"].tolist()[0]
  153.         #print(currentLV, currentXP)
  154.  
  155.         firstBatch = maxBoostMatches % 5
  156.         if firstBatch == 0:
  157.             firstBatch = 5
  158.         remainderBatchCount = (maxBoostMatches - firstBatch)//5
  159.         #print(remainderBatchCount, type(remainderBatchCount))
  160.  
  161.        
  162.  
  163.         batchList = [firstBatch,] + [5]*remainderBatchCount
  164.         print(batchList)
  165.  
  166.         for j in range(len(batchList)):
  167.  
  168.             batchCost = coinCalc(currentLV, batchList[j])
  169.             LVrangeCost += batchCost
  170.  
  171.             for k in range(batchList[j]):
  172.                 #print(str(k+1) + " of " + str(batchList[j]) + " boosts in a batch (" + str(nonmatchBoosts) + " non-match boosts in tow before use)")
  173.                 if nonmatchBoosts > 0:
  174.                     nonmatchBoosts -= 1
  175.                     currentXP += maxBoostXP
  176.                 elif matchBoosts > 0:
  177.                     matchBoosts -=1
  178.                     currentXP += maxBoostMatchXP
  179.                 else:
  180.                     print("error: " + str(nonmatchBoosts) + " non-match boosts and " + str(matchBoosts) + " match boosts")
  181.                     return
  182.             for k in range(len(RT.index) - 1):
  183.  
  184.                 if RT.loc[k, "Cumulative XP"] <= currentXP <= RT.loc[k+1, "Cumulative XP"]:
  185.                     currentLV = RT.loc[k, "LV"]
  186.                     break
  187.         print("cost for this leveling range is " + str(LVrangeCost))
  188.         totalCost += LVrangeCost
  189.         totalXP = sum(XPbyLB)
  190.         totalBoosts += maxBoostMatches
  191.         totalNonMatches += nonmatchBoostsStable
  192.         print("Total cost up to this point is " + str(totalCost))
  193.  
  194.         OP += "|" + str(XPbyLB[i]) + " <br/> " + str(maxBoostMatches) + " (" + str(nonmatchBoostsStable) + ") <br/> " + str(LVrangeCost) + "\n"
  195.        
  196.  
  197.         print("☆☆")
  198.     totalPrint = "|" + str(totalXP) + " <br/> " + str(totalBoosts) + " (" + str(totalNonMatches) + ") <br/> " + str(totalCost) + "\n"
  199.     OP += totalPrint
  200.     print(OP)
  201.    
  202.  
  203.  
  204.  
  205. def masterdataSearch(datatype="Skill", start=0, Length=100):
  206.     mystr1 = "{{#masterdata:"+datatype+"|"
  207.     mystr2 = "}}"
  208.     if datatype == "Skill":
  209.         mystr2 = "|format=wiki" + mystr2
  210.     elif datatype == "Quest":
  211.         mystr2 = "|args=fullname" + mystr2
  212.     ##n.b. for datatype==Quest:
  213.         #[20000,30000) main story main quest, test main story main quests?
  214.         #[20000,30000):
  215.             #1-48 main story free quests (ch1-9)
  216.             #49-51 AR lesson quests
  217.  
  218.         #[30000,40000) for character quests
  219.         #[40000,50000):
  220.             #1-25 test main story free quests?
  221.             #next few are love quests
  222.         #[50000,80000) for daily quests
  223.         #[60000,70000) for event main quests
  224.         #[70000,80000) for event free quests
  225.         #[80000,90000) for special quests
  226.         #[90000,100000) for skill quests
  227.         #[100000,11000) for dungeon quests
  228.  
  229.     finish = start + Length
  230.  
  231.     for i in range(start, finish):
  232.         print(mystr1 + str(i+1) + mystr2)
  233.  
  234.  
  235. def valueWikiTabular(myInput=("0    1   2   3   4   5   6   7   8   9")):
  236.     myList = myInput.split("\t")
  237.     del myList[2:4]
  238.     OP = " || ".join(myList)
  239.     print(OP)
  240.  
  241. def dungeonXPsplitter(questXP = 32000, XPreq = 65000, mentorMod = 0.5):
  242.     #assumes each unit requires XPreq
  243.     questXP *= 1 + mentorMod
  244.     overages = []
  245.     allCaseRuns = []
  246.     for units in range(1,6): #support excluded from XP distribution, so only up the overages for runs done by up to 5 units are checked
  247.         XPoverage = XPreq - questXP/units
  248.         runs = 1
  249.         print(str(units) + " units")
  250.         while XPoverage > 0:
  251.             print("cum XP per unit gained in "+ str(runs) + " runs: " + str((questXP/units)*runs))
  252.             XPoverage -= questXP/units
  253.             runs += 1
  254.         print("total XP per unit gained in "+ str(runs) + " runs: " + str((questXP/units)*runs) + " (" + str(-XPoverage) + " wasted)")
  255.  
  256.         overages.append(XPoverage)
  257.         allCaseRuns.append(runs)
  258.     for i in range(len(overages)):
  259.         print(str(i+1) + " units, " + str(-overages[i]) + " wasted XP, " + str(-overages[i]/(i+1)) + " wasted XP per run, " + str(allCaseRuns[i]) + " runs.")
  260.  
  261.  
  262.  
  263.  
  264. #convert multi-column lookup formula from array-dependent to array-independent
  265. #{=INDEX(range1,MATCH(1,(A1=range2)*(B1=range3)*(C1=range4),0))} → =INDEX(rng1,MATCH(1,INDEX((A1=rng2)*(B1=rng3)*(C1=rng4),0,1),0))
  266.  
  267. '''
  268.  
  269. '''
  270.  
  271.  
  272. if __name__ == "__main__":
  273.     values = "7591  9682    49.388  710 3871    5365    1006    1395    3019    4184"
  274.     #valueWikiTabular(values)
  275.     #masterdataSearch(datatype="Skill", start=1100, Length=100)
  276.     #levelCost(rarity=1)
  277.     dungeonXPsplitter()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement