pep8 and better lady model

This commit is contained in:
Barak Michener 2013-07-29 19:36:54 -04:00
parent 9eb3625393
commit b9f07c85fa

50
tim.py
View file

@ -25,7 +25,7 @@ class DeceptionGame(object):
self.observations = [] self.observations = []
self.seen = [] self.seen = []
self.tid = 0 self.tid = 0
self.lady_will_duck = mc.Bernoulli("lady_will_duck", 0.5) self.lady_will_duck = mc.Bernoulli("lady_will_duck", 0.8)
self.mission_ducks_on_round = [None] * 5 self.mission_ducks_on_round = [None] * 5
self.mission_ducks_on_round[0] = mc.Bernoulli("missionduck_on_0", 0.5) self.mission_ducks_on_round[0] = mc.Bernoulli("missionduck_on_0", 0.5)
self.mission_ducks_on_round[1] = mc.Bernoulli("missionduck_on_1", 0.5) self.mission_ducks_on_round[1] = mc.Bernoulli("missionduck_on_1", 0.5)
@ -78,16 +78,16 @@ class DeceptionGame(object):
else: else:
return None return None
else: else:
if self.lady_will_duck.rand(): if self.player_is_good(deal, p2):
if self.player_is_good(deal, p2) == claim: if claim == True:
return True return self.lady_will_duck.rand()
else: else:
return False return not self.lady_will_duck.rand()
else: else:
if self.player_is_good(deal, p2) == claim: if claim == False:
return False return self.lady_will_duck.rand()
else: else:
return True return not self.lady_will_duck.rand()
transaction.append(obs) transaction.append(obs)
self.observations.append(transaction) self.observations.append(transaction)
self.seen.append(["Lady:", p1, "says", p2 , "is", "Good" if claim else "Evil"]) self.seen.append(["Lady:", p1, "says", p2 , "is", "Good" if claim else "Evil"])
@ -360,23 +360,23 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()
base_game = DeceptionGame(ResistanceGame(5)) base_game = DeceptionGame(ResistanceGame(5))
#base_game.add_known_role(0, "G1") #base_game.add_known_role(0, "G1")
#base_game.add_known_alliance(1, False) #base_game.add_known_alliance(1, False)
#base_game.player_sees_player_and_claims(0, 1, True) #base_game.player_sees_player_and_claims(0, 1, True)
#base_game.player_sees_player_and_claims(1, 2, False) #base_game.player_sees_player_and_claims(1, 2, False)
#base_game.player_sees_player_and_claims(2, 3, False) #base_game.player_sees_player_and_claims(2, 3, False)
base_game.do_vote([1,2], [0,1,1,0,1], 1) base_game.do_vote([1,2], [0,1,1,0,1], 1)
base_game.do_mission([1,2], 0, False, 1) base_game.do_mission([1,2], 0, False, 1)
base_game.do_vote([0, 1, 2], [1,1,1,0,1], 2) base_game.do_vote([0, 1, 2], [1,1,1,0,1], 2)
base_game.do_mission([0, 1, 2], 1, False, 2) base_game.do_mission([0, 1, 2], 1, False, 2)
base_game.do_vote([3, 4], [0,0,1,1,1], 3) base_game.do_vote([3, 4], [0,0,1,1,1], 3)
base_game.do_mission([3, 4], 0, False, 3) base_game.do_mission([3, 4], 0, False, 3)
base_game.do_vote([3, 4], [0,0,1,1,1], 4) base_game.do_vote([3, 4], [0,0,1,1,1], 4)
base_game.do_mission([0, 3, 4], 1, False, 4) base_game.do_mission([0, 3, 4], 1, False, 4)
#base_game.do_vote([1, 3, 4], [0,1,1,0,1], 5) #base_game.do_vote([1, 3, 4], [0,1,1,0,1], 5)
#base_game.do_mission([1, 3, 4], 1, True, 5) #base_game.do_mission([1, 3, 4], 1, True, 5)
base_game.eval(100) base_game.eval(100)
base_game.print_report() base_game.print_report()