diff options
author | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-20 00:11:23 +0100 |
---|---|---|
committer | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-20 00:11:23 +0100 |
commit | 2eef87c8970db643c4ef09e0fd9e8110c8193043 (patch) | |
tree | 78a9bcc7932ab8edb8669ded755ee2c81afc0912 /build/content | |
parent | c135f85fcdc1eeedd04e0c9e9f626b907500f20a (diff) |
finish condition and bad cost function
Diffstat (limited to 'build/content')
-rw-r--r-- | build/content/armor.txt | 66 | ||||
-rw-r--r-- | build/content/autolevel.py | 20 |
2 files changed, 47 insertions, 39 deletions
diff --git a/build/content/armor.txt b/build/content/armor.txt index 5182a0c..5ceaacc 100644 --- a/build/content/armor.txt +++ b/build/content/armor.txt @@ -2,9 +2,9 @@ { "name": "metal plating", "weight": [ - 50.0, - 50.0, - 50.0 + 10.0, + 10.0, + 10.0 ], "pierce": [ 5.0, @@ -20,9 +20,9 @@ { "name": "heavy metal plating", "weight": [ - 80.0, - 80.0, - 80.0 + 16.0, + 16.0, + 16.0 ], "pierce": [ 7.0, @@ -43,9 +43,9 @@ { "name": "reflective plating", "weight": [ - 40.0, - 40.0, - 40.0 + 8.0, + 8.0, + 8.0 ], "laser": [ 10.0, @@ -56,9 +56,9 @@ { "name": "heat resistent plating", "weight": [ - 50.0, - 50.0, - 50.0 + 10.0, + 10.0, + 10.0 ], "fusion": [ 8.0, @@ -69,9 +69,9 @@ { "name": "padding", "weight": [ - 20.0, - 20.0, - 20.0 + 4.0, + 4.0, + 4.0 ], "spread": [ 5.0, @@ -87,9 +87,9 @@ { "name": "reactive armor", "weight": [ - 75.0, - 75.0, - 75.0 + 15.0, + 15.0, + 15.0 ], "explosive": [ 12.0, @@ -100,9 +100,9 @@ { "name": "energy shields", "weight": [ - 25.0, - 25.0, - 25.0 + 5.0, + 5.0, + 5.0 ], "pierce": [ 3.0, @@ -133,9 +133,9 @@ { "name": "composite armor", "weight": [ - 30.0, - 30.0, - 30.0 + 6.0, + 6.0, + 6.0 ], "pierce": [ 6.0, @@ -156,9 +156,9 @@ { "name": "plastic armor", "weight": [ - 10.0, - 10.0, - 10.0 + 2.0, + 2.0, + 2.0 ], "pierce": [ 4.0, @@ -169,9 +169,9 @@ { "name": "sloped steel armor", "weight": [ - 45.0, - 45.0, - 45.0 + 9.0, + 9.0, + 9.0 ], "pierce": [ 10.0, @@ -187,9 +187,9 @@ { "name": "charged armor", "weight": [ - 100.0, - 100.0, - 100.0 + 20.0, + 20.0, + 20.0 ], "explosive": [ 25.0, diff --git a/build/content/autolevel.py b/build/content/autolevel.py index eac6e09..345bccf 100644 --- a/build/content/autolevel.py +++ b/build/content/autolevel.py @@ -1,6 +1,6 @@ import json -def vectorize (obj, forbidlist): +def vectorize (obj, forbidlist, _): for c in obj: for key in c: if not(key in forbidlist): @@ -10,13 +10,18 @@ def vectorize (obj, forbidlist): try: val = float(val); except: pass c[key] = [val for i in range(3)] - return obj + +def query (obj, allowlist, op): + for c in obj: + for key in c: + if key in allowlist: + c[key] = op(c[key]) -def comp(filename, forbidlist): +def comp(filename, l, fun, op=None): with open(filename+".txt", "r") as f: obj = json.loads(f.read()) - obj = vectorize(obj, forbidlist) - with open(filename+".txt", "w") as f: + fun(obj, l, op) + with open(filename+"-new"+".txt", "w") as f: f.write(json.dumps(obj, indent=4)) if __name__ == "__main__": @@ -25,4 +30,7 @@ if __name__ == "__main__": #comp("batteries", ["name"]) #comp("armor", ["name"]) #comp("chassis", ["name"]) - comp("brains", ["name"]) + #comp("brains", ["name"]) + #comp("brains", ["name"]) + + #comp("armor", ["weight"], query, lambda x: [x[i]/5 for i in range(3)]) |