Adding comments to skp test script

This commit is contained in:
b 2021-01-06 20:02:28 -06:00
parent 19f0e4c776
commit 2b95c69176

View file

@ -36,6 +36,7 @@ print(build_weapon)
def is_reqless(item): def is_reqless(item):
return all(x == 0 for x in item["reqs"]) return all(x == 0 for x in item["reqs"])
# Consolidate skillpoint and req into arrays for ease of processing.
def setup(item): def setup(item):
item["skillpoints"] = [item["str"], item["dex"], item["int"], item["def"], item["agi"]] item["skillpoints"] = [item["str"], item["dex"], item["int"], item["def"], item["agi"]]
item["has_negstat"] = any(x < 0 for x in item["skillpoints"]) item["has_negstat"] = any(x < 0 for x in item["skillpoints"])
@ -52,13 +53,13 @@ for item in build_items:
consider.append(item) consider.append(item)
setup(build_weapon) setup(build_weapon)
# Apply the skillpoints an item gives to the build.
def apply_skillpoints(skillpoints, item): def apply_skillpoints(skillpoints, item):
skillpoints[0] += item["str"] for i in range(5):
skillpoints[1] += item["dex"] skillpoints[i] += item["skillpoints"][i]
skillpoints[2] += item["int"]
skillpoints[3] += item["def"]
skillpoints[4] += item["agi"]
# Figure out (naively) how many skillpoints need to be applied to get the current item to fit.
# Doesn't handle -skp.
def apply_to_fit(skillpoints, item): def apply_to_fit(skillpoints, item):
applied = [0, 0, 0, 0, 0] applied = [0, 0, 0, 0, 0]
for i, req, cur in zip(range(5), item["reqs"], skillpoints): for i, req, cur in zip(range(5), item["reqs"], skillpoints):
@ -71,6 +72,7 @@ def apply_to_fit(skillpoints, item):
static_skillpoints_base = [0, 0, 0, 0, 0] static_skillpoints_base = [0, 0, 0, 0, 0]
# Separate out the no req items and add them to the static skillpoint base.
for item in fixed: for item in fixed:
apply_skillpoints(static_skillpoints_base, item) apply_skillpoints(static_skillpoints_base, item)
@ -78,6 +80,7 @@ best = None
best_skillpoints = [0, 0, 0, 0, 0] best_skillpoints = [0, 0, 0, 0, 0]
best_total = math.inf best_total = math.inf
# Try every combination and pick the best one.
import itertools import itertools
for permutation in itertools.permutations(consider): for permutation in itertools.permutations(consider):