示例#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;
 }
 public PositionalWithMultipleDirectionsInputMapper(SimpleSnakeWorldParams sp)
 {
     _height     = sp.Height;
     _width      = sp.Width;
     _maxFood    = sp.MaxFood;
     _startLen   = sp.StartLen;
     _inputCount = _maxFood * 3 + _startLen * 2 + 4; //per ogni cibo 3 inputs = 2 per la posizione e 1 per la validità
     //forse da aggiungere la direzione dello snake come input...
     _foodCoordinatesNumber = _maxFood * 2;
 }
示例#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;
            //    }
            //}
        }
 public GridWithMultipleDirectionsInputMapper(SimpleSnakeWorldParams sp)
 {
     _height     = sp.Height;
     _width      = sp.Width;
     _inputCount = _height * _width + 4;
 }
示例#5
0
 public GridInputMapper(SimpleSnakeWorldParams sp)
 {
     _height     = sp.Height;
     _width      = sp.Width;
     _inputCount = _height * _width;
 }