public void SetOriginalActionModel(SecretAnnouncementInfo info)
 {
     _originalSecretAnnouncementInfo = info;
     foreach (string name in info.Audience.Keys)
     {
         Aaud_ARL.AddItemToList(name);
     }
     Announcement_FC.SetFormulaExpression(info.Announcement.Expression);
 }
 public void CopyFrom(SecretAnnouncementInfo secretAnnouncementInfo)
 {
     Announcement = secretAnnouncementInfo.Announcement;
     Audience = secretAnnouncementInfo.Audience;
 }
Esempio n. 3
0
        public static EpistemicModel FromText(ref string[] lines)
        {
            EpistemicModel model = new EpistemicModel();
            int lineNum = 0;
            if (lines[lineNum++] == "START_AGENTS")
            {
                int agentCount = int.Parse(lines[lineNum++]);
                int i;
                for (i = lineNum; i < agentCount+lineNum; i++)
                {
                    model.AddAgent(lines[i]);
                }
                lineNum = i;
                if (lines[lineNum++] != "END_AGENTS")
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
            if (lines[lineNum++] == "START_ATOMICS")
            {
                int atomicCount = int.Parse(lines[lineNum++]);
                int i;
                for (i = lineNum; i < atomicCount + lineNum; i++)
                {
                    model.AddAtomic(lines[i]);
                }
                lineNum = i;
                if (lines[lineNum++] != "END_ATOMICS")
                {
                    return null;
                }
            }
            else
            {
                return null;
            }

            if (lines[lineNum++] == "START_ANN_INFO")
            {
                int infoCount = int.Parse(lines[lineNum++]);
                for (int i = 0; i < infoCount ; i++)
                {
                      if (lines[lineNum] == "Secret")
                      {
                          lineNum++;
                          SecretAnnouncementInfo info = new SecretAnnouncementInfo();
                          string infoName = lines[lineNum++];
                          info.Announcement.Expression = lines[lineNum++];
                          int audienceCount = int.Parse(lines[lineNum++]);
                          for (int j = 0; j < audienceCount; j++)
                          {
                              info.AddNewAudience(lines[lineNum++]);
                          }
                          model._secretAnnouncementInfos.Add(infoName , info);
                      }
                      else if(lines[lineNum] == "Public")
                      {
                          lineNum++;
                          PublicAnnouncementInfo info = new PublicAnnouncementInfo();
                          string infoName = lines[lineNum++];
                          info.Announcement.Expression = lines[lineNum++];
                          int audienceCount = int.Parse(lines[lineNum++]);
                          for (int j = 0; j < audienceCount; j++)
                          {
                              info.AddNewAudience(lines[lineNum++]);
                          }
                          model._publicAnnouncementInfos.Add(infoName, info);
                      }
                }
                if (lines[lineNum++] != "END_ANN_INFO")
                {
                    return null;
                }
            }
            else
            {
                return null;
            }

            List<string> newData = lines.ToList();
            newData.RemoveRange(0, lineNum);
            lines = newData.ToArray();

            return model;
        }
Esempio n. 4
0
 public void CopyFrom(SecretAnnouncementInfo secretAnnouncementInfo)
 {
     Announcement = secretAnnouncementInfo.Announcement;
     Audience     = secretAnnouncementInfo.Audience;
 }
Esempio n. 5
0
 public SecretAnnouncementInfo CreateSecretAnnouncementInfo(string name)
 {
     if (IsNameConsistentForAnnounceInfo(name))
     {
         SecretAnnouncementInfo newSInfo = new SecretAnnouncementInfo();
         _secretAnnouncementInfos.Add(name, newSInfo);
         return newSInfo;
     }
     return null;
 }