def test_GenerosityPole(self): curstate1 = State({"f1": 100}, {"i1": 0}) desState1 = State({'f1': 1000}, {'i1': 1000}) test_polelow = GenerosityPole(-1, 1) test_polemiddle = GenerosityPole(0, 1) test_polehigh = GenerosityPole(1, 1) move1 = Move({"f1": 100, "f2": 0}, {"i1": 1}, [], 1, None) # most expensive move2 = Move({"f1": 75, "f2": 0}, {"i1": 1}, [], 1, None) move3 = Move({"f1": 45, "f2": 0}, {"i1": 1}, [], 1, None) move4 = Move({"f1": 0, "f2": 0}, {"i1": 1}, [], 1, None) test_MST1 = MST(curstate1, desState1, [move1, move2, move3, move4], 2) test_MST2 = MST(curstate1, desState1, [move1, move2, move3, move4], 2) test_MST3 = MST(curstate1, desState1, [move1, move2, move3, move4], 2) actorlow = Actor([test_polelow], curstate1, None, None, .05, None, None, [], []) actormiddle = Actor([test_polemiddle], curstate1, None, None, .05, None, None, [], []) actorhigh = Actor([test_polehigh], curstate1, None, None, .05, None, None, [], []) low_mst = test_polelow.actOnMST(test_MST1, actorlow) mid_mst = test_polemiddle.actOnMST(test_MST2, actormiddle) high_mst = test_polehigh.actOnMST(test_MST3, actorhigh) self.assertTrue(len(low_mst.getMoves()) == 1) self.assertTrue(len(high_mst.getMoves()) == 4) self.assertTrue(len(mid_mst.getMoves()) == 2) self.assertTrue(True) if __name__ == '__main__': unittest.main()
def test_RiskPole(self): curstate1 = State({"f1": 100, "f2": 0}, {"i1": 0}) desState1 = State({'f1': 1000}, {'i1': 1000}) move1 = Move({"f1": 0, "f2": 0}, {"i1": 1}, [], 1, None) move2 = Move({"f1": 50, "f2": 0}, {"i1": 2}, [], 1, None) move3 = Move({"f1": 100, "f2": 0}, {"i1": 3}, [], 1, None) move4 = Move({"f1": 200, "f2": 0}, {"i1": 3}, [], 1, None) test_MST1 = MST(curstate1, desState1, [move1, move2, move3, move4], 2) test_MST2 = MST(curstate1, desState1, [move1, move2, move3, move4], 2) test_MST3 = MST(curstate1, desState1, [move1, move2, move3, move4], 2) test_polelow = RiskPole(-1, 1) test_polemiddle = RiskPole(0, 1) test_polehigh = RiskPole(1, 1) actorlow = Actor([test_polelow], curstate1, None, None, 0.05, None, None, [], None) # actormiddle = Actor([test_polemiddle], curstate1, None, None, 0.05, None, None, [], None) # actorhigh = Actor([test_polehigh], curstate1, None, None, 0.05, None, None, [], None) low_mst = test_polelow.actOnMST(test_MST1, actorlow) # contain only move1 mid_mst = test_polemiddle.actOnMST(test_MST2, actormiddle) # containmove1 and 2 high_mst = test_polehigh.actOnMST(test_MST3, actorhigh) # contain 123 self.assertTrue(low_mst.containsMove(move1)) self.assertFalse(low_mst.containsMove(move2)) self.assertFalse(low_mst.containsMove(move3)) self.assertFalse(low_mst.containsMove(move4)) self.assertTrue(mid_mst.containsMove(move1)) self.assertTrue(mid_mst.containsMove(move2)) self.assertFalse(mid_mst.containsMove(move3)) self.assertFalse(mid_mst.containsMove(move4)) self.assertTrue(high_mst.containsMove(move1)) self.assertTrue(high_mst.containsMove(move2)) self.assertTrue(high_mst.containsMove(move3)) self.assertFalse(high_mst.containsMove(move4))
def test_rationalityPole(self): move1 = Move({"f1": 1}, {"i1": 1}, [], 0, None) move2 = Move({"f1": 2}, {"i1": 2}, [], .45, None) move3 = Move({"f1": 3}, {"i1": 3}, [], .95, None) curstate1 = State({'f1': 0}, {'i1': 0}) desState1 = State({'f1': 100}, {'i1': 100}) test_MST1 = MST(curstate1, desState1, [move1, move2, move3], 2) test_MST2 = MST(curstate1, desState1, [move1, move2, move3], 2) test_MST3 = MST(curstate1, desState1, [move1, move2, move3], 2) test_polelow = RationalityPole(-1, 1) test_polemiddle = RationalityPole(0, 1) test_polehigh = RationalityPole(1, 1) actorlow = Actor([test_polelow], None, None, None, 0.05, None, None, [], None) # will remove no moves actormiddle = Actor([test_polemiddle], None, None, None, 0.05, None, None, [], None) # will remove move1 actorhigh = Actor([test_polehigh], None, None, None, 0.05, None, None, [], None) # will remove move1, move2 low_mst = test_polelow.actOnMST(test_MST1, actorlow) self.assertTrue(low_mst.containsMove(move1) and low_mst.containsMove(move2) and low_mst.containsMove(move3)) mid_mst = test_polemiddle.actOnMST(test_MST2, actormiddle) print("middle test_MST") self.assertTrue(mid_mst.containsMove(move2)) self.assertFalse(mid_mst.containsMove(move1)) self.assertTrue(mid_mst.containsMove(move3)) high_mst = test_polehigh.actOnMST(test_MST3, actorhigh) self.assertTrue(high_mst.containsMove(move3)) self.assertFalse(high_mst.containsMove(move1)) self.assertFalse(high_mst.containsMove(move2))
def test_EmotionalPole(self): curstate1 = State({"f1": 100}, {"i1": 0}) desState1 = State({'f1': 1000}, {'i1': 1000}) test_polelow = EmotionalPole(-.81, 1) test_polemiddle = EmotionalPole(.5, 1) test_polehigh = EmotionalPole(1, 1) move1 = Move({"f1": 0}, {"i1": 0}, [], .5, 'Engage in diplomatic cooperation') # .6-.8 move2 = Move({"f1": 0}, {"i1": 0}, [], .5, 'Appeal') # 4-6 move3 = Move({"f1": 0}, {"i1": 0}, [], .5, 'Build economic infrastructure') # .5-.7 move4 = Move({"f1": 0}, {"i1": 0}, [], .5, 'Assault') # -.2 move5 = Move({"f1": 0}, {"i1": 0}, [], .5, 'Coerce') # -.8 test_MST1 = MST(curstate1, desState1, [move1, move2, move3, move4, move5], 2) test_MST2 = MST(curstate1, desState1, [move1, move2, move3, move4, move5], 2) test_MST3 = MST(curstate1, desState1, [move1, move2, move3, move4, move5], 2) actorlow = Actor([test_polelow], curstate1, None, None, .05, None, None, [], []) actormiddle = Actor([test_polemiddle], curstate1, None, None, .05, None, None, [], []) actorhigh = Actor([test_polehigh], curstate1, None, None, .05, None, None, [], []) low_mst = test_polelow.actOnMST(test_MST1, actorlow) mid_mst = test_polemiddle.actOnMST(test_MST2, actormiddle) high_mst = test_polehigh.actOnMST(test_MST3, actorhigh) self.assertTrue(low_mst.containsMove(move5)) self.assertFalse(low_mst.containsMove(move1) and low_mst.containsMove(move2) and low_mst.containsMove( move3) and low_mst.containsMove(move4)) self.assertFalse(mid_mst.containsMove(move1)) self.assertFalse(mid_mst.containsMove(move4)) self.assertFalse(mid_mst.containsMove(move5)) self.assertTrue(mid_mst.containsMove(move2)) self.assertFalse(mid_mst.containsMove(move3))
def test_ParticularHolisticPole(self): move1 = Move({ "test1": 5, "test2": 10, "test3": 20 }, None, [0, 0, 0, 0], .5, None) move2 = Move({ "test1": 100, "test2": 200, "test3": 300 }, None, [15, 20, 14, 19], .5, None) move3 = Move({ "test1": 1, "test2": 1, "test3": 1 }, None, [200, -350, 900, 3], .5, None) move4 = Move({ "test1": -10, "test2": 10, "test3": -100 }, None, [39, 189, 289, 398], .5, None) move5 = Move({ "test1": 500, "test2": 1000, "test3": 10000 }, None, [10, 20, 30, 40], .5, None) move0 = Move({ "test1": 0, "test2": 0, "test3": 0 }, None, [1000, 1000, 1000, 1000], 0, None) moves = [move1, move2, move3, move4, move5, move0] test_polelow = ParticularHolisticPole(-1, 1) test_polemiddle = ParticularHolisticPole(0, 1) test_polehigh = ParticularHolisticPole(1, 1) actorlow = Actor([test_polelow], None, None, None, 0.05, None, None, [], [0, 0, 0, 0]) actormiddle = Actor([test_polemiddle], None, None, None, 0.05, None, None, [], [0, 0, 0, 0]) actorhigh = Actor([test_polehigh], None, None, None, 0.05, None, None, [], [0, 0, 0, 0]) moveslow = test_polelow.actOnList(moves, actorlow) movesmiddle = test_polemiddle.actOnList(moves, actormiddle) moveshigh = test_polehigh.actOnList(moves, actorhigh) self.assertTrue(len(moveslow) != 6) self.assertTrue(len(moveshigh) >= 5)
def test_riskPole(self): move1 = Move({ "test1": 5, "test2": 10, "test3": 20 }, None, [], .5, None) move2 = Move({ "test1": 100, "test2": 200, "test3": 300 }, None, [], .5, None) move3 = Move({"test1": 1, "test2": 1, "test3": 1}, None, [], .5, None) move4 = Move({ "test1": -10, "test2": 10, "test3": -100 }, None, [], .5, None) move5 = Move({ "test1": 500, "test2": 1000, "test3": 10000 }, None, [], .5, None) move0 = Move({"test1": 0, "test2": 0, "test3": 0}, None, [], 0, None) moves = [move1, move2, move3, move4, move5, move0] test_polelow = RiskPole(-1, 1) test_polemiddle = RiskPole(0, 1) test_polehigh = RiskPole(.99, 1) actorlow = Actor([test_polelow], None, None, None, 0.05, None, None, [], None) actormiddle = Actor([test_polemiddle], None, None, None, 0.05, None, None, [], None) actorhigh = Actor([test_polehigh], None, None, None, 0.05, None, None, [], None) moveslow = test_polelow.actOnList(moves, actorlow) movesmiddle = test_polemiddle.actOnList(moves, actormiddle) moveshigh = test_polehigh.actOnList(moves, actorhigh) self.assertTrue(actorlow.error < 1) print("low error", actorlow.resourcesError) # print("high error", actorhigh.error) print("high error" + str(actorhigh.resourcesError)) print("middle error", actormiddle.resourcesError) # print(actormiddle.error) print("done")
def test_EmotionalPole(self): # need to make categories and see if they add moves # pretty much only need to make actors, poles, and moves w only categories test_polelow = EmotionalPole(-.21, 1) test_polemiddle = EmotionalPole(0, 1) test_polehigh = EmotionalPole(.6, 1) actorlow = Actor([test_polelow], None, None, None, 0.05, None, None, [], []) actormiddle = Actor([test_polemiddle], None, None, None, 0.05, None, None, [], []) actorhigh = Actor([test_polehigh], None, None, None, 0.05, None, None, [], []) move1 = Event( None, None, Move({"t1": 0}, None, [], .5, 'Engage in diplomatic cooperation'), 0) move2 = Event( None, None, Move({"t1": 0}, None, [], .5, 'Engage in in material cooperation'), 0) move3 = Event(None, None, Move({"t1": 0}, None, [], .5, 'Appeal'), 0) # .4-.6 move4 = Event( None, None, Move({"t1": 0}, None, [], .5, 'Build economic infrastructure'), 0) move5 = Event( None, None, Move({"t1": 0}, None, [], .5, 'Build energy infrastructure'), 0) move6 = Event( None, None, Move({"t1": 0}, None, [], .5, 'Build military infrastructure'), 0) moveneg = Event(None, None, Move({"t1": 0}, None, [], .5, 'Assault'), 0) moveneg2 = Event(None, None, Move({"t1": 0}, None, [], .5, 'Coerce'), 0) history = [move1, move2, move3, move4, move5, move6, moveneg, moveneg2] actorlow.history = history actormiddle.history = history actorhigh.history = history moves = [] moveslow = test_polelow.actOnList(moves, actorlow) movesmiddle = test_polemiddle.actOnList(moves, actormiddle) moveshigh = test_polehigh.actOnList(moves, actorhigh) print("emotionalpole move length") print(len(moveslow)) print(len(movesmiddle)) print(len(moveshigh))
def test_GenerosityPole(self): test_polelow = GenerosityPole(-1, 1) test_polemiddle = GenerosityPole(0, 1) test_polehigh = GenerosityPole(1, 1) actorlow = Actor([test_polelow], None, None, None, .05, None, None, [], []) actormiddle = Actor([test_polemiddle], None, None, None, .05, None, None, [], []) actorhigh = Actor([test_polehigh], None, None, None, .05, None, None, [], []) move1 = Move({ "test1": 100, "test2": 100, "test3": 100 }, None, [], .5, None) move2 = Move({ "test1": 200, "test2": 200, "test3": 200 }, None, [], .5, None) move3 = Move({"test1": 0, "test2": 0, "test3": 0}, None, [], .5, None) move4 = Move({ "test1": 1000, "test2": 1000, "test3": 1000 }, None, [], .5, None) move5 = Move({ "test1": 500, "test2": 1000, "test3": 1000 }, None, [], .5, None) moves = [move1, move2, move3, move4, move5] moveslow = test_polelow.actOnList(moves, actorlow) movesmiddle = test_polemiddle.actOnList(moves, actormiddle) moveshigh = test_polehigh.actOnList(moves, actorhigh) self.assertTrue(move3 in moveslow) self.assertTrue(len(moveslow) == 1) self.assertTrue(len(moveshigh) == 5) self.assertTrue((move4 not in movesmiddle))
def test_rationalityPole(self): move1 = Move({ "test1": 5, "test2": 10, "test3": 20 }, None, [], .5, None) move2 = Move({ "test1": 100, "test2": 200, "test3": 300 }, None, [], .5, None) move3 = Move({"test1": 1, "test2": 1, "test3": 1}, None, [], .5, None) move4 = Move({ "test1": -10, "test2": 10, "test3": -100 }, None, [], .5, None) move5 = Move({ "test1": 500, "test2": 1000, "test3": 10000 }, None, [], .5, None) move0 = Move({"test1": 0, "test2": 0, "test3": 0}, None, [], 0, None) moves = [move1, move2, move3, move4, move5, move0] test_polelow = RationalityPole(-1, 1) test_polemiddle = RationalityPole(-.5, 1) test_polehigh = RationalityPole(1, 1) actorlow = Actor([test_polelow], None, None, None, 0.05, None, None, [], None) actormiddle = Actor([test_polemiddle], None, None, None, 0.05, None, None, [], None) actorhigh = Actor([test_polehigh], None, None, None, 0.05, None, None, [], None) moveslow = test_polelow.actOnList(moves, actorlow) movesmiddle = test_polemiddle.actOnList(moves, actormiddle) moveshigh = test_polehigh.actOnList(moves, actorhigh) self.assertEqual(len(moveshigh), 6) self.assertEqual(len(moveslow), 0) self.assertTrue(len(movesmiddle) < 4)
def test_PrimacyRecencyPole(self): curstate1 = State({"f1": 100, "f2": 0}, {"i1": 0}) desState1 = State({'f1': 1000}, {'i1': 1000}) test_polelow = PrimacyRecencyPole(-1, .1) test_polemiddle = PrimacyRecencyPole(0, 1) test_polehigh = PrimacyRecencyPole(1, 1) move1 = Move({"f1": 101, "f2": 0}, {"i1": 1}, [], 1, None) move2 = Move({"f1": 102, "f2": 0}, {"i1": 1}, [], 1, None) move3 = Move({"f1": 110, "f2": 0}, {"i1": 1}, [], 1, None) move4 = Move({"f1": 106, "f2": 0}, {"i1": 1}, [], 1, None) move5 = Move({"f1": 101, "f2": 0}, {"i1": 0}, [], 1, None) move6 = Move({"f1": 102, "f2": 0}, {"i1": 0}, [], 1, None) move7 = Move({"f1": 110, "f2": 0}, {"i1": 0}, [], 1, None) move8 = Move({"f1": 106, "f2": 0}, {"i1": 0}, [], 1, None) move00 = Move({"f1": 0, "f2": 0}, {"i1": 0}, [], 1, None) event1 = Event(None, None, move1, 0) event2 = Event(None, None, move2, 0) event3 = Event(None, None, move3, 0) event4 = Event(None, None, move4, 0) event5 = Event(None, None, move5, 0) event6 = Event(None, None, move6, 0) event7 = Event(None, None, move7, 0) event8 = Event(None, None, move8, 0) actorlow = Actor([test_polelow], curstate1, None, None, .05, None, None, [], []) actormiddle = Actor([test_polemiddle], curstate1, None, None, .05, None, None, [], []) # high recency actorhigh = Actor([test_polehigh], curstate1, None, None, .05, None, None, [], []) actorlow.memory = [event1, event2, event3, event4] actorhigh.memory = [event1, event2, event3, event4] actormiddle.memory = [event1, event2, event3, event4] actorlow.history = [event5, event6, event7, event8] actormiddle.history = [event5, event6, event7, event8] actorhigh.history = [event5, event6, event7, event8] test_MST1 = MST(curstate1, desState1, [move1, move2, move3, move4, move5, move6, move7, move8, move00], 2) test_MST2 = MST(curstate1, desState1, [move1, move2, move3, move4, move5, move6, move7, move8, move00], 2) test_MST3 = MST(curstate1, desState1, [move1, move2, move3, move4, move5, move6, move7, move8, move00], 2) low_mst = test_polelow.actOnMST(test_MST1, actorlow) # contain only move 1,2,5,6,7,8,00 mid_mst = test_polemiddle.actOnMST(test_MST2, actormiddle) # contain 1,2,5,6,00 high_mst = test_polehigh.actOnMST(test_MST3, actorhigh) # contain 1,2,3,,4 ,5,6,00 self.assertTrue(low_mst.containsMove(move1)) self.assertTrue(low_mst.containsMove(move2)) self.assertTrue(low_mst.containsMove(move5)) self.assertTrue(low_mst.containsMove(move6)) self.assertTrue(low_mst.containsMove(move7)) self.assertTrue(low_mst.containsMove(move00)) self.assertFalse(low_mst.containsMove(move3)) self.assertFalse(low_mst.containsMove(move4)) self.assertTrue(low_mst.containsMove(move8)) self.assertTrue(mid_mst.containsMove(move1)) self.assertTrue(mid_mst.containsMove(move2)) self.assertTrue(mid_mst.containsMove(move5)) self.assertTrue(mid_mst.containsMove(move6)) self.assertTrue(mid_mst.containsMove(move00)) self.assertFalse(mid_mst.containsMove(move3)) self.assertFalse(mid_mst.containsMove(move4)) self.assertFalse(mid_mst.containsMove(move7)) self.assertFalse(mid_mst.containsMove(move8)) self.assertFalse(mid_mst.containsMove(move3)) self.assertTrue(high_mst.containsMove(move2)) self.assertTrue(high_mst.containsMove(move3)) self.assertTrue(high_mst.containsMove(move4)) self.assertTrue(high_mst.containsMove(move5)) self.assertTrue(high_mst.containsMove(move6)) self.assertTrue(high_mst.containsMove(move00)) self.assertTrue(not high_mst.containsMove(move7)) self.assertTrue(not high_mst.containsMove(move8)) self.assertTrue(high_mst.containsMove(move1))
generate_resource_vocab(moves) # TODO # one hot for infrastructure as well s1 = [0] * 52 s2 = [100] * 52 s3 = [-1000] * 52 curState = State({i: s1[i] for i in range(len(s1))}, {0: 0}) desState = State({i: s2[i] for i in range(len(s2))}, {0: 100}) criticalState = State({i: s3[i] for i in range(len(s3))}, {0: -1000}) io_values = {"A": 0, "B": 0, "C": 0, "D": 0, "E": 0} actor = Actor([ rationality, risk, emotion, generosity, particularHolistic, primacyRecency, routineCreative ], curState, desState, maxTime=2, error=0, history=[], criticalState=criticalState, allActors=[], ioValues=io_values, end_io_state=io_values) actor.makeDecision()
def post_index(): # def __init__(self, poles, currentState, desiredState, maxTime, error, history, criticalState, allActors, ioValues, end_io_state): poles_list = [pole for pole in request.form if pole.endswith("val")] poles = [] for pole in poles_list: name = pole.replace(" ", "").replace("_val", "") MyClass = getattr(importlib.import_module("dm.Pole"), name + "Pole") val = float(request.form.get(pole)) / 100 weight = float(request.form.get(pole.replace("val", "weight"))) / 100 poles.append(MyClass(val, weight)) with open("static/resource_vocab.txt", 'r') as file: resources = [line.rstrip('\n') for line in file] current_resources = { resource: 1 for resource in request.form.get("cur_resources").replace("," "").split() } desired_resources = { resource: 1 for resource in request.form.get("des_resources").replace("," "").split() } critical_resources = { resource: 1 for resource in request.form.get("critical_resources").replace( "," "").split() } current_infra = { infra: 1 for infra in request.form.get("cur_infra").replace("," "").split() } desired_infra = { infra: 1 for infra in request.form.get("des_infra").replace("," "").split() } critical_infra = { infra: 1 for infra in request.form.get("critical_infra").replace("," "").split() } current_state = State(current_resources, current_infra) desired_state = State(desired_resources, desired_infra) critical_state = State(critical_resources, critical_infra) max_time = int(request.form.get("max_time")) error = int(request.form.get("error")) # TODO history is blank for now # TODO allActors is blank for now io_list = [io for io in request.form if io.endswith("end")] io_values = {} desired_io_values = {} for io in io_list: val = float(request.form.get(io)) / 100 io_values[io.replace("_value_end", "")] = val desired_val = float(request.form.get(io.replace("_end", ""))) desired_io_values[io.replace("_value_end", "")] = desired_val actor = Actor(poles, current_state, desired_state, max_time, error, [], critical_state, [], io_values, desired_io_values)
def test_RoutineCreativePole(self): test_polelow = RoutineCreativePole(-.75, 1) test_polemiddle = RoutineCreativePole(0, 1) test_polehigh = RoutineCreativePole(1, 1) # high primacy actorlow = Actor([test_polelow], State({ "test1": 1, "test2": 1, "test3": 1, "test4": 1 }, None), None, None, .1, None, None, [], []) actormiddle = Actor([test_polemiddle], State( { "test1": 1, "test2": 1, "test3": 1, "test4": 1 }, None), None, None, .1, None, None, [], []) # high recency actorhigh = Actor([test_polehigh], State( { "test1": 1, "test2": 1, "test3": 1, "test4": 1 }, None), None, None, .1, None, None, [], []) event1 = Event( None, None, Move({ "test1": 1, "test2": 1, "test3": 1, "test4": 1 }, None, [], .5, None), 0) event2 = Event( None, None, Move({ "test1": 0, "test2": 0, "test3": 0, "test4": 0 }, None, [], .5, None), 0) # event3 = Event(None, None, Move({"test1":100, "test2": 100, "test3": 200, "test4": 300}, None, [], .5, None),0) # event4 = Event(None, None, Move({"test1":0, "test2": 0, "test3": 0, "test4": 1}, None, [], .5, None),0) # event5 = Event(None, None, Move({"test1":1, "test2": 1, "test3": 1, "test4": 2}, None, [], .5, None),0) # event6 = Event(None, None, Move({"test1":101, "test2": 100, "test3": 100, "test4": 100}, None, [], .5, None),0) # event7 = Event(None, None, Move({"test1":501, "test2": 500, "test3": 500, "test4": 500}, None, [], .5, None),0) # event8 = Event(None, None, Move({"test1":1, "test2": 1, "test3": 0, "test4": 0}, None, [], .5, None),0) moves = [ Move({ "test1": 1, "test2": 1, "test3": 1, "test4": 1 }, None, [], .5, None), Move({ "test1": 0, "test2": 0, "test3": 0, "test4": 0 }, None, [], .5, None), Move({ "test1": 1000, "test2": 1000, "test3": 1000, "test4": 1000 }, None, [], .5, None), Move({ "test1": .75, "test2": .75, "test3": .75, "test4": .75 }, None, [], .5, None), Move({ "test1": .89, "test2": .99, "test3": .99, "test4": 1 }, None, [], .5, None) ] successfulMoves = [ event1, event2 ] # ,event3, event4, event5, event6, event7, event8] actorlow.timeTicks = 8 actormiddle.timeTicks = 8 actorhigh.timeTicks = 8 actorlow.successfulMoves = successfulMoves actorhigh.successfulMoves = successfulMoves actormiddle.successfulMoves = successfulMoves moveslow = test_polelow.actOnList(moves, actorlow) movesmiddle = test_polemiddle.actOnList(moves, actormiddle) moveshigh = test_polehigh.actOnList(moves, actorhigh) print("PRINTING MOVES LOW MIDDLE HIGH") print(len(moveslow)) print(len(movesmiddle)) print(len(moveshigh))
def test_PrimacyRecencyPole(self): test_polelow = PrimacyRecencyPole(-1, 1) test_polemiddle = PrimacyRecencyPole(0, 1) test_polehigh = PrimacyRecencyPole(1, 1) # high primacy actorlow = Actor([test_polelow], State({ "test1": 1, "test2": 0, "test3": 0, "test4": 0 }, None), None, None, .05, None, None, [], []) actormiddle = Actor([test_polemiddle], State( { "test1": 1, "test2": 0, "test3": 0, "test4": 0 }, None), None, None, .05, None, None, [], []) # high recency actorhigh = Actor([test_polehigh], State( { "test1": 1, "test2": 0, "test3": 0, "test4": 0 }, None), None, None, .05, None, None, [], []) event1 = Event( None, None, Move({ "test1": 1, "test2": 1, "test3": 1, "test4": 1 }, None, [], .5, None), 0) event2 = Event( None, None, Move({ "test1": 1, "test2": 1, "test3": 1, "test4": 2 }, None, [], .5, None), 0) event3 = Event( None, None, Move({ "test1": .96, "test2": 0, "test3": 0, "test4": 0 }, None, [], .5, None), 0) event4 = Event( None, None, Move({ "test1": 0, "test2": 0, "test3": 0, "test4": 0 }, None, [], .5, None), 0) event5 = Event( None, None, Move({ "test1": 1, "test2": 1, "test3": 1, "test4": 2 }, None, [], .5, None), 0) event6 = Event( None, None, Move({ "test1": 101, "test2": 100, "test3": 100, "test4": 100 }, None, [], .5, None), 0) event7 = Event( None, None, Move({ "test1": 501, "test2": 500, "test3": 500, "test4": 500 }, None, [], .5, None), 0) event8 = Event( None, None, Move({ "test1": 1, "test2": 1, "test3": 0, "test4": 0 }, None, [], .5, None), 0) moves = [] history = [event1, event2, event3, event4] memory = [event5, event6, event7, event8] actorlow.history = [event1, event2, event3, event4] actorhigh.history = [event1, event2, event3, event4] actormiddle.history = [event1, event2, event3, event4] actorlow.memory = [event5, event6, event7, event8] actormiddle.memory = [event5, event6, event7, event8] actorhigh.memory = [event5, event6, event7, event8] print("MOVES LOW") moveslow = test_polelow.actOnList(moves, actorlow) print("MOVES MID:") movesmiddle = test_polemiddle.actOnList(moves, actormiddle) print("MOVES HIGH:") moveshigh = test_polehigh.actOnList(moves, actorhigh)