示例#1
0
 public static void Seen(AgentTypes type)
 {
     if (OnSeeing != null)
     {
         OnSeeing(type);
     }
 }
 private void Returns_Correct_Agent_Details(string agentGuid, AgentTypes expectedAgentType, string expectedAgentId)
 {
     this.When(x => x.WhenACommandActionIsCreated(agentGuid))
     .Then(x => x.ThenTheActionShouldBeSuccessful())
     .Then(x => x.TheAgentDetailsShouldBeCorrect(expectedAgentType, expectedAgentId))
     .BDDfy();
 }
 public async Task <MovieRequestRow> GetOne(AgentTypes agentType, string agentSourceId)
 {
     return(await DbContext.
            MovieRequests
            .Include(x => x.MovieRequestAgents)
            .Where(x => x.MovieRequestAgents.Any(mra => mra.AgentType == agentType && mra.AgentSourceId == agentSourceId)).
            FirstOrDefaultAsync());
 }
示例#4
0
        private void Add()
        {
            ulong       id      = _idGenerator.GetID();
            AgentsGroup ag      = new AgentsGroup(id, "Новая группа " + id);
            var         groupVM = new AgentGroupViewModel(ag, AgentTypes.FirstOrDefault());

            AgentGroups.Add(groupVM);
            SelectedGroup = groupVM;
        }
 public void CreateAgentState(AgentTypes types)
 {
     switch (types)
     {
     case AgentTypes.Player:
         gameObject.AddComponent <CharacterController>();
         State = new PlayerState(this);
         break;
     }
 }
示例#6
0
        private void GivenAgentDetails()
        {
            const AgentTypes agentType = AgentTypes.Imdb;
            var agentSourceId          = Guid.NewGuid().ToString();

            _agentDetails = new AgentGuidParserResult(agentType, agentSourceId);

            _agentGuidParser.TryGetAgentDetails(Arg.Any <string>())
            .Returns(_agentDetails);
        }
示例#7
0
    public static Agent CreateAgent(AgentTypes types)
    {
        Agent toReturn = null;

        switch (types)
        {
        case AgentTypes.Player:
            toReturn = new Agent();
            break;
        }
        return(toReturn);
    }
示例#8
0
 void seeSomeone(AgentTypes seenAgent)
 {
     if (seenAgent == AgentTypes.Outlaw)
     {
         Debug.Log("BANG!");
         EventManager.Shoot(location);
     }
     else
     {
         Debug.Log("Howdy Citizen!");
     }
 }
 public MoviePlexMediaItemRowBuilder()
 {
     _plexMediaItemId = new Random().Next(1, int.MaxValue);
     _identifier      = Guid.NewGuid();
     _key             = new Random().Next(1, int.MaxValue);
     _title           = Guid.NewGuid().ToString();
     _agentType       = AgentTypes.TheMovieDb;
     _agentSourceId   = "447109";
     _mediaUri        = Guid.NewGuid().ToString();
     _year            = DateTime.UtcNow.Year;
     _mediaType       = PlexMediaTypes.Movie;
     _resolution      = Guid.NewGuid().ToString();
 }
示例#10
0
 public PlexEpisodeRowBuilder()
 {
     _plexEpisodeId = new Random().Next(1, int.MaxValue);
     _identifier    = Guid.NewGuid();
     _episode       = 1;
     _mediaItemKey  = new Random().Next(1, int.MaxValue);
     _title         = Guid.NewGuid().ToString();
     _agentType     = AgentTypes.TheMovieDb;
     _mediaUri      = Guid.NewGuid().ToString();
     _year          = DateTime.UtcNow.Year;
     _resolution    = Guid.NewGuid().ToString();
     _tvRequests    = new List <TvRequestEpisodeRowBuilder>();
 }
示例#11
0
        public PlexSeasonRowBuilder()
        {
            _plexSeasonId        = new Random().Next(1, int.MaxValue);
            _identifier          = Guid.NewGuid();
            _season              = 1;
            _mediaItemKey        = new Random().Next(1, int.MaxValue);
            _title               = Guid.NewGuid().ToString();
            _agentType           = AgentTypes.TheMovieDb;
            _agentSourceId       = "446021";
            _mediaUri            = Guid.NewGuid().ToString();
            _plexEpisodeBuilders = new List <PlexEpisodeRowBuilder>();
            _tvRequests          = new List <TvRequestSeasonRowBuilder>();

            WithPlexEpisodes();
        }
示例#12
0
 /// <summary>
 /// Construct with the provided IGenomeDecoder and ICoevolutionPhenomeEvaluator.
 /// The number of parallel threads defaults to Environment.ProcessorCount.
 /// </summary>
 public ForagingEvaluator(IGenomeDecoder <TGenome, IBlackBox> genomeDecoder, World environment,
                          AgentTypes agent_type = AgentTypes.Spinning, bool agents_navigate = true,
                          bool agents_hide      = true)
 {
     AgentType                = agent_type;
     _agentsNavigate          = agents_navigate;
     _agentsHide              = agents_hide;
     _genomeDecoder           = genomeDecoder;
     _world                   = environment;
     _world.PlantEaten       += new World.PlantEatenHandler(_world_PlantEaten);
     _world.Stepped          += new World.StepEventHandler(_world_Stepped);
     _world.PlantEaten       += new World.PlantEatenHandler(addRewardToStatisticsList);
     _world.Stepped          += new World.StepEventHandler(updateRewardStatistics);
     _world.Stepped          += new World.StepEventHandler(esl_step);
     _world.AgentEaten       += new World.AgentEatenHandler(_world_AgentEaten);
     _world.PlantEaten       += new World.PlantEatenHandler(_world_BadPlantEaten);
     _world.Stepped          += new World.StepEventHandler(intraGenerationalPredatorChange);
     BackpropEpochsPerExample = 1;
     MemParadigm              = MemoryParadigm.Fixed;
     CurrentMemorySize        = 1;
     GenerationsPerMemorySize = 20;
     LogDiversity             = true;
     _random                  = new FastRandom();
 }
示例#13
0
 public PlexEpisodeRowBuilder WithAgentType(AgentTypes agentType)
 {
     _agentType = agentType;
     return(this);
 }
示例#14
0
 private async Task <PlexMediaItemRow> GetPlexMediaItem(AgentTypes agentType, string externalId)
 {
     return(await _plexService.GetExistingMediaItemByAgent(PlexMediaTypes.Show, agentType, externalId));
 }
示例#15
0
 public TvRequestAgentRowBuilder()
 {
     _agentType     = AgentTypes.TheMovieDb;
     _agentSourceId = "446021";
 }
示例#16
0
 public async Task <PlexMediaItemRow> GetExistingMediaItemByAgent(PlexMediaTypes mediaType, AgentTypes agentType, string agentSourceId)
 {
     return(await _plexMediaRepository.GetOne(x =>
                                              x.MediaType == mediaType &&
                                              x.AgentType == agentType &&
                                              x.AgentSourceId == agentSourceId));
 }
 public async Task <TvRequestRow> GetExistingRequest(AgentTypes agentType, string agentSourceId)
 {
     return(await _requestRepository.GetOne(x => x.PrimaryAgent.AgentType == agentType && x.PrimaryAgent.AgentSourceId == agentSourceId));
 }
 public MovieRequestAgentRow(AgentTypes agentType, string agentSourceId)
 {
     AgentType     = agentType;
     AgentSourceId = agentSourceId;
 }
示例#19
0
 public TvPlexMediaItemRowBuilder WithAgentType(AgentTypes agentType)
 {
     _agentType = agentType;
     return(this);
 }
示例#20
0
 public PlexSeasonRowBuilder WithAgentType(AgentTypes agentType)
 {
     _agentType = agentType;
     return(this);
 }
示例#21
0
 public async Task <MovieRequestRow> GetExistingRequest(AgentTypes agentType, string agentSourceId)
 {
     return(await _requestRepository.GetOne(agentType, agentSourceId));
 }
 public MediaAgentBuilder()
 {
     _agentType     = AgentTypes.TheMovieDb;
     _agentSourceId = Guid.NewGuid().ToString();
 }
示例#23
0
 public TvRequestAgentRowBuilder WithAgentType(AgentTypes agentType)
 {
     _agentType = agentType;
     return(this);
 }
 public MediaAgentBuilder WithAgentType(AgentTypes agentType)
 {
     _agentType = agentType;
     return(this);
 }
        /// <summary>
        /// Initialize the experiment with some optional XML configutation data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _timeStepsPerGeneration  = (ulong)XmlUtils.GetValueAsInt(xmlConfig, "TimeStepsPerGeneration");
            _stepReward              = XmlUtils.GetValueAsInt(xmlConfig, "StepReward");
            _agentType               = (AgentTypes)Enum.Parse(typeof(AgentTypes), XmlUtils.TryGetValueAsString(xmlConfig, "AgentType"));
            _plantLayout             = (PlantLayoutStrategies)Enum.Parse(typeof(PlantLayoutStrategies), XmlUtils.TryGetValueAsString(xmlConfig, "PlantLayout"));
            _paradigm                = (EvolutionParadigm)Enum.Parse(typeof(EvolutionParadigm), XmlUtils.TryGetValueAsString(xmlConfig, "EvolutionParadigm"));
            bool?diverse = XmlUtils.TryGetValueAsBool(xmlConfig, "LogDiversity");

            if (diverse.HasValue && diverse.Value)
            {
                _logDiversity = true;
            }
            if (_agentType == AgentTypes.Social)
            {
                var memSection = xmlConfig.GetElementsByTagName("Memory")[0] as XmlElement;
                _memory = (MemoryParadigm)Enum.Parse(typeof(MemoryParadigm), XmlUtils.TryGetValueAsString(memSection, "Paradigm"));
                SocialAgent.DEFAULT_MEMORY_SIZE = XmlUtils.GetValueAsInt(memSection, "Size");
                if (_memory == MemoryParadigm.IncrementalGrowth)
                {
                    _memGens       = XmlUtils.GetValueAsInt(memSection, "GrowthGenerations");
                    _maxMemorySize = XmlUtils.GetValueAsInt(memSection, "MaxSize");
                }
                _teaching = (TeachingParadigm)Enum.Parse(typeof(TeachingParadigm), XmlUtils.TryGetValueAsString(xmlConfig, "TeachingParadigm"));
            }
            var species = new List <PlantSpecies>();

            var plants = xmlConfig.GetElementsByTagName("Plant");

            for (int i = 0; i < plants.Count; i++)
            {
                var plant = plants[i] as XmlElement;
                species.Add(new PlantSpecies(i)
                {
                    Name   = XmlUtils.GetValueAsString(plant, "Name"),
                    Radius = XmlUtils.GetValueAsInt(plant, "Radius"),
                    Reward = XmlUtils.GetValueAsInt(plant, "Reward"),
                    Count  = XmlUtils.GetValueAsInt(plant, "Count")
                });
            }

            Random    random     = new Random();
            var       agents     = new List <ForagingAgent>();
            const int NUM_AGENTS = 10;

            for (int i = 0; i < NUM_AGENTS; i++)
            {
                agents.Add(new SpinningAgent(i)
                {
                    X = random.Next(500), Y = random.Next(500), Orientation = random.Next(360)
                });
            }

            List <Predator> predators = new List <Predator>();

            _predCount = XmlUtils.GetValueAsInt(xmlConfig, "Predators");
            var predStr = XmlUtils.TryGetValueAsString(xmlConfig, "PredatorDistribution");

            if (predStr != null)
            {
                PredatorDistribution = (PredatorDistributionTypes)Enum.Parse(typeof(PredatorDistributionTypes), predStr, true);
            }
            _predTypes = XmlUtils.GetValueAsInt(xmlConfig, "PredatorTypes");
            if (PredatorDistribution == PredatorDistributionTypes.Alternating)
            {
                _predGens = XmlUtils.GetValueAsDouble(xmlConfig, "PredatorGenerations");
            }
            _distinguishPreds = XmlUtils.GetValueAsBool(xmlConfig, "DistinguishPredators");

            _world = new World(agents, XmlUtils.GetValueAsInt(xmlConfig, "WorldHeight"), XmlUtils.GetValueAsInt(xmlConfig, "WorldHeight"), species, predators)
            {
                AgentHorizon        = XmlUtils.GetValueAsInt(xmlConfig, "AgentHorizon"),
                PlantLayoutStrategy = _plantLayout,
                StepReward          = _stepReward,
                PredatorTypes       = _predTypes
            };

            var outputs    = XmlUtils.TryGetValueAsInt(xmlConfig, "Outputs");
            var navigation = XmlUtils.TryGetValueAsBool(xmlConfig, "AgentsNavigate");
            var hiding     = XmlUtils.TryGetValueAsBool(xmlConfig, "AgentsHide");

            _navigationEnabled = navigation.HasValue ? navigation.Value : false;
            _hidingEnabled     = hiding.HasValue ? hiding.Value : false;
            if (!outputs.HasValue)
            {
                if (_navigationEnabled || _hidingEnabled)
                {
                    _outputs = (_navigationEnabled ? 2 : 0) + (_hidingEnabled ? _predTypes + 1 : 0);
                }
                else
                {
                    _outputs = outputs.HasValue ? outputs.Value : 2;
                }
            }
            else
            {
                _outputs = outputs.Value;
            }
            var inputs = XmlUtils.TryGetValueAsInt(xmlConfig, "Inputs");

            _inputs = inputs.HasValue ? inputs.Value : _world.PlantTypes.Count() * World.SENSORS_PER_OBJECT_TYPE + (_distinguishPreds ? _predTypes : 1) * World.SENSORS_PER_OBJECT_TYPE + 1;

            _eaParams             = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams     = new NeatGenomeParameters()
            {
                ActivationFn = PlainSigmoid.__DefaultInstance
            };
            if (_teaching != TeachingParadigm.EgalitarianEvolvedAcceptability)
            {
                _neatGenomeParams.InitialInterconnectionsProportion = 0.1;
            }
        }
 private void TheAgentDetailsShouldBeCorrect(AgentTypes expectedAgentType, string expectedAgentId)
 {
     _responseAgentDetails.AgentType.Should().Be(expectedAgentType);
     _responseAgentDetails.AgentSourceId.Should().Be(expectedAgentId);
 }
示例#27
0
 public MediaAgent(AgentTypes agentType, string agentSourceId)
 {
     AgentType     = agentType;
     AgentSourceId = agentSourceId;
 }
示例#28
0
 public AgentGroupConfigViewModel(IEnumerable <WayPoint> ioPoints, List <AgentsGroup> groups)
 {
     if (groups != null && groups.Count > 0)
     {
         _agentGroups = new ObservableCollection <AgentGroupViewModel>(from g in groups select new AgentGroupViewModel(g, AgentTypes.FirstOrDefault(t => t.Code == g.AgentTypeCode)));
         _idGenerator = new Generator(_agentGroups.Max(a => a.Group.Id));
     }
     else
     {
         _agentGroups = new ObservableCollection <AgentGroupViewModel>();
         _idGenerator = new Generator();
     }
     _ioPoints = ioPoints;
 }
示例#29
0
 public AgentGuidParserResult(AgentTypes agentType, string agentSourceId)
 {
     AgentType     = agentType;
     AgentSourceId = agentSourceId;
 }
示例#30
0
        /// <summary>
        /// Initialize the experiment with some optional XML configutation data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name = name;
            _populationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _timeStepsPerGeneration = (ulong)XmlUtils.GetValueAsInt(xmlConfig, "TimeStepsPerGeneration");
            _stepReward = XmlUtils.GetValueAsInt(xmlConfig, "StepReward");
            _agentType =(AgentTypes) Enum.Parse(typeof(AgentTypes), XmlUtils.TryGetValueAsString(xmlConfig, "AgentType"));
            _plantLayout = (PlantLayoutStrategies)Enum.Parse(typeof(PlantLayoutStrategies), XmlUtils.TryGetValueAsString(xmlConfig, "PlantLayout"));
            _paradigm = (EvolutionParadigm)Enum.Parse(typeof(EvolutionParadigm), XmlUtils.TryGetValueAsString(xmlConfig, "EvolutionParadigm"));
            bool? diverse = XmlUtils.TryGetValueAsBool(xmlConfig, "LogDiversity");
            if (diverse.HasValue && diverse.Value)
                _logDiversity = true;
            if (_agentType == AgentTypes.Social)
            {
                var memSection = xmlConfig.GetElementsByTagName("Memory")[0] as XmlElement;
                _memory = (MemoryParadigm)Enum.Parse(typeof(MemoryParadigm), XmlUtils.TryGetValueAsString(memSection, "Paradigm"));
                SocialAgent.DEFAULT_MEMORY_SIZE = XmlUtils.GetValueAsInt(memSection, "Size");
                if (_memory == MemoryParadigm.IncrementalGrowth)
                {
                    _memGens = XmlUtils.GetValueAsInt(memSection, "GrowthGenerations");
                    _maxMemorySize = XmlUtils.GetValueAsInt(memSection, "MaxSize");
                }
                _teaching = (TeachingParadigm)Enum.Parse(typeof(TeachingParadigm), XmlUtils.TryGetValueAsString(xmlConfig, "TeachingParadigm"));
            }
            var species = new List<PlantSpecies>();

            var plants = xmlConfig.GetElementsByTagName("Plant");
            for (int i = 0; i < plants.Count; i++)
            {
                var plant = plants[i] as XmlElement;
                species.Add(new PlantSpecies(i)
                {
                    Name = XmlUtils.GetValueAsString(plant, "Name"),
                    Radius = XmlUtils.GetValueAsInt(plant, "Radius"),
                    Reward = XmlUtils.GetValueAsInt(plant, "Reward"),
                    Count = XmlUtils.GetValueAsInt(plant, "Count")
                });
            }
           
            Random random = new Random();
            var agents = new List<ForagingAgent>();
            const int NUM_AGENTS = 10;
            for (int i = 0; i < NUM_AGENTS; i++)
            {
                agents.Add(new SpinningAgent(i) { X = random.Next(500), Y = random.Next(500), Orientation = random.Next(360) });
            }

            List<Predator> predators = new List<Predator>();
            _predCount = XmlUtils.GetValueAsInt(xmlConfig, "Predators");
            var predStr = XmlUtils.TryGetValueAsString(xmlConfig, "PredatorDistribution");
            if (predStr != null)
                PredatorDistribution = (PredatorDistributionTypes)Enum.Parse(typeof(PredatorDistributionTypes), predStr, true);
            _predTypes = XmlUtils.GetValueAsInt(xmlConfig, "PredatorTypes");
            if (PredatorDistribution == PredatorDistributionTypes.Alternating)
                _predGens = XmlUtils.GetValueAsDouble(xmlConfig, "PredatorGenerations");
            _distinguishPreds = XmlUtils.GetValueAsBool(xmlConfig, "DistinguishPredators");

            _world = new World(agents, XmlUtils.GetValueAsInt(xmlConfig, "WorldHeight"), XmlUtils.GetValueAsInt(xmlConfig, "WorldHeight"), species, predators)
            {
                AgentHorizon = XmlUtils.GetValueAsInt(xmlConfig, "AgentHorizon"),
                PlantLayoutStrategy = _plantLayout,
                StepReward = _stepReward,
                PredatorTypes = _predTypes
            };

            var outputs = XmlUtils.TryGetValueAsInt(xmlConfig, "Outputs");
            var navigation = XmlUtils.TryGetValueAsBool(xmlConfig, "AgentsNavigate");
            var hiding = XmlUtils.TryGetValueAsBool(xmlConfig, "AgentsHide");
            _navigationEnabled = navigation.HasValue ? navigation.Value : false;
            _hidingEnabled = hiding.HasValue ? hiding.Value : false;
            if (!outputs.HasValue)
            {
                if (_navigationEnabled || _hidingEnabled)
                    _outputs = (_navigationEnabled ? 2 : 0) + (_hidingEnabled ? _predTypes + 1 : 0);
                else
                    _outputs = outputs.HasValue ? outputs.Value : 2;
            }
            else
                _outputs = outputs.Value;
            var inputs = XmlUtils.TryGetValueAsInt(xmlConfig, "Inputs");
            _inputs = inputs.HasValue ? inputs.Value : _world.PlantTypes.Count() * World.SENSORS_PER_OBJECT_TYPE + (_distinguishPreds ? _predTypes : 1) * World.SENSORS_PER_OBJECT_TYPE + 1;

            _eaParams = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams = new NeatGenomeParameters()
            {
                ActivationFn = PlainSigmoid.__DefaultInstance
            };
            if (_teaching != TeachingParadigm.EgalitarianEvolvedAcceptability)
                _neatGenomeParams.InitialInterconnectionsProportion = 0.1;
        }