def test_create_vector_bounds(self): plays, op_plays, op_start_plays = 1, 1, 1 player = axl.EvolvableGambler(parameters=(plays, op_plays, op_start_plays)) lb, ub = player.create_vector_bounds() self.assertIsInstance(lb, list) self.assertIsInstance(ub, list) self.assertEqual(len(lb), 8) self.assertEqual(len(ub), 8)
def test_vector_to_instance(self): plays, op_plays, op_start_plays = 1, 1, 1 player = axl.EvolvableGambler(parameters=(plays, op_plays, op_start_plays)) vector = [random.random() for _ in range(8)] player.receive_vector(vector) keys = create_lookup_table_keys(player_depth=plays, op_depth=op_plays, op_openings_depth=op_start_plays) action_dict = dict(zip(keys, vector)) self.assertEqual(player._lookup.dictionary, action_dict)
def test_receive_vector(self): plays, op_plays, op_start_plays = 1, 1, 1 player = axl.EvolvableGambler(parameters=(plays, op_plays, op_start_plays)) self.assertRaises(AttributeError, axl.EvolvableGambler.__getattribute__, *[player, 'vector']) vector = [random.random() for _ in range(8)] player.receive_vector(vector) self.assertEqual(player.pattern, vector)
def test_mutate_value_bounds(self): player = axl.EvolvableGambler(parameters=(1, 1, 1), seed=0) self.assertEqual(player.mutate_value(2), 1) self.assertEqual(player.mutate_value(-2), 0)