Skip to content

Commit

Permalink
enable associations by min values
Browse files Browse the repository at this point in the history
  • Loading branch information
rbroc committed Jan 18, 2024
1 parent 311189e commit 6ad7c34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/simcat/agents.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pandas as pd
import numpy as np
from .utils import load_matrix
from .matrix import Matrix
import json
from copy import deepcopy
Expand Down Expand Up @@ -85,15 +84,18 @@ def get_metrics(self, resp_wd, kvals, t):
resp_neighbors_current,
]

def speak(self, seed, pop=True):
def speak(self, seed, stopping_rule='distance', pop=True):
"""Picks response word based on cue (seed).
Returns probability of cue-response association, and response word.
Also pops response/cue value if pop=True
Args:
seed (str): seed word at current turn
pop (bool): whether to remove the word from memory
"""
resp_idx = np.argmin(self.matrix.data[seed])
if stopping_rule == 'distance':
resp_idx = np.argmin(self.matrix.data[seed])
else:
resp_idx = np.argmax(self.matrix.data[seed])
resp_wd = self.matrix.data[seed].index[resp_idx]
prob = self.listen(seed, resp_wd, pop)
return round(prob, 5), resp_wd
Expand Down
3 changes: 2 additions & 1 deletion src/simcat/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def _run_trial(self, speaker, seed, turn, itr, init_seed, log=None):
init_seed (str): initial seed word
log (df): dataframe containing interaction log
"""
prob_agent, resp = speaker.speak(seed=seed)
prob_agent, resp = speaker.speak(seed=seed,
stopping_rule=self.stopping_rule)
prob = [
a.listen(seed, resp) if a is not speaker else prob_agent
for a in self.agents
Expand Down

0 comments on commit 6ad7c34

Please sign in to comment.