Esempio n. 1
0
        private void CognitiveCycle(object obj)
        {
            Console.WriteLine("Starting Cognitive Cycle ... press CTRL-C to finish !");
            // Cognitive Cycle starts here getting sensorial information
            while (CurrentCognitiveCycle != MaxNumberOfCognitiveCycles)
            {
                // Get current sensory information
                IList <Thing> currentSceneInWS3D = processSensoryInformation();

                // Make the perception
                SensoryInformation si = prepareSensoryInformation(currentSceneInWS3D);

                //Perceive the sensory information
                CurrentAgent.Perceive(si);

                //Choose an action
                ExternalActionChunk chosen = CurrentAgent.GetChosenExternalAction(si);

                // Get the selected action
                String          actionLabel = chosen.LabelAsIComparable.ToString();
                CreatureActions actionType  = (CreatureActions)Enum.Parse(typeof(CreatureActions), actionLabel, true);

                // Call the output event handler
                processSelectedAction(actionType);

                // Increment the number of cognitive cycles
                CurrentCognitiveCycle++;

                //Wait to the agent accomplish his job
                if (TimeBetweenCognitiveCycles > 0)
                {
                    Thread.Sleep(TimeBetweenCognitiveCycles);
                }
            }
        }
Esempio n. 2
0
        private void CognitiveCycle(object obj)
        {
            Console.WriteLine("Starting Cognitive Cycle ... press CTRL-C to finish !");
            // Cognitive Cycle starts here getting sensorial information
            var watch = System.Diagnostics.Stopwatch.StartNew();

            // the code that you want to measure comes here
            while (CurrentCognitiveCycle != MaxNumberOfCognitiveCycles)
            {
                Console.WriteLine("Creature: Clarion - Remaining Jewel: " + getJewelRemainingTotal());
                // Get current sensory information
                IList <Thing> currentSceneInWS3D = processSensoryInformation();

                // Make the perception
                SensoryInformation si = prepareSensoryInformation(currentSceneInWS3D);

                //Perceive the sensory information
                CurrentAgent.Perceive(si);

                //Choose an action
                ExternalActionChunk chosen = CurrentAgent.GetChosenExternalAction(si);

                // Get the selected action
                String          actionLabel = chosen.LabelAsIComparable.ToString();
                CreatureActions actionType  = (CreatureActions)Enum.Parse(typeof(CreatureActions), actionLabel, true);

                // Increment the number of cognitive cycles
                CurrentCognitiveCycle++;

                // Call the output event handler
                processSelectedAction(actionType);

                //Wait to the agent accomplish his job
                if (TimeBetweenCognitiveCycles > 0)
                {
                    Thread.Sleep(TimeBetweenCognitiveCycles);
                }
            }
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds / 1000;

            Console.WriteLine("Clarion completed time: " + elapsedMs);
        }