def test_score_with_weights(self): axl.seed(0) opponents_information = [ utils.PlayerInfo(s, {}) for s in axl.demo_strategies ] objective = utils.prepare_objective() params = DummyParams() score = utils.score_params( params, objective=objective, opponents_information=opponents_information, # All weight on Coop weights=[1, 0, 0, 0, 0]) expected_score = 3 self.assertEqual(score, expected_score) score = utils.score_params( params, objective=objective, opponents_information=opponents_information, # Shared weight between Coop and Def weights=[2, 2, 0, 0, 0]) expected_score = 1.5 self.assertEqual(score, expected_score) score = utils.score_params( params, objective=objective, opponents_information=opponents_information, # Shared weight between Coop and Def weights=[2, -.5, 0, 0, 0]) expected_score = 4.0 self.assertEqual(score, expected_score)
def test_with_init_kwargs(self): axl.seed(0) opponents_information = [utils.PlayerInfo(axl.Random, {"p": 0})] objective = utils.prepare_objective() score = utils.score_player(axl.Cooperator(), objective=objective, opponents_information=opponents_information) expected_score = 0 self.assertEqual(score, expected_score) opponents_information = [utils.PlayerInfo(axl.Random, {"p": 1})] objective = utils.prepare_objective() score = utils.score_player(axl.Cooperator(), objective=objective, opponents_information=opponents_information) expected_score = 3.0 self.assertEqual(score, expected_score)
def test_score(self): axl.seed(0) opponents_information = [ utils.PlayerInfo(s, {}) for s in axl.demo_strategies ] objective = utils.prepare_objective() score = utils.score_player(axl.Cooperator(), objective=objective, opponents_information=opponents_information) expected_score = 2.0949 self.assertEqual(score, expected_score)