ConversationFlow is an R6 base class defining the interface for turn-taking
mechanisms in a focus group simulation. Subclasses implement specific strategies
for selecting the next speaker.
Value
An R6 generator meant for subclassing; instances are built by
create_conversation_flow(), which returns a ConversationFlow
subclass object ready for FocusGroup.
Methods for Subclassing
initialize(agents, moderator_id)Sets up the flow. Call
super$initialize(agents, moderator_id).select_next_speaker(focus_group)Required. Logic to choose the next
FGAgentto speak. Should return the agent object orNULL.update_state_post_selection(speaker_id, focus_group)Optional. Updates internal state after a speaker has spoken. Base implementation updates
self$last_speaker_id.note_moderator_turn()Optional. Called after every moderator line: a guide item, a call-on line, or an injected moderator message. Base implementation clears
self$last_speaker_id, so that a flow that passes over the previous speaker bars only back-to-back participant turns.
Public fields
agentsA named list of
FGAgentobjects participating in the conversation.participant_idsA character vector of agent identifiers, excluding the moderator.
moderator_idCharacter. The ID of the moderator agent.
last_speaker_idThe ID of the agent who last spoke. Can be
NULL.selection_metadataDetails recorded for the latest selection when it departs from the flow's usual rule, such as a lowered desire threshold or, under
on_desire_failure = "random", a desire-scoring failure.routing_recordThe record of the latest selection, whatever rule made it: a list with
flow,rule,candidates,excluded(a named character vector giving the reason each excluded participant was passed over),scores,threshold,tied,tie_break, andselected_id. A running session copies it into its routing record after every pick. A subclass that does not set it is recorded with rule"custom".
Methods
Method new()
Initializes the ConversationFlow object.
Usage
ConversationFlow$new(agents, moderator_id)Method note_moderator_turn()
Notes that the moderator has just spoken. The participant who spoke before the moderator's line is then no longer the previous speaker: whoever closed one question may open the next.
