Exemplo n.º 1
0
 public SnakeGameEvaluatorSmart(SimpleSnakeWorldParams _swparams, IInputMapper _inputMapper, IOutputMapper _outputMapper, int _trialsPerEvaluation, int _maxTicksWithoutEating)
 {
     this._swparams              = _swparams;
     this._inputMapper           = _inputMapper;
     this._outputMapper          = _outputMapper;
     this._trialsPerEvaluation   = _trialsPerEvaluation;
     this._maxTicksWithoutEating = _maxTicksWithoutEating;
 }
Exemplo n.º 2
0
        public SnakeRunnerSmart(SimpleSnakeWorld sw, IBlackBox phenome, IInputMapper inputMapper, IOutputMapper outputMapper, int _msBetweenTicks, int _maxTicksWithoutScoreChange)
        {
            this._sw                         = sw;
            this.Phenome                     = phenome;
            this._msBetweenTicks             = _msBetweenTicks;
            this._maxTicksWithoutScoreChange = _maxTicksWithoutScoreChange;

            _inputMapper  = inputMapper;
            _outputMapper = outputMapper;
        }
Exemplo n.º 3
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");

            //snake specific params
            _swparams = SnakeUtils.GetParamsFromXml(xmlConfig);

            _trialsPerEvaluation   = XmlUtils.TryGetValueAsInt(xmlConfig, "TrialsPerEvaluation") ?? _trialsPerEvaluation;
            _maxTicksWithoutEating = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxTicksWithoutEating") ?? (_swparams.Height * _swparams.Width + _swparams.TicksBetweenFood);


            _inputMapperName  = XmlUtils.TryGetValueAsString(xmlConfig, "InputMapping") ?? _inputMapperName;
            _outputMapperName = XmlUtils.TryGetValueAsString(xmlConfig, "OutputMapping") ?? _outputMapperName;

            _description     = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);

            _eaParams                         = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount             = _specieCount;
            _neatGenomeParams                 = new NeatGenomeParameters();
            _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;

            //string nameoftype = (string ) typeof(GridInputMapper).GetProperty("Name", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue(null, null);

            Type inputType = Assembly.GetAssembly(typeof(IInputMapper)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && (typeof(IInputMapper).IsAssignableFrom(myType)) &&
                                                                                         _inputMapperName == (string)myType.GetProperty("Name", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue(null, null)).First();

            _inputMapper = (IInputMapper)Activator.CreateInstance(inputType, _swparams);

            Type outputType = Assembly.GetAssembly(typeof(IOutputMapper)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && (typeof(IOutputMapper).IsAssignableFrom(myType)) &&
                                                                                           _outputMapperName == (string)myType.GetProperty("Name", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue(null, null)).First();

            _outputMapper = (IOutputMapper)Activator.CreateInstance(outputType);

            //foreach (Type type in
            //Assembly.GetAssembly(typeof(IInputMapper)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(IInputMapper) )))
            //{
            //    SnakeRunnerFactory srf = (SnakeRunnerFactory) Activator.CreateInstance(type, swOriginal);
            //    if (srf.Name == _ioLayers)
            //    {
            //        _srf = srf;
            //        break;
            //    }
            //}
        }