first working computation with new model
This commit is contained in:
parent
8b7cab4c59
commit
b36982b65d
7 changed files with 487 additions and 17 deletions
|
|
@ -26,6 +26,8 @@
|
|||
7
|
||||
],
|
||||
"type": "vote",
|
||||
"proposer": 0,
|
||||
"voten": 1,
|
||||
"round": 1
|
||||
},
|
||||
{
|
||||
|
|
@ -69,6 +71,8 @@
|
|||
6
|
||||
],
|
||||
"type": "vote",
|
||||
"proposer": 1,
|
||||
"voten": 1,
|
||||
"round": 2
|
||||
},
|
||||
{
|
||||
|
|
@ -95,6 +99,8 @@
|
|||
5
|
||||
],
|
||||
"type": "vote",
|
||||
"proposer": 2,
|
||||
"voten": 2,
|
||||
"round": 2
|
||||
},
|
||||
{
|
||||
|
|
@ -121,6 +127,8 @@
|
|||
3
|
||||
],
|
||||
"type": "vote",
|
||||
"proposer": 3,
|
||||
"voten": 3,
|
||||
"round": 2
|
||||
},
|
||||
{
|
||||
|
|
@ -147,6 +155,8 @@
|
|||
6
|
||||
],
|
||||
"type": "vote",
|
||||
"proposer": 4,
|
||||
"voten": 4,
|
||||
"round": 2
|
||||
},
|
||||
{
|
||||
|
|
@ -202,6 +212,8 @@
|
|||
7
|
||||
],
|
||||
"type": "vote",
|
||||
"proposer": 5,
|
||||
"voten": 1,
|
||||
"round": 3
|
||||
},
|
||||
{
|
||||
|
|
@ -227,6 +239,8 @@
|
|||
6,
|
||||
7
|
||||
],
|
||||
"proposer": 6,
|
||||
"voten": 2,
|
||||
"type": "vote",
|
||||
"round": 3
|
||||
},
|
||||
|
|
@ -253,7 +267,9 @@
|
|||
5,
|
||||
7
|
||||
],
|
||||
"proposer": 7,
|
||||
"type": "vote",
|
||||
"voten": 3,
|
||||
"round": 3
|
||||
},
|
||||
{
|
||||
|
|
@ -280,6 +296,8 @@
|
|||
5
|
||||
],
|
||||
"type": "vote",
|
||||
"proposer": 0,
|
||||
"voten": 4,
|
||||
"round": 3
|
||||
},
|
||||
{
|
||||
|
|
@ -335,7 +353,9 @@
|
|||
5,
|
||||
6
|
||||
],
|
||||
"proposer": 1,
|
||||
"type": "vote",
|
||||
"voten": 1,
|
||||
"round": 4
|
||||
},
|
||||
{
|
||||
|
|
@ -382,6 +402,8 @@
|
|||
6
|
||||
],
|
||||
"type": "vote",
|
||||
"proposer": 1,
|
||||
"voten": 1,
|
||||
"round": 5
|
||||
},
|
||||
{
|
||||
|
|
@ -403,4 +425,4 @@
|
|||
"must fail": true,
|
||||
"round": 5
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
|
|||
450
games/p2
Normal file
450
games/p2
Normal file
|
|
@ -0,0 +1,450 @@
|
|||
[
|
||||
{
|
||||
"game_size": 10,
|
||||
"player_names": {}
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
1,
|
||||
7,
|
||||
8
|
||||
],
|
||||
"votes": [
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"round": 1,
|
||||
"voten": 1,
|
||||
"proposer": 8,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
2,
|
||||
7,
|
||||
9
|
||||
],
|
||||
"votes": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"round": 1,
|
||||
"voten": 2,
|
||||
"proposer": 9,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
0,
|
||||
5,
|
||||
6
|
||||
],
|
||||
"votes": [
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"round": 1,
|
||||
"voten": 3,
|
||||
"proposer": 0,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "mission",
|
||||
"team": [
|
||||
0,
|
||||
5,
|
||||
6
|
||||
],
|
||||
"fails": 1,
|
||||
"round": 1,
|
||||
"must fail": false,
|
||||
"print_order": [
|
||||
"team",
|
||||
"fails",
|
||||
"must fail",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
1,
|
||||
3,
|
||||
6,
|
||||
7
|
||||
],
|
||||
"votes": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"round": 2,
|
||||
"voten": 1,
|
||||
"proposer": 1,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
7
|
||||
],
|
||||
"votes": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"round": 2,
|
||||
"voten": 2,
|
||||
"proposer": 2,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
0,
|
||||
1,
|
||||
3,
|
||||
4
|
||||
],
|
||||
"votes": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"round": 2,
|
||||
"voten": 3,
|
||||
"proposer": 3,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
0,
|
||||
4,
|
||||
7,
|
||||
9
|
||||
],
|
||||
"votes": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"round": 2,
|
||||
"voten": 4,
|
||||
"proposer": 4,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "mission",
|
||||
"team": [
|
||||
0,
|
||||
4,
|
||||
7,
|
||||
9
|
||||
],
|
||||
"fails": 1,
|
||||
"round": 2,
|
||||
"must fail": false,
|
||||
"print_order": [
|
||||
"team",
|
||||
"fails",
|
||||
"must fail",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "lady",
|
||||
"p1": 7,
|
||||
"p2": 0,
|
||||
"is good": true,
|
||||
"round": false,
|
||||
"print_order": [
|
||||
"p1",
|
||||
"p2",
|
||||
"round",
|
||||
"is good"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
0,
|
||||
4,
|
||||
5,
|
||||
9
|
||||
],
|
||||
"votes": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"round": 3,
|
||||
"voten": 1,
|
||||
"proposer": 5,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
0,
|
||||
3,
|
||||
6,
|
||||
7
|
||||
],
|
||||
"votes": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"round": 3,
|
||||
"voten": 2,
|
||||
"proposer": 6,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
0,
|
||||
2,
|
||||
6,
|
||||
7
|
||||
],
|
||||
"votes": [
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"round": 3,
|
||||
"voten": 3,
|
||||
"proposer": 7,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vote",
|
||||
"team": [
|
||||
0,
|
||||
1,
|
||||
8,
|
||||
9
|
||||
],
|
||||
"votes": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0
|
||||
],
|
||||
"round": 3,
|
||||
"voten": 4,
|
||||
"proposer": 8,
|
||||
"fails required": 1,
|
||||
"print_order": [
|
||||
"team",
|
||||
"votes",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "mission",
|
||||
"team": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
9
|
||||
],
|
||||
"fails": 0,
|
||||
"round": 3,
|
||||
"must fail": true,
|
||||
"print_order": [
|
||||
"team",
|
||||
"fails",
|
||||
"must fail",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "lady",
|
||||
"p1": 0,
|
||||
"p2": 9,
|
||||
"is good": true,
|
||||
"round": false,
|
||||
"print_order": [
|
||||
"p1",
|
||||
"p2",
|
||||
"round",
|
||||
"is good"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "mission",
|
||||
"team": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
7,
|
||||
9
|
||||
],
|
||||
"fails": 0,
|
||||
"round": 4,
|
||||
"must fail": false,
|
||||
"print_order": [
|
||||
"team",
|
||||
"fails",
|
||||
"must fail",
|
||||
"round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "mission",
|
||||
"team": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
6
|
||||
],
|
||||
"fails": 0,
|
||||
"round": 5,
|
||||
"must fail": true,
|
||||
"print_order": [
|
||||
"team",
|
||||
"fails",
|
||||
"must fail",
|
||||
"round"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -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([])):
|
||||
|
|
|
|||
2
tim.py
2
tim.py
|
|
@ -114,7 +114,7 @@ def main():
|
|||
|
||||
game = DeceptionGame(
|
||||
AvalonGame(int(metadata["game_size"])),
|
||||
DefaultModel)
|
||||
DataModel)
|
||||
namemap = metadata["player_names"]
|
||||
game.load_save(data)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue