From 2eef87c8970db643c4ef09e0fd9e8110c8193043 Mon Sep 17 00:00:00 2001 From: jacopo grandi Date: Sat, 20 Feb 2021 00:11:23 +0100 Subject: finish condition and bad cost function --- build/army/army.txt | Bin 0 -> 21528 bytes build/content/armor.txt | 66 ++++++++++++++++++++++----------------------- build/content/autolevel.py | 20 +++++++++----- build/test.exe | Bin 751762 -> 775710 bytes 4 files changed, 47 insertions(+), 39 deletions(-) create mode 100644 build/army/army.txt (limited to 'build') diff --git a/build/army/army.txt b/build/army/army.txt new file mode 100644 index 0000000..033dd7c Binary files /dev/null and b/build/army/army.txt differ 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)]) diff --git a/build/test.exe b/build/test.exe index de1814f..a57fe22 100644 Binary files a/build/test.exe and b/build/test.exe differ -- cgit v1.2.3-54-g00ecf