Skip to content

Commit

Permalink
rsa recursive swap speaker/listener
Browse files Browse the repository at this point in the history
  • Loading branch information
kach committed Jul 3, 2024
1 parent 55717ad commit 1cfdb11
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions demo-rsa-recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ def denotes(u, r):
[1, 1]
])[r, u]

@memo
def listener[u: U, r: R](beta, t):
cast: [listener, speaker]
listener: thinks[
speaker: given(r in R, wpp=1),
speaker: chooses(u in U, wpp=speaker[u, r](beta, t - 1) if t > 0 else denotes(u, r))
]
listener: observes [speaker.u] is u
listener: chooses(r in R, wpp=E[speaker.r == r])
return E[listener.r == r]

@memo
def speaker[u: U, r: R](beta, t):
cast: [speaker, listener]
Expand All @@ -35,6 +24,17 @@ def speaker[u: U, r: R](beta, t):
])
return E[speaker.u == u]

@memo
def listener[u: U, r: R](beta, t):
cast: [listener, speaker]
listener: thinks[
speaker: given(r in R, wpp=1),
speaker: chooses(u in U, wpp=speaker[u, r](beta, t - 1) if t > 0 else denotes(u, r))
]
listener: observes [speaker.u] is u
listener: chooses(r in R, wpp=E[speaker.r == r])
return E[listener.r == r]

beta = 3.
for t in range(10):
ic(t, listener(beta, t), speaker(beta, t))

0 comments on commit 1cfdb11

Please sign in to comment.