예제 #1
0
    def setUp(self):
        self.game = gambit.read_game("test_games/mixed_strategy.nfg")

        self.profile_double = self.game.mixed_profile()
        self.profile_rational = self.game.mixed_profile(True)
        self.restriction = self.profile_double.restriction()

        self.tree_game = gambit.read_game("test_games/mixed_behavior_game.efg")

        self.tree_profile_double = self.tree_game.mixed_profile()
        self.tree_profile_rational = self.tree_game.mixed_profile(True)
        self.tree_restriction = self.tree_profile_double.restriction()
예제 #2
0
    def setUp(self):
        self.game = gambit.read_game("test_games/mixed_strategy.nfg")

        self.profile_double = self.game.mixed_profile()
        self.profile_rational = self.game.mixed_profile(True)
        self.restriction = self.profile_double.restriction()

        self.tree_game = gambit.read_game("test_games/mixed_behavior_game.efg")

        self.tree_profile_double = self.tree_game.mixed_profile()
        self.tree_profile_rational = self.tree_game.mixed_profile(True)
        self.tree_restriction = self.tree_profile_double.restriction()
예제 #3
0
 def test_player_get_max_payoff(self):
     "To test getting the maximum payoff for the players"
     game = gambit.read_game("test_games/payoff_game.nfg")
     assert game.players[0].max_payoff == fractions.Fraction(10, 1)
     assert game.players["Player 1"].max_payoff == fractions.Fraction(10, 1)
     assert game.players[1].max_payoff == fractions.Fraction(8, 1)
     assert game.players["Player 2"].max_payoff == fractions.Fraction(8, 1)
예제 #4
0
 def test_player_get_min_payoff(self):
     "To test getting the minimum payoff for the players"
     game = gambit.read_game("test_games/payoff_game.nfg")
     assert game.players[0].min_payoff == fractions.Fraction(4,1)
     assert game.players["Player 1"].min_payoff == fractions.Fraction(4,1)
     assert game.players[1].min_payoff == fractions.Fraction(1,1)
     assert game.players["Player 2"].min_payoff == fractions.Fraction(1,1)
예제 #5
0
    def setUp(self):
        self.game = gambit.new_table([2,2])
        self.game.players[0].label = "joe"
        self.game.players["joe"].strategies[0].label = "cooperate"
        self.game.players[1].label = "dan"
        self.game.players["dan"].strategies[1].label = "defect"
        
        self.profile_double = self.game.mixed_profile()
        self.profile_rational = self.game.mixed_profile(True)

        self.tree_game = gambit.read_game("test_games/mixed_behavior_game.efg")

        self.tree_profile_double = self.tree_game.mixed_profile()
        self.tree_profile_rational = self.tree_game.mixed_profile(True)
예제 #6
0
파일: test_mixed.py 프로젝트: theref/gambit
    def setUp(self):
        self.game = gambit.new_table([2, 2])
        self.game.players[0].label = "joe"
        self.game.players["joe"].strategies[0].label = "cooperate"
        self.game.players[1].label = "dan"
        self.game.players["dan"].strategies[1].label = "defect"

        self.profile_double = self.game.mixed_profile()
        self.profile_rational = self.game.mixed_profile(True)

        self.tree_game = gambit.read_game("test_games/mixed_behavior_game.efg")

        self.tree_profile_double = self.tree_game.mixed_profile()
        self.tree_profile_rational = self.tree_game.mixed_profile(True)
예제 #7
0
def getEquilibrium(fname, infoFile):
	debug = 0
	g = gambit.read_game(fname)
	for player in g.players:
		print player.label, len(player.strategies)

	with open(infoFile) as jFile:
		data = json.load(jFile)

	for pnum, role in enumerate(data['roles']):
		for index, strategy in enumerate(role['strategies']):
			g.players[pnum].strategies[index].label = strategy

	if debug:
		for player in g.players:
			print player.strategies,"\n"

		print list(g.contingencies)
		for i in range(0, len(g.players[0].strategies)):
			for j in range(0, len(g.players[1].strategies)):
				print g[i,j][0],
				print "\t\t\t",
				print g[i,j][1]

	with open("Eq.txt", 'w') as rF:
		rF.write("Mapping of player strategies\n")
		for player in g.players:
			rF.write(player.label + ":[")
			for strategy in player.strategies:
				rF.write(strategy.label + " ")
			rF.write("]\n")
		rF.write("\n\n")
		for desc, func in methods.iteritems():
			rF.write(desc + "\n")
			solver = func();
			res = solver.solve(g)
			writeToFile(rF, g, res)
			rF.write("\n\n")
예제 #8
0
 def setUp(self):
     self.game = gambit.read_game("test_games/mixed_behavior_game.efg")
     
     self.profile_double = self.game.behav_profile()
     self.profile_rational = self.game.behav_profile(True)
예제 #9
0
 def setUp(self):
     self.game = gambit.new_tree()
     self.extensive_game = gambit.read_game("test_games/basic_extensive_game.efg")
예제 #10
0
 def setUp(self):
     self.game = gambit.read_game("test_games/mixed_behavior_game.efg")
     
     self.profile_double = self.game.behav_profile()
     self.profile_rational = self.game.behav_profile(True)
예제 #11
0
 def setUp(self):
     self.extensive_game = gambit.read_game(
         "test_games/complicated_extensive_game.efg")
예제 #12
0
 def setUp(self):
     self.extensive_game = gambit.read_game("test_games/basic_extensive_game.efg")
     self.complicated_game = gambit.read_game("test_games/complicated_extensive_game.efg")
예제 #13
0
 def setUp(self):
     self.game = gambit.read_game("./test_games/sample_extensive_game.efg")
예제 #14
0
 def setUp(self):
     self.game = gambit.read_game("test_games/mixed_strategy.nfg")
     self.support_profile = self.game.support_profile()
     self.restriction = self.support_profile.restrict()
예제 #15
0
 def test_game_is_not_perfect_recall(self):
     "To test checking if the game is not of perfect recall"
     game = gambit.read_game("test_games/not_perfect_recall.efg")
     assert not game.is_perfect_recall
예제 #16
0
 def test_game_get_max_payoff(self):
     "To test getting the maximum payoff of the game"
     game = gambit.read_game("test_games/payoff_game.nfg")
     assert game.max_payoff == fractions.Fraction(10,1)
예제 #17
0
 def setUp(self):
     self.game = gambit.new_table([2,2])
     self.extensive_game = gambit.read_game("test_games/basic_extensive_game.efg")
예제 #18
0
 def test_game_is_not_const_sum(self):
     "To test checking if the game is not constant sum"
     game = gambit.read_game("test_games/non_const_sum_game.nfg")
     assert not game.is_const_sum