/// <summary> /// Ask Help to teammates about it belief /// when task is blocked because of a lack of belief /// </summary> /// <param name="task"></param> /// <param name="blocker"></param> public virtual void TryRecoverBlockerIncompleteBelief(SymuTask task, Blocker blocker) { if (task is null) { throw new ArgumentNullException(nameof(task)); } if (blocker is null) { throw new ArgumentNullException(nameof(blocker)); } // Check if he has the right to receive knowledge from others agents if (!Cognitive.MessageContent.CanReceiveBeliefs) { // If agent has no other strategy // Blocker must be unblocked in a way or another RecoverBlockerIncompleteBeliefByGuessing(task, blocker); return; } var murphy = Environment.MainOrganization.Murphies.IncompleteBelief; var knowledgeId = (IAgentId)blocker.Parameter; var knowledgeBit = (byte)blocker.Parameter2; var teammates = GetAgentIdsForInteractions(InteractionStrategy.Beliefs).ToList(); var askInternally = murphy.AskInternally(Schedule.Step, blocker.InitialStep); if (teammates.Any() && askInternally) { var attachments = new MessageAttachments(); attachments.Add(blocker); attachments.Add(task); attachments.KnowledgeId = knowledgeId; attachments.KnowledgeBit = knowledgeBit; var messageType = murphy.AskOnWhichChannel(Cognitive.InteractionCharacteristics.PreferredCommunicationMediums); ImpactOfTheCommunicationMediumOnTimeSpent(messageType, true, task.KeyActivity); SendToMany(teammates, MessageAction.Ask, SymuYellowPages.Help, attachments, messageType); } else { if (murphy.ShouldGuess(blocker.NumberOfTries)) { // Blocker must be unblocked in a way or another RecoverBlockerIncompleteBeliefByGuessing(task, blocker); } else { TryRecoverBlockerIncompleteBeliefExternally(task, blocker); } } }
public void AddSubscribeTest() { var attachments = new MessageAttachments(); attachments.Add((byte)1); attachments.Add((byte)2); var message = new Message(_agent.AgentId, _agent.AgentId, MessageAction.Add, SymuYellowPages.Subscribe, attachments); _agent.AddSubscribe(message); Assert.AreEqual(1, _agent.MessageProcessor.Subscriptions.SubscribersCount(1)); Assert.AreEqual(1, _agent.MessageProcessor.Subscriptions.SubscribersCount(2)); Assert.AreEqual(0, _agent.MessageProcessor.Subscriptions.SubscribersCount(0)); }
public override void TryRecoverBlockerIncompleteKnowledgeExternally(SymuTask task, Blocker blocker, IAgentId knowledgeId, byte knowledgeBit) { if (blocker == null) { throw new ArgumentNullException(nameof(blocker)); } var attachments = new MessageAttachments(); attachments.Add(blocker); attachments.Add(task); attachments.KnowledgeId = knowledgeId; attachments.KnowledgeBit = knowledgeBit; Send(Internet.AgentId, MessageAction.Ask, SymuYellowPages.Help, attachments, CommunicationMediums.ViaAPlatform); }
public void AddAttachments(params MessageAttachment[] messageAttachments) { foreach (var attachment in messageAttachments) { if (MessageAttachments.All(x => x.ExternalId != attachment.ExternalId)) { MessageAttachments.Add(attachment); } } }
/// <summary> /// Try recover blocker for an incompleteInformation blocker /// Missing information come from creator => ask PO, Users, .... /// </summary> /// <param name="task"></param> /// <param name="blocker"></param> public void TryRecoverBlockerIncompleteInformation(SymuTask task, Blocker blocker) { if (task is null) { throw new ArgumentNullException(nameof(task)); } if (blocker is null) { throw new ArgumentNullException(nameof(blocker)); } var murphy = Environment.MainOrganization.Murphies.IncompleteInformation; var askInternally = Environment.MainOrganization.Murphies.IncompleteKnowledge.AskInternally(Schedule.Step, blocker.InitialStep); //TODO send to creator only if he has the right to communicate to cf. Network if (askInternally && task.HasCreator) { var messageType = murphy.AskOnWhichChannel(Cognitive.InteractionCharacteristics .PreferredCommunicationMediums); var parameter = new MessageAttachments(); parameter.Add(blocker); parameter.Add(task); Send(task.Creator, MessageAction.Ask, SymuYellowPages.Help, parameter, messageType); } else { if (murphy.ShouldGuess(blocker.NumberOfTries)) { // Blocker must be unblocked in a way or another RecoverBlockerIncompleteByGuessing(task, blocker, Environment.MainOrganization.Murphies.IncompleteInformation, BlockerResolution.Guessing); } else { TryRecoverBlockerIncompleteInformationExternally(task, blocker); } } }