first working computation with new model
This commit is contained in:
parent
8b7cab4c59
commit
b36982b65d
7 changed files with 487 additions and 17 deletions
|
|
@ -42,9 +42,9 @@ class DataModel(DefaultModel):
|
|||
elif role == "Percival":
|
||||
roles = [self.player_role(x) for x in team]
|
||||
tc = ""
|
||||
if "merlin" in roles:
|
||||
if "Merlin" in roles:
|
||||
tc += "merlin"
|
||||
if "morgana" in roles:
|
||||
if "Morgana" in roles:
|
||||
tc += "morgana"
|
||||
if tc == "":
|
||||
tc = "neither"
|
||||
|
|
@ -81,10 +81,13 @@ class DataModel(DefaultModel):
|
|||
else:
|
||||
continue
|
||||
app = approval(data)
|
||||
if app == 0.0:
|
||||
continue
|
||||
if vote == 1:
|
||||
total = total * app
|
||||
else:
|
||||
total = total * (1.0 - app)
|
||||
#print total
|
||||
return total
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -46,13 +46,13 @@ class BaseModel(object):
|
|||
|
||||
# Override these!
|
||||
def player_sees_player_and_claims(self, p1, p2, claim, rnd):
|
||||
return True
|
||||
return 1.0
|
||||
|
||||
def mission(self, team, fails, must_fail, rnd):
|
||||
return True
|
||||
return 1.0
|
||||
|
||||
def votes(self, team, votes, fail_req, rnd, voten, proposer):
|
||||
return True
|
||||
return 1.0
|
||||
|
||||
|
||||
class DefaultModel(BaseModel):
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ def isSpy(x, game):
|
|||
return game["players"][x]["spy"]
|
||||
|
||||
def approval(x):
|
||||
if x["Approve"] + x["Reject"] == 0:
|
||||
if x[0] + x[1] == 0:
|
||||
return 0.0
|
||||
return (x["Approve"] * 1.0) / (x["Approve"] + x["Reject"])
|
||||
return (x[0] * 1.0) / (x[0] + x[1])
|
||||
|
||||
def getRole(x, game):
|
||||
if str(x) not in game["role_by_seat"]:
|
||||
|
|
@ -23,16 +23,11 @@ def getRole(x, game):
|
|||
return game["role_by_seat"][str(x)]
|
||||
|
||||
def sumKeys(a, b):
|
||||
out = dd(int)
|
||||
for k, v in a.items():
|
||||
out[k] += v
|
||||
for k, v in b.items():
|
||||
out[k] += v
|
||||
return out
|
||||
return (a[0] + b[0], a[1] + b[1])
|
||||
|
||||
def sum_helper(table, constraint_list):
|
||||
def sum_helper(table, constraint_list, keys=["Approve", "Reject"]):
|
||||
if len(constraint_list) == 0:
|
||||
return table
|
||||
return (table[keys[0]], table[keys[1]])
|
||||
c = constraint_list[0]
|
||||
out = dd(int)
|
||||
if isinstance(c, type([])):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue