Exemple #1
0
        private static void AddBehavior([NotNull] List <BehaviorInfo> behaviorInfos,
                                        [NotNull] Behavior behavior, int level)
        {
            var behaviorInfo = new BehaviorInfo {
                behavior = behavior, level = level
            };

            behaviorInfos.Add(behaviorInfo);

            Type behaviorType = behavior.GetType();

            if (behaviorType.IsSubclassOf(typeof(Composite)))
            {
                var children = (Behavior[])s_compositeChildrenField.GetValue(behavior);

                for (int i = 0, count = children.Length; i < count; ++i)
                {
                    AddBehavior(behaviorInfos, children[i], level + 1);
                }
            }
            else if (behaviorType.IsSubclassOf(typeof(Decorator)))
            {
                var child = (Behavior)s_decoratorChildField.GetValue(behavior);
                AddBehavior(behaviorInfos, child, level + 1);
            }
        }
Exemple #2
0
 void m_viewModel_BehaviorEventReceived(BehaviorInfo obj)
 {
     if (InvokeRequired)
     {
         this.Invoke(new Action <BehaviorInfo>(m_viewModel_BehaviorEventReceived), obj);
     }
     else
     {
         if (behaviorEventList.Count >= 50)
         {
             var item = behaviorEventList[behaviorEventList.Count - 1];
             item.Dispose();
             behaviorEventList.RemoveAt(behaviorEventList.Count - 1);
             advTreeBehaviourEvent.Nodes.RemoveAt(behaviorEventList.Count - 1);
         }
         var property = new BehaviorProperty(obj);
         behaviorEventList.Insert(0, property);
         //advTreeTrafficEvent.RefreshItems();
         DevComponents.AdvTree.Node n = new DevComponents.AdvTree.Node(property.EventType);
         n.Cells.Add(new DevComponents.AdvTree.Cell(property.StartTime));
         n.Cells.Add(new DevComponents.AdvTree.Cell(property.EndTime));
         n.Cells.Add(new DevComponents.AdvTree.Cell(property.ObjectId));
         n.Cells.Add(new DevComponents.AdvTree.Cell(property.ObjType));
         n.Cells.Add(new DevComponents.AdvTree.Cell(property.CameraCode));
         n.Tag = property;
         advTreeBehaviourEvent.Nodes.Insert(0, n);
     }
 }
        /// <summary>
        ///     Calculates the distance between two behaviors.
        /// </summary>
        /// <param name="behavior1">The first behavior in the distance calculation.</param>
        /// <param name="behavior2">The second behavior in the distance calculation.</param>
        /// <returns>A measure of the behavioral distance.</returns>
        public static double CalculateDistance(BehaviorInfo behavior1, BehaviorInfo behavior2)
        {
            if (behavior1.Behaviors.Length != behavior2.Behaviors.Length)
            {
                throw new SharpNeatException(
                    "Cannot compare behavior characterizations because behavior length differs.");
            }

            // Calculate the difference between the behavior double-precision arrays
            return CalculateDistance(behavior1.Behaviors, behavior2.Behaviors);
        }
Exemple #4
0
    /// <summary>
    /// 인자로 주어진 행동을 검증한 후 수행합니다.
    /// </summary>
    /// <param name="b">수행할 행동</param>
    public static void Perform(Behavior b)
    {
        if (!Verificate(b))
        {
            Debug.LogWarning("Bad behavior.");
            return;
        }
        BehaviorInfo bi = Find(b);

        bi.Perform(b);
    }
        void m_dataReceiveService_OnBehaviorReceived(BehaviorInfo obj)
        {
            if (obj == null)
            {
                return;
            }

            if (BehaviorEventReceived != null && (BehaviourFilterType == BehaviorType.None || BehaviourFilterType == obj.EventType))
            {
                BehaviorEventReceived(obj);
            }
        }
Exemple #6
0
    /// <summary>
    /// 행동 수행 단계에서 인자로 주어진 행동이 행동 데이터베이스에 있는 행동 정보에 존재하는, 유효한 행동인지 검증하는 함수입니다.
    /// </summary>
    /// <param name="b">검증할 행동</param>
    /// <returns>유효한 행동이면 true, 아니면 false를 반환합니다.</returns>
    public static bool Verificate(Behavior b)
    {
        // 인자로 주어진 행동이 올바른지 확인합니다.
        if (b == null || b.GetBehavior() == null)
        {
            return(false);
        }
        // 행동과 이름이 같은 행동 정보를 찾습니다.
        BehaviorInfo bi = Find(b);

        // 행동 정보가 존재하는지 확인합니다.
        if (bi == null)
        {
            return(false);
        }
        // 행동 정보에서 요구하는 대상 수와 행동의 대상 수가 일치하는지 확인합니다.
        if (bi.GetTargetNumber() != b.GetObjectPlayers().Count)
        {
            return(false);
        }
        // 자신을 대상으로 지정할 수 없는 행동의 경우, 행동에서 자신이 대상으로 지정되었는지 확인합니다.
        if (!bi.GetTargetMyself() && b.GetObjectPlayers().IndexOf(b.GetSubjectPlayer()) != -1)
        {
            return(false);
        }
        // 행동이 통찰인 경우, 대상의 목표일 것으로 추정한 플레이어의 수가 두 명인지 확인합니다.
        if (bi.GetBehaviorName() == "basicInsight" && b.GetThirdPartyPlayers().Count != 2)
        {
            return(false);
        }
        // 지정할 수 없는 대상을 지정했는지, 같은 대상을 여러 번 지정했는지 확인합니다.
        List <PlayerController> pc = new List <PlayerController>();

        foreach (PlayerController p in b.GetObjectPlayers())
        {
            if (!p.GetTargetable() || p.GetDead())
            {
                return(false);
            }
            if (pc.IndexOf(p) != -1)
            {
                return(false);
            }
            pc.Add(p);
        }
        return(true);
    }
Exemple #7
0
 public void Add(InputBehaviorSet behaviors, string new_group = "")
 {
     if (behaviors == null)
     {
         return;
     }
     foreach (BehaviorInfo b in behaviors.Behaviors)
     {
         BehaviorInfo bcopy = b;
         if (new_group != "")
         {
             bcopy.group = new_group;
         }
         Behaviors.Add(bcopy);
     }
     behaviors_modified();
 }
        private void DoReceiveNOTE_UPLOAD_BEHAVIOR_EVENT(XmlNode itemData)
        {
            BehaviorInfo info = new BehaviorInfo();

            System.Xml.XmlNode itemCameraCode = itemData.SelectSingleNode("CameraCode");
            info.CameraID = itemCameraCode.InnerXml;
            System.Xml.XmlNode itemObjId = itemData.SelectSingleNode("ObjId");
            info.ObjectId = Convert.ToUInt32(itemObjId.InnerXml);
            System.Xml.XmlNode itemEventType = itemData.SelectSingleNode("EventType");
            info.EventType = (BehaviorType)Convert.ToUInt32(itemEventType.InnerXml);

            System.Xml.XmlNode itemStartTimeSec = itemData.SelectSingleNode("StartTimeSec");
            uint StartTimeSec = Convert.ToUInt32(itemStartTimeSec.InnerXml);

            System.Xml.XmlNode itemStartTimeMilliSec = itemData.SelectSingleNode("StartTimeMilliSec");
            uint StartTimeMilliSec = Convert.ToUInt32(itemStartTimeMilliSec.InnerXml);

            info.StartTime = DataModel.Common.ZEROTIME.AddSeconds(StartTimeSec).AddMilliseconds(StartTimeMilliSec);
            System.Xml.XmlNode itemEndTimeSec = itemData.SelectSingleNode("EndTimeSec");
            uint EndTimeSec = Convert.ToUInt32(itemEndTimeSec.InnerXml);

            System.Xml.XmlNode itemEndTimeMilliSec = itemData.SelectSingleNode("EndTimeMilliSec");
            uint EndTimeMilliSec = Convert.ToUInt32(itemEndTimeMilliSec.InnerXml);

            info.EndTime = DataModel.Common.ZEROTIME.AddSeconds(EndTimeSec).AddMilliseconds(EndTimeMilliSec);


            int EventObjCoordX = Convert.ToInt32(itemData.SelectSingleNode("EventObjCoordX").InnerXml);
            int EventObjCoordY = Convert.ToInt32(itemData.SelectSingleNode("EventObjCoordY").InnerXml);
            int EventObjWidth  = Convert.ToInt32(itemData.SelectSingleNode("EventObjWidth").InnerXml);
            int EventObjHeight = Convert.ToInt32(itemData.SelectSingleNode("EventObjHeight").InnerXml);

            info.EventObjRect = new System.Drawing.Rectangle(EventObjCoordX, EventObjCoordY, EventObjWidth, EventObjHeight);
            System.Xml.XmlNode itemObjType = itemData.SelectSingleNode("ObjType");
            info.ObjType = ( E_SEARCH_RESULT_OBJECT_TYPE)Convert.ToUInt32(itemObjType.InnerXml);
            System.Xml.XmlNode itemObjNum = itemData.SelectSingleNode("ObjNum");
            info.ObjNum = Convert.ToUInt32(itemObjNum.InnerXml);

            string ImageBuffer = itemData.SelectSingleNode("ImageBuffer").InnerXml;

            info.Image = new System.IO.MemoryStream(Convert.FromBase64String(ImageBuffer));
            if (OnBehaviorReceived != null)
            {
                OnBehaviorReceived(info);
            }
        }
        void realtimereceive_OnReceiveNOTE_UPLOAD_BEHAVIOR_EVENT(Interop.Protocol tcp, Interop.NOTE_UPLOAD_BEHAVIOR_EVENT obj)
        {
            string msg = string.Format("ObjectId:{1}," + Environment.NewLine
                                       + "EventType:{2}," + Environment.NewLine
                                       + "StartTime:{3}," + Environment.NewLine
                                       + "EndTime:{4}," + Environment.NewLine
                                       + "EventObjRect:{5}," + Environment.NewLine
                                       + "ObjType:{6}," + Environment.NewLine
                                       + "ObjNum:{7}," + Environment.NewLine
                                       //+ "Image:{10}," + Environment.NewLine
                                       //+ "Reserved:{11}," + Environment.NewLine
                                       , obj.CameraCode
                                       , obj.ObjectId
                                       , obj.EventType
                                       , obj.StartTime
                                       , obj.EndTime
                                       , obj.EventObjRect
                                       , obj.ObjType
                                       , obj.ObjNum
                                       //, obj.Image
                                       //, obj.Reserved
                                       );

            MyLog4Net.Container.Instance.Log.Debug(msg);

            BehaviorInfo info = new BehaviorInfo()
            {
                CameraID      = obj.CameraCode,
                EventObjRect  = obj.EventObjRect,
                EventType     = (BehaviorType)obj.EventType,
                Image         = obj.Image,
                ObjectId      = obj.ObjectId,
                ObjNum        = obj.ObjNum,
                ObjType       = (E_SEARCH_RESULT_OBJECT_TYPE)obj.ObjType,
                EndTime       = obj.EndTime,
                StartTime     = obj.StartTime,
                EventVideoUrl = obj.EventVideoUrl,
            };

            if (OnBehaviorReceived != null)
            {
                OnBehaviorReceived(info);
            }
        }
Exemple #10
0
    private void DisplayBehaviorForTrigger(TriggerInfo trigger)
    {
        currentBehavior = currentBot.Behaviors.FirstOrDefault(behaviorInfo => behaviorInfo.TriggerId == trigger.ID);

        if (currentBehavior != null)
        {
            var behaviorBlocks = currentBehavior.Blocks.Select(block => block != null ? Block.FromInfo(block) : null);

            foreach (var block in behaviorBlocks.Where(block => block != null))
            {
                AddBlock(block);
            }

            currentTriggerBlock = GetBlockById(currentBehavior.EntryBlockId) as TriggerBlock;
            if (currentTriggerBlock != null)
            {
                currentTriggerBlock.gameObject.transform.SetPositionAndRotation(new Vector2(-6.3f, 4f), Quaternion.Euler(0, 0, 0));
                StartCoroutine(LetStartThen(currentTriggerBlock.PositionConnections));
            }
        }
    }
Exemple #11
0
    // 여기에 기본 행동과 스킬을 추가할 수 있습니다.
    private void Awake()
    {
        bm = gameObject.GetComponent <BattleManager>();
        BehaviorInfo bi;

        #region 기본 행동 목록
        // 단일 대상 일반 공격
        bi = new BehaviorInfo("basicAttack", "단일 공격", 0, 1, false, 0, "단일 대상에게 자신의 단일 일반 공격력만큼의 피해를 줍니다.")
        {
            Perform = BasicAttack
        };
        behaviorInfo.Add(bi);

        // 두 명 대상 일반 공격(프로토타입 버전에 존재, 최종 버전에서는 다공 특화 캐릭터가 사용)
        bi = new BehaviorInfo("basicDoubleAttack", "다수 공격", 0, 2, false, 0, "두 명의 대상에게 각각 자신의 다수 일반 공격력만큼의 피해를 줍니다.")
        {
            Perform = BasicDoubleAttack
        };
        behaviorInfo.Add(bi);

        // 단일 대상 일반 회복
        bi = new BehaviorInfo("basicHeal", "회복", 1, 1, true, 0, "단일 대상의 체력을 자신의 회복량만큼 회복시킵니다. 자신에게 사용할 수 있습니다.")
        {
            Perform = BasicHeal
        };
        behaviorInfo.Add(bi);

        // 두 명 대상 일반 회복(최종 버전에서 회복 특화 캐릭터가 사용)
        bi = new BehaviorInfo("basicDoubleHeal", "다수 회복", 1, 2, true, 0, "두 명 대상의 체력을 각각 자신의 회복량만큼 회복시킵니다. 자신에게 사용할 수 있습니다.")
        {
            Perform = BasicDoubleHeal
        };
        behaviorInfo.Add(bi);

        // 일반 통찰
        bi = new BehaviorInfo("basicInsight", "통찰", 0, 1, false, 0, "단일 대상을 선택하고, 그 대상이 잡아야 하는 목표 두 명이 누구인지 추정합니다. 목표 두 명을 모두 맞히면 이번 턴에 자신이 받는 모든 피해를 무시하고, 처음에 선택한 대상이 이번 턴에 수행할 행동을 무효화합니다. 목표를 정확히 맞히지 못하면 아무 행동도 하지 않습니다. 통찰에 성공한 대상에게는 다시 사용할 수 없습니다.")
        {
            Perform = BasicInsight
        };
        behaviorInfo.Add(bi);
        #endregion

        #region 스킬 목록

        /* // 형식:
         *
         * bi = new BehaviorInfo("스킬 이름", "설명에 표시되는 스킬 이름", 마나 소모량, 대상 수, 대상에 자신 포함 여부(true/false), 대상 옵션, "스킬 상세 설명", 스킬 종류)
         * {
         *     perform = 스킬 구현 함수 이름
         * };
         * behaviorInfo.Add(bi);
         *
         * // 대상 수       0: 지정하지 않음, 1~5: 1~5명 지정
         * // 대상 옵션     0: 옵션 없음, 1~4: 무작위 1~4명 대상, 5: 모든 생존자 대상, 6: 자신 대상(대상에 자신 포함 여부가 true여야 함)
         * // 대상 옵션은 대상 수가 0일 때 0이 아닌 값으로 설정하고, 대상 수가 0이 아닐 때 0으로 설정하면 된다.
         * // 대상에 자신 포함 여부가 false이면 모든 옵션에서 자신 제외
         * // 스킬 종류     1: 캐릭터 고유 스킬, 2: 공용 스킬
         */

        bi = new BehaviorInfo("singlePowerAttack1", "단일 대상 강한 공격", 3, 1, false, 0, "단일 대상에게 7의 피해를 줍니다.", 2)
        {
            Perform = SinglePowerAttack1
        };
        behaviorInfo.Add(bi);

        bi = new BehaviorInfo("singlePowerAttack2", "단일 대상 강한 공격", 6, 1, false, 0, "단일 대상에게 12의 피해를 줍니다.", 2)
        {
            Perform = SinglePowerAttack2
        };
        behaviorInfo.Add(bi);

        bi = new BehaviorInfo("singlePowerAttack3", "단일 대상 강한 공격", 10, 1, false, 0, "단일 대상에게 18의 피해를 줍니다.", 2)
        {
            Perform = SinglePowerAttack3
        };
        behaviorInfo.Add(bi);

        // TODO 새 스킬을 추가할 때는 위와 같은 형식으로 여기에 추가하고, 아래에 스킬이 수행하는 스킬 구현 함수를 만들어주세요.

        #endregion
    }
    public bool ExecuteCyclic(IBehaviorExecutionContext context, TriggerResult trigger)
    {
        if (!CyclicActionsComplete && InitActionsComplete)
        {
            // CYCLIC_BLOCK
              var var_ebbaffde_15bc_9860_a6bf_509b6d6a59a6 = new List<Task>();
  var var_c9a06f4b_8778_dcec_bbc4_38221887afe2 = new Action( () =>
  {
    var var_58933fdd_5ef9_050e_8b8c_4bbd0c74246c= new BehaviorInfo{BehaviorName = "Dance",RobotName = "Hiro"};

    BehaviorModuleHelper.Execute(context, var_58933fdd_5ef9_050e_8b8c_4bbd0c74246c);

  });
  var var_b0843968_09f4_bf69_b462_30f80c3d6d92 = new Action( () =>
  {
    var var_73dea3ca_51c6_79be_8608_d6d0d2e3743b= new BehaviorInfo{BehaviorName = "Dance",RobotName = "Taro"};

    BehaviorModuleHelper.Execute(context, var_73dea3ca_51c6_79be_8608_d6d0d2e3743b);

  });
  var_ebbaffde_15bc_9860_a6bf_509b6d6a59a6.Add(Task.Run(var_c9a06f4b_8778_dcec_bbc4_38221887afe2));
  var_ebbaffde_15bc_9860_a6bf_509b6d6a59a6.Add(Task.Run(var_b0843968_09f4_bf69_b462_30f80c3d6d92));
  Task.WaitAll(var_ebbaffde_15bc_9860_a6bf_509b6d6a59a6.ToArray());
  System.Console.WriteLine("Parallel action execution complete");

            if (ExecutionLifetime == BehaviorExecutionLifetime.once)
            {
                CyclicActionsComplete = true;
            }
            else if (ExecutionLifetime == BehaviorExecutionLifetime.until)
            {
                var complete = ExecutionUntil(context);
                CyclicActionsComplete = !complete;
            }
        }
        return CyclicActionsComplete;
    }
Exemple #13
0
    public bool ExecuteCyclic(IBehaviorExecutionContext context, TriggerResult trigger)
    {
        if (!CyclicActionsComplete && InitActionsComplete)
        {
            // CYCLIC_BLOCK
              if (count == 1) {
    var var_4cb4bb22_b20c_ffff_82d4_9a629b6d9712= string.Format("You have completed the exercise {0}  time!",count);
    var var_aab31148_d989_dbc4_99a9_607c437ff1f9= new BehaviorInfo
    {
    BehaviorName = "Say Expressively",
    RobotName = "Hiro",Parameters = new Dictionary<string, object>
    {
    {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions(var_4cb4bb22_b20c_ffff_82d4_9a629b6d9712, true, "string")},
    }
    };

    BehaviorModuleHelper.Execute(context, var_aab31148_d989_dbc4_99a9_607c437ff1f9);
  } else {
    var var_474e66e3_dfef_9670_b4a0_9dca1102d7ba= string.Format("You have completed the exercise {0}  times!",count);
    var var_64f27bb6_60e3_0d16_b68b_52c3ee3e11ed= new BehaviorInfo
    {
    BehaviorName = "Say Expressively",
    RobotName = "Hiro",Parameters = new Dictionary<string, object>
    {
    {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions(var_474e66e3_dfef_9670_b4a0_9dca1102d7ba, true, "string")},
    }
    };

    BehaviorModuleHelper.Execute(context, var_64f27bb6_60e3_0d16_b68b_52c3ee3e11ed);
  }



            if (ExecutionLifetime == BehaviorExecutionLifetime.once)
            {
                CyclicActionsComplete = true;
            }
            else if (ExecutionLifetime == BehaviorExecutionLifetime.until)
            {
                var complete = ExecutionUntil(context);
                CyclicActionsComplete = !complete;
            }
        }
        return CyclicActionsComplete;
    }
Exemple #14
0
 public BehaviorExecutor(BotController bot, BehaviorInfo behavior)
 {
     this.bot      = bot;
     this.behavior = behavior;
 }
Exemple #15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            btnSave.Enabled = false;
            bool          chkPass      = true;
            List <string> errorMsgList = new List <string>();
            List <string> logStrList   = new List <string>();

            // 檢查資料
            foreach (DataGridViewRow drv in dgBehavior.Rows)
            {
                // 檢查 good,detention 不能同時 true
                bool cG = false, cD = false;
                bool.TryParse(drv.Cells[colGood.Index].Value + "", out cG);
                bool.TryParse(drv.Cells[colDetention.Index].Value + "", out cD);
                if (cG == true && cD == true)
                {
                    chkPass = false;
                    errorMsgList.Add("Good 與 Detention 不能同時勾選。");
                    break;
                }
            }

            if (chkPass)
            {
                try
                {
                    List <string> updateCmdList = new List <string>();
                    // 更新 General Comment
                    string gComment       = txtGeneralComment.Text.Replace("'", "''");
                    string updateGComment = "UPDATE $esl.weekly_report SET general_comment = '" + gComment + "' WHERE uid = " + SelectedWeeklyReportUID + ";";
                    if (!string.IsNullOrWhiteSpace(SelectedWeeklyReportUID))
                    {
                        if (oldGeneralComment != txtGeneralComment.Text)
                        {
                            logStrList.Add("Genner Comment 由「" + oldGeneralComment + "」改成「" + txtGeneralComment.Text + "」。");
                        }

                        updateCmdList.Add(updateGComment);
                        foreach (WeeklyReportLogRecord rec in WeeklyReportLogRecordList)
                        {
                            if (rec.UID == SelectedWeeklyReportUID)
                            {
                                rec.GeneralComment = txtGeneralComment.Text;
                            }
                        }
                    }


                    // 更新 PersionComment
                    string pComment       = txtTeacherComment.Text.Replace("'", "''");
                    string updatePComment = "UPDATE $esl.weekly_data SET personal_comment = '" + pComment + "' WHERE uid = " + SelectedWeeklyDataUID + ";";

                    if (!string.IsNullOrWhiteSpace(SelectedWeeklyDataUID))
                    {
                        updateCmdList.Add(updatePComment);

                        logStrList.Add("Teacher Comment 由「" + oldTeacherComment + "」改成「" + txtTeacherComment.Text + "」。");

                        foreach (WeeklyDataInfo wdi in WeeklyDataInfoList)
                        {
                            if (wdi.UID == SelectedWeeklyDataUID)
                            {
                                wdi.PersonalComment = txtTeacherComment.Text;
                            }
                        }
                    }

                    // 更新 Behavior
                    BehaviorInfoList.Clear();
                    List <string> tmpList = new List <string>();
                    foreach (DataGridViewRow drv in dgBehavior.Rows)
                    {
                        tmpList.Clear();
                        BehaviorInfo bi = drv.Tag as BehaviorInfo;
                        if (bi != null)
                        {
                            // 處理 log
                            if (bi.Comment != drv.Cells[colBComment.Index].Value + "")
                            {
                                tmpList.Add("Behavior Comment 由「" + bi.Comment + "」改成「" + drv.Cells[colBComment.Index].Value + "" + "」。");
                            }


                            bi.Comment = drv.Cells[colBComment.Index].Value + "";

                            bool bG = false, bD = false;
                            bool.TryParse(drv.Cells[colGood.Index].Value + "", out bG);
                            bool.TryParse(drv.Cells[colDetention.Index].Value + "", out bD);
                            if (bi.isGood != bG)
                            {
                                tmpList.Add("Behavior Good 由「" + bi.isGood + "」改成「" + bG + "」。");
                            }

                            bi.isGood = bG;

                            if (bi.isDetention != bD)
                            {
                                tmpList.Add("Behavior Detention 由「" + bi.isDetention + "」改成「" + bD + "」。");
                            }

                            bi.isDetention = bD;

                            if (tmpList.Count > 0)
                            {
                                string str = "Behavior 日期:" + bi.CreateDate;
                                logStrList.Add(str);
                                foreach (string s in tmpList)
                                {
                                    logStrList.Add(s);
                                }
                            }

                            BehaviorInfoList.Add(bi);
                        }
                    }


                    foreach (BehaviorInfo bi in BehaviorInfoList)
                    {
                        string comm = bi.Comment.Replace("'", "''");
                        string good = "false";
                        string det  = "false";
                        if (bi.isGood)
                        {
                            good = "true";
                        }

                        if (bi.isDetention)
                        {
                            det = "true";
                        }

                        string strSQL = "UPDATE $esl.behavior_data SET comment='" + comm + "',is_good_behavior=" + good + ",detention=" + det + " WHERE UID = " + bi.UID + "";

                        if (!string.IsNullOrWhiteSpace(bi.UID))
                        {
                            updateCmdList.Add(strSQL);
                        }
                    }

                    // 更新資料
                    UpdateHelper uh = new UpdateHelper();
                    uh.Execute(updateCmdList);

                    if (logStrList.Count > 0)
                    {
                        //  取得目前所選學生
                        if (dgStudentData.SelectedRows.Count > 0)
                        {
                            WeeklyDataInfo wdi = dgStudentData.SelectedRows[0].Tag as WeeklyDataInfo;
                            if (wdi != null)
                            {
                                string sinfo = "班級:" + wdi.ClassName + " ,座號:" + wdi.SeatNo + "  ,姓名:" + wdi.StudentName + " ,\n";
                                FISCA.LogAgent.ApplicationLog.Log("ESL 檢視週報表", "修改資料", "student", wdi.StudentID, sinfo + string.Join("\n", logStrList.ToArray()));
                            }
                        }
                    }

                    MessageBox.Show("儲存完成");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("儲存失敗," + ex.Message);
                    btnSave.Enabled = true;
                }
            }
            else
            {
                if (errorMsgList.Count > 0)
                {
                    MessageBox.Show(string.Join(",", errorMsgList.ToArray()));
                }
            }



            btnSave.Enabled = true;
        }
Exemple #16
0
        private void LoadBehaviorData(string StudentID, string CourseID, string TeacherID)
        {
            try
            {
                if (string.IsNullOrEmpty(SelectdBeginDate))
                {
                    SelectdBeginDate = DateTime.Now.ToString("yyyy-MM-dd");
                }
                if (string.IsNullOrEmpty(SelectdEndDate))
                {
                    SelectdEndDate = DateTime.Now.ToString("yyyy-MM-dd");
                }

                SelectdBeginDate = DateTime.Parse(SelectdBeginDate).ToString("yyyy-MM-dd");
                SelectdEndDate   = DateTime.Parse(SelectdEndDate).ToString("yyyy-MM-dd");

                string sql = "SELECT " +
                             "uid" +
                             ",create_date" +
                             ",comment" +
                             ",is_good_behavior" +
                             ",detention " +
                             " FROM $esl.behavior_data" +
                             " WHERE ref_course_id = " + CourseID + "" +
                             " AND ref_student_id = " + StudentID + "" +
                             " AND ref_teacher_id = " + TeacherID + "" +
                             " AND create_date >= '" + SelectdBeginDate + "'" +
                             " AND create_date <= '" + SelectdEndDate + "'" +
                             " ORDER BY create_date";

                BehaviorInfoList.Clear();
                dgBehavior.Rows.Clear();

                QueryHelper qh = new QueryHelper();
                DataTable   dt = qh.Select(sql);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        BehaviorInfo bi = new BehaviorInfo();
                        bi.Comment     = "" + dr["comment"];
                        bi.CourseID    = CourseID;
                        bi.UID         = "" + dr["uid"];
                        bi.isGood      = false;
                        bi.isDetention = false;
                        bi.CreateDate  = "" + dr["create_date"] != "" ? DateTime.Parse("" + dr["create_date"]).ToString("yyyy/MM/dd") : "";
                        if ("" + dr["is_good_behavior"] == "true")
                        {
                            bi.isGood = true;
                        }
                        if ("" + dr["detention"] == "true")
                        {
                            bi.isDetention = true;
                        }
                        bi.TeacherID = TeacherID;
                        bi.StudentID = StudentID;
                        BehaviorInfoList.Add(bi);
                    }
                }

                foreach (BehaviorInfo bi in BehaviorInfoList)
                {
                    int rowIdx = dgBehavior.Rows.Add();
                    dgBehavior.Rows[rowIdx].Tag = bi;
                    dgBehavior.Rows[rowIdx].Cells[colBCreateDate.Index].Value = bi.CreateDate;
                    dgBehavior.Rows[rowIdx].Cells[colBComment.Index].Value    = bi.Comment;
                    dgBehavior.Rows[rowIdx].Cells[colGood.Index].Value        = false;
                    dgBehavior.Rows[rowIdx].Cells[colDetention.Index].Value   = false;

                    if (bi.isGood)
                    {
                        dgBehavior.Rows[rowIdx].Cells[colGood.Index].Value = true;
                    }
                    ;

                    if (bi.isDetention)
                    {
                        dgBehavior.Rows[rowIdx].Cells[colDetention.Index].Value = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("載入 Behavior 資料失敗," + ex.Message);
            }
        }
    public void Execute(IBehaviorExecutionContext context)
    {
        // STARTUP_BLOCK
          var var_862fef01_d556_1537_a12a_be89ce762dfd = new List<Task>();
  var var_aca01bc5_b6ef_6c67_aa3c_f065ee993a92 = new Action( () =>
  {
    var var_3641a8a3_6179_2204_b150_d7359fe9260c= new BehaviorInfo{BehaviorName = "Greet",RobotName = "Hiro"};

    BehaviorModuleHelper.Execute(context, var_3641a8a3_6179_2204_b150_d7359fe9260c);

  });
  var var_853bcb58_acf7_ceb1_ab72_ee040ea19571 = new Action( () =>
  {
    var var_5ab5d4fd_7fe4_ff71_bc15_6f483055047c= new BehaviorInfo{BehaviorName = "Greet",RobotName = "Taro"};

    BehaviorModuleHelper.Execute(context, var_5ab5d4fd_7fe4_ff71_bc15_6f483055047c);

  });
  var_862fef01_d556_1537_a12a_be89ce762dfd.Add(Task.Run(var_aca01bc5_b6ef_6c67_aa3c_f065ee993a92));
  var_862fef01_d556_1537_a12a_be89ce762dfd.Add(Task.Run(var_853bcb58_acf7_ceb1_ab72_ee040ea19571));
  Task.WaitAll(var_862fef01_d556_1537_a12a_be89ce762dfd.ToArray());
  System.Console.WriteLine("Parallel action execution complete");var var_bf59f011_690d_eb2a_9701_a0bdf52ee6bd= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("I am Hiro", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_bf59f011_690d_eb2a_9701_a0bdf52ee6bd);
  var var_c01098b4_a9e2_468c_8b91_f8829c4d6fa3= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Taro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("And I am Taro", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_c01098b4_a9e2_468c_8b91_f8829c4d6fa3);
  var var_567e0153_ac87_6f4d_9b5d_bf0c1d2ddb8a= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("We want to introduce Indriya system. Taro, you want to start?", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_567e0153_ac87_6f4d_9b5d_bf0c1d2ddb8a);
  var var_ec1499f8_bafe_1869_a3da_24666d86581a= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Taro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("Yes sure.", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_ec1499f8_bafe_1869_a3da_24666d86581a);
  var var_1c66ef30_587d_b0fa_8fc9_1078f8201e7f= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Taro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("Indriya helps to design interaction scenario based on human behaviors", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_1c66ef30_587d_b0fa_8fc9_1078f8201e7f);
  var var_f3e0ffd0_259b_cec5_b455_c81c99bb5039= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("That's right! You can design program to respond to a gesture", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_f3e0ffd0_259b_cec5_b455_c81c99bb5039);
  var var_4eb698cb_6291_358a_b56d_7fe3c5a78cdf= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Taro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("And also to a voice command from the user", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_4eb698cb_6291_358a_b56d_7fe3c5a78cdf);
  var var_f119e276_0793_879e_80de_6ad27c0761d2= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("You can also program two robots operate in parallel", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_f119e276_0793_879e_80de_6ad27c0761d2);
  var var_62cddfa4_0f75_ef4a_8abe_531b414a056e= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Taro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("And finally you can design behaviors with priority", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_62cddfa4_0f75_ef4a_8abe_531b414a056e);
  var var_08335cda_77da_928e_8cc1_c80cc61c2753= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("If you want both of us to dance together, wave your right or left hand", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_08335cda_77da_928e_8cc1_c80cc61c2753);
  var var_8d75c052_b97a_1a4b_adea_5ab215014397= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Taro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("If you want to interrupt at any time, say STOP loudly", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_8d75c052_b97a_1a4b_adea_5ab215014397);

    }
        // GetWorkBufferSize(nn::audio::detail::AudioRendererParameterInternal) -> u64
        public ResultCode GetAudioRendererWorkBufferSize(ServiceCtx context)
        {
            AudioRendererParameter parameters = GetAudioRendererParameter(context);

            if (AudioRendererCommon.CheckValidRevision(parameters))
            {
                BehaviorInfo behaviorInfo = new BehaviorInfo();

                behaviorInfo.SetUserLibRevision(parameters.Revision);

                long size;

                int totalMixCount = parameters.SubMixCount + 1;

                size = BitUtils.AlignUp(parameters.MixBufferCount * 4, AudioRendererConsts.BufferAlignment) +
                       parameters.SubMixCount * 0x400 +
                       totalMixCount * 0x940 +
                       parameters.VoiceCount * 0x3F0 +
                       BitUtils.AlignUp(totalMixCount * 8, 16) +
                       BitUtils.AlignUp(parameters.VoiceCount * 8, 16) +
                       BitUtils.AlignUp(((parameters.SinkCount + parameters.SubMixCount) * 0x3C0 + parameters.SampleCount * 4) *
                                        (parameters.MixBufferCount + 6), AudioRendererConsts.BufferAlignment) +
                       (parameters.SinkCount + parameters.SubMixCount) * 0x2C0 +
                       (parameters.EffectCount + parameters.VoiceCount * 4) * 0x30 +
                       0x50;

                if (behaviorInfo.IsSplitterSupported())
                {
                    size += BitUtils.AlignUp(NodeStates.GetWorkBufferSize(totalMixCount) + EdgeMatrix.GetWorkBufferSize(totalMixCount), 16);
                }

                size = parameters.SinkCount * 0x170 +
                       (parameters.SinkCount + parameters.SubMixCount) * 0x280 +
                       parameters.EffectCount * 0x4C0 +
                       ((size + SplitterContext.CalcWorkBufferSize(behaviorInfo, parameters) + 0x30 * parameters.EffectCount + (4 * parameters.VoiceCount) + 0x8F) & ~0x3FL) +
                       ((parameters.VoiceCount << 8) | 0x40);

                if (parameters.PerformanceManagerCount >= 1)
                {
                    size += (PerformanceManager.GetRequiredBufferSizeForPerformanceMetricsPerFrame(behaviorInfo, parameters) *
                             (parameters.PerformanceManagerCount + 1) + 0xFF) & ~0x3FL;
                }

                if (behaviorInfo.IsVariadicCommandBufferSizeSupported())
                {
                    size += CommandGenerator.CalculateCommandBufferSize(parameters) + 0x7E;
                }
                else
                {
                    size += 0x1807E;
                }

                size = BitUtils.AlignUp(size, 0x1000);

                context.ResponseData.Write(size);

                Logger.PrintDebug(LogClass.ServiceAudio, $"WorkBufferSize is 0x{size:x16}.");

                return(ResultCode.Success);
            }
            else
            {
                context.ResponseData.Write(0L);

                Logger.PrintWarning(LogClass.ServiceAudio, $"Library Revision REV{AudioRendererCommon.GetRevisionVersion(parameters.Revision)} is not supported!");

                return(ResultCode.UnsupportedRevision);
            }
        }
        private bool AddBehaviorBlock(BehaviorInfo behaviorInfo)
        {
            if (behaviorInfo.BehaviorType.IsGenericType)
            {
                var genericInterface = _type.GetInterface(behaviorInfo.BehaviorType.FullName);
                if (genericInterface != null)
                {
                    _blocks.Add(BuildBehaviorBlock(behaviorInfo, genericInterface.GetGenericArguments()));
                    return true;
                }
            }
            if (behaviorInfo.BehaviorType.IsAssignableFrom(_type))
            {
                _blocks.Add(BuildBehaviorBlock(behaviorInfo));
                return true;
            }

            return false;
        }
    public bool ExecuteCyclic(IBehaviorExecutionContext context, TriggerResult trigger)
    {
        if (!CyclicActionsComplete && InitActionsComplete)
        {
            // CYCLIC_BLOCK
              var var_e13f4a25_80e3_f7f2_a729_20d6aee5d4ba= new BehaviorInfo
  {
  BehaviorName = "Move To",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"translation", BehaviorModuleHelper.CreateBehaviorParameterOptions("0", false, "float")},
  {"rotation", BehaviorModuleHelper.CreateBehaviorParameterOptions("1", false, "float")},
  {"human", BehaviorModuleHelper.CreateBehaviorParameterOptions("1", false, "float")},
  {"dist", BehaviorModuleHelper.CreateBehaviorParameterOptions(1.50, false, "float")},
  {"x", BehaviorModuleHelper.CreateBehaviorParameterOptions(0.0, true, "float")},
  {"y", BehaviorModuleHelper.CreateBehaviorParameterOptions(0.0, true, "float")},
  {"theta", BehaviorModuleHelper.CreateBehaviorParameterOptions(0.0, true, "float")}
  }
  };

  if (context.RefreshApproachParameters(var_e13f4a25_80e3_f7f2_a729_20d6aee5d4ba, trigger)) {
  BehaviorModuleHelper.Execute(context, var_e13f4a25_80e3_f7f2_a729_20d6aee5d4ba);
  }
  var var_32c9179f_0614_11f8_bd1a_a0649c1d0667= new BehaviorInfo
  {
  BehaviorName = "Move To",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"translation", BehaviorModuleHelper.CreateBehaviorParameterOptions("1", false, "float")},
  {"rotation", BehaviorModuleHelper.CreateBehaviorParameterOptions("0", false, "float")},
  {"human", BehaviorModuleHelper.CreateBehaviorParameterOptions("1", false, "float")},
  {"dist", BehaviorModuleHelper.CreateBehaviorParameterOptions(1.50, false, "float")},
  {"x", BehaviorModuleHelper.CreateBehaviorParameterOptions(1.50, true, "float")},
  {"y", BehaviorModuleHelper.CreateBehaviorParameterOptions(0.0, true, "float")},
  {"theta", BehaviorModuleHelper.CreateBehaviorParameterOptions(0.0, true, "float")}
  }
  };

  if (context.RefreshApproachParameters(var_32c9179f_0614_11f8_bd1a_a0649c1d0667, trigger)) {
  BehaviorModuleHelper.Execute(context, var_32c9179f_0614_11f8_bd1a_a0649c1d0667);
  }
  var var_d2a5e02f_8c19_33cc_b240_3413036630d9= new BehaviorInfo{BehaviorName = "wish",RobotName = "Hiro"};

  BehaviorModuleHelper.Execute(context, var_d2a5e02f_8c19_33cc_b240_3413036630d9);
  var var_4330a2d9_5d64_7429_b18b_06083d44a70c= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("I am Nao! Welcome to Edo-Tokyo museum.", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_4330a2d9_5d64_7429_b18b_06083d44a70c);
  var var_dcbc2f6b_2259_fd93_8d04_797fa191107c= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("The Edo-Tokyo museum is a museum of the history of Tokyo during the Edo period", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_dcbc2f6b_2259_fd93_8d04_797fa191107c);
  var var_d6b52600_4ab0_f757_af15_6dd8587e5942= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("It was established in 1993", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_d6b52600_4ab0_f757_af15_6dd8587e5942);
  var var_22bdaaf8_a7e1_dca9_b981_f684fe9a8dc3= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("It has lifetime replica of the Nihonbashi, which was the bridge leading into Edo", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_22bdaaf8_a7e1_dca9_b981_f684fe9a8dc3);
  var var_6bb0f235_782b_5862_b6ac_80bd1345d345= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("It also has scaled down models of towns and building from the Edo, Meiji and Showa periods", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_6bb0f235_782b_5862_b6ac_80bd1345d345);
  var var_37cdbb14_89b3_3d26_a4a5_a1d9bc2ec861= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("The museum was designed by Kiyonori Kikutake", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_37cdbb14_89b3_3d26_a4a5_a1d9bc2ec861);
  var var_2c28ab2f_d8fa_9b1f_820e_bd3f802bf637= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("I hope you will enjoy your visit to Edo-Tokyo museum", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_2c28ab2f_d8fa_9b1f_820e_bd3f802bf637);
  var var_c76e0ccc_3577_ba62_9f4d_394436f0b6cc= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("Have a nice day!", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_c76e0ccc_3577_ba62_9f4d_394436f0b6cc);


            if (ExecutionLifetime == BehaviorExecutionLifetime.once)
            {
                CyclicActionsComplete = true;
            }
            else if (ExecutionLifetime == BehaviorExecutionLifetime.until)
            {
                var complete = ExecutionUntil(context);
                CyclicActionsComplete = !complete;
            }
        }
        return CyclicActionsComplete;
    }
 /// <summary>
 ///     Evaluates whether the given behavior info meets the minimal criteria for this behavior characterization.  However,
 ///     given that this is the null behavior characterization, it will always meet the minimal criteria (given that there
 ///     probably isn't one).
 /// </summary>
 /// <param name="behaviorInfo">The behavior info to evaluate.</param>
 /// <returns>
 ///     Boolean value indicating whether the given behavior info meets the minimal criteria for this behavior
 ///     characterization.  This will always be true given that this is the null behavior characterization.
 /// </returns>
 public bool IsMinimalCriteriaSatisfied(BehaviorInfo behaviorInfo)
 {
     return(true);
 }
Exemple #22
0
        /// <summary>
        ///     Runs a maze navigation trial.  This involves, for every timestep, activating the network with the radar/sensor
        ///     inputs, updating the navigator with the network output (i.e. changing the angular velocity and speed), moving the
        ///     navigator to the next position based on those updates, and finally returning the trial information, whether that be
        ///     fitness-based or behavior-based.
        /// </summary>
        /// <param name="agent">
        ///     The black box (neural network) that takes in the navigator sensors controls the navigator by
        ///     outputting the angular velocity and speed differentials based on those inputs.
        /// </param>
        /// <param name="searchType">The type of evaluation to perform (i.e. fitness, novelty, etc.).</param>
        /// <param name="goalReached">Indicates whether the goal has been reached.</param>
        /// <returns>The trial results (which will either be a fitness value or a behavior).</returns>
        public TTrialInfo RunTrial(IBlackBox agent, SearchType searchType, out bool goalReached)
        {
            ITrialInfo trialInfo;

            // Initialize the starting number of bridging applications
            var curBridgingApplications = 0;

            // Default the goal reached parameter to false
            goalReached = false;

            // Reset neural network
            agent.ResetState();

            // If this is a fitness evaluation, return the fitness score as the
            // difference between the maximum target distance and the ending distance
            // to the target
            if (searchType.Equals(SearchType.Fitness))
            {
                // Run for the given number of timesteps or until the goal is reached
                for (var curTimestep = 0; curTimestep < _maxTimesteps; curTimestep++)
                {
                    RunTimestep(agent, false, ref curBridgingApplications);

                    // If the goal has been reached, break out of the loop
                    if (GetDistanceToTarget() < _minSuccessDistance)
                    {
                        goalReached = true;
                        break;
                    }
                }

                var fitness = _maxDistanceToTarget - GetDistanceToTarget();
                trialInfo = new FitnessInfo(fitness, fitness);
            }
            // Otherwise, this is a behavioral evaluation, so return the ending
            // location of the navigator
            else
            {
                // Run for the given number of timesteps or until the goal is reached
                for (var curTimestep = 0; curTimestep < _maxTimesteps; curTimestep++)
                {
                    RunTimestep(agent, (curBridgingApplications < _numBridgingApplications),
                                ref curBridgingApplications);

                    _behaviorCharacterization.UpdateBehaviors(new List <double>
                    {
                        _navigator.Location.X,
                        _navigator.Location.Y
                    });

                    // If the goal has been reached, break out of the loop
                    if (GetDistanceToTarget() < _minSuccessDistance)
                    {
                        goalReached = true;
                        break;
                    }
                }

                // Extract the behavior info object
                trialInfo = new BehaviorInfo(_behaviorCharacterization.GetBehaviorCharacterizationAsArray());
            }

            return((TTrialInfo)trialInfo);
        }
        private Expression BuildBehaviorBlock(BehaviorInfo behaviorInfo, Type[] genericArguments)
        {
            var method = behaviorInfo.GetMethod(genericArguments);
            var methodCallExpression = BuildMethodCallExpression(method);

            // If the implementation method returns a boolean, then when it is false, stop processing.
            if (method.ReturnType == typeof(bool))
            {
                return Expression.IfThen(Expression.Not(methodCallExpression), Expression.Return(_end));
            }
            return methodCallExpression;
        }
Exemple #24
0
 /// <summary>
 ///     Evaluates whether the given behavior info meets the minimal criteria for this behavior characterization.
 /// </summary>
 /// <param name="behaviorInfo">The behavior info to evaluate.</param>
 /// <returns>
 ///     Boolean value indicating whether the given behavior info meets the minimal criteria for this behavior
 ///     characterization.
 /// </returns>
 public bool IsMinimalCriteriaSatisfied(BehaviorInfo behaviorInfo)
 {
     // If there is no minimal criteria, then by definition it has been met
     return(_minimalCriteria?.DoesCharacterizationSatisfyMinimalCriteria(behaviorInfo) ??
            true);
 }
Exemple #25
0
    public void Execute(IBehaviorExecutionContext context)
    {
        // STARTUP_BLOCK
          var var_6717280f_6dd1_692b_860c_f3d59bee0edb= new BehaviorInfo{BehaviorName = "stand",RobotName = "Hiro"};

  BehaviorModuleHelper.Execute(context, var_6717280f_6dd1_692b_860c_f3d59bee0edb);
  var var_bb61d711_7af2_c618_870c_a7505dff05e5= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("Hello! I am Nao!", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_bb61d711_7af2_c618_870c_a7505dff05e5);
  var var_778f900e_0853_13a8_b1b6_7e19fdddcb83= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("The doctor asked me to guide your therapy today!", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_778f900e_0853_13a8_b1b6_7e19fdddcb83);
  var var_0c670167_94d8_aedf_969e_a493738905fe= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("At first I will demonstrate the exercise routine", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_0c670167_94d8_aedf_969e_a493738905fe);
  var var_d666dcfe_0bac_4133_b1a5_42b8b29891eb= new BehaviorInfo{BehaviorName = "liftLeftHand",RobotName = "Hiro"};

  BehaviorModuleHelper.Execute(context, var_d666dcfe_0bac_4133_b1a5_42b8b29891eb);
  var var_ded8b18b_cca7_3037_b4dd_04885555a3b8= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("Please do this exercise five times. I will count for you!", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_ded8b18b_cca7_3037_b4dd_04885555a3b8);
  var var_9affd26b_d86e_7ed7_b48f_9393f29c83cf= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("Make yourself comfortable", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_9affd26b_d86e_7ed7_b48f_9393f29c83cf);
  var var_fc085727_4d3e_6efc_96fa_231ffb70bae4= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("Start doing the routine slowly", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_fc085727_4d3e_6efc_96fa_231ffb70bae4);
  count = 0;

    }
 private bool HandlerHasBehavior(BehaviorInfo behaviorInfo)
 {
     if (behaviorInfo.BehaviorType.IsGenericType)
     {
         if (_handlerType.GetInterface(behaviorInfo.BehaviorType.FullName) != null)
         {
             return true;
         }
     }
     return behaviorInfo.BehaviorType.IsAssignableFrom(_handlerType);
 }
Exemple #27
0
    public void Execute(IBehaviorExecutionContext context)
    {
        // EXIT_BLOCK
          var var_75eef517_3148_a1f8_9ac8_3401e951ac76= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("You did a great job today!", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_75eef517_3148_a1f8_9ac8_3401e951ac76);
  var var_11dadac2_feb0_e652_9e9a_9aeded062c88= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("I am looking forward to guide you next time.", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_11dadac2_feb0_e652_9e9a_9aeded062c88);
  var var_57f046be_007c_da14_877a_07dc80a6e261= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("Thank you and have a nice day!", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_57f046be_007c_da14_877a_07dc80a6e261);

    }
    public bool ExecuteCyclic(IBehaviorExecutionContext context, TriggerResult trigger)
    {
        if (!CyclicActionsComplete && InitActionsComplete)
        {
            // CYCLIC_BLOCK
              var var_af0d9ba5_7f8e_6560_8d24_b70a9ba0510b= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Hiro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("Taro, we received a stop command.", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_af0d9ba5_7f8e_6560_8d24_b70a9ba0510b);
  var var_3e5335a3_9a1f_a44a_be41_4d9a6ea6e64b= new BehaviorInfo
  {
  BehaviorName = "Say Expressively",
  RobotName = "Taro",Parameters = new Dictionary<string, object>
  {
  {"msg", BehaviorModuleHelper.CreateBehaviorParameterOptions("Yes, Let us go to rest position", true, "string")}
  }
  };

  BehaviorModuleHelper.Execute(context, var_3e5335a3_9a1f_a44a_be41_4d9a6ea6e64b);
  var var_aa5dbbc8_6eea_8066_b55f_b7d1125178e2 = new List<Task>();
  var var_71a15906_a3c2_8bd7_9262_a96cf5b603aa = new Action( () =>
  {
    var var_eba9448d_1a8b_7cea_9257_b15d34f07cc1= new BehaviorInfo
    {
    BehaviorName = "Take Rest",
    RobotName = "Hiro",Parameters = new Dictionary<string, object>()
    };

    BehaviorModuleHelper.Execute(context, var_eba9448d_1a8b_7cea_9257_b15d34f07cc1);

  });
  var var_67c4371e_7f29_7ef8_83de_ba7819f3b264 = new Action( () =>
  {
    var var_189a9b7e_37dc_f4b2_9a38_b8bdbc780275= new BehaviorInfo
    {
    BehaviorName = "Take Rest",
    RobotName = "Taro",Parameters = new Dictionary<string, object>()
    };

    BehaviorModuleHelper.Execute(context, var_189a9b7e_37dc_f4b2_9a38_b8bdbc780275);

  });
  var_aa5dbbc8_6eea_8066_b55f_b7d1125178e2.Add(Task.Run(var_71a15906_a3c2_8bd7_9262_a96cf5b603aa));
  var_aa5dbbc8_6eea_8066_b55f_b7d1125178e2.Add(Task.Run(var_67c4371e_7f29_7ef8_83de_ba7819f3b264));
  Task.WaitAll(var_aa5dbbc8_6eea_8066_b55f_b7d1125178e2.ToArray());
  System.Console.WriteLine("Parallel action execution complete");

            if (ExecutionLifetime == BehaviorExecutionLifetime.once)
            {
                CyclicActionsComplete = true;
            }
            else if (ExecutionLifetime == BehaviorExecutionLifetime.until)
            {
                var complete = ExecutionUntil(context);
                CyclicActionsComplete = !complete;
            }
        }
        return CyclicActionsComplete;
    }