コード例 #1
0
 public BusStop(ulong id, Enviroment.Map map, Enviroment.WayPoint location)
 {
     base.Id = id;
     base.Dislocation = location;
     _map = map;
     _servicePoint = new Point(location.X, location.Y);
 }
コード例 #2
0
 public Crosswalk(Enviroment.Map map, List<Point> mapCells)
     : base(map, mapCells)
 {
     foreach (var cell in mapCells)
     {
         map[0].SetCell(cell.X, cell.Y, new Enviroment.Model.Cell(0x01) { TemporarilyClosed = true });
     }
 }
コード例 #3
0
        public LayerViewModel(Enviroment.Model.Layer layer)
            : this(layer.MaskSource, layer.Name, layer.Scale)
        {
            MaskInfo = new List<MapInfoVM>();

            foreach (var pair in layer.MaskInfo)
            {
                MaskInfo.Add(new MapInfoVM(pair.Key, pair.Value));
            }
        }
コード例 #4
0
        public void Initialize(Enviroment.Map map, Dictionary<string, object> settings)
        {
            _map = map;
            if (map.Count == 0)
            {
                Width = 800;
                Height = 600;
                Background = Brushes.Gainsboro;
            }
            else
            {
                Width = map[0].Width;
                Height = map[0].Height;
                if (map[0].Substrate != null)
                {
                    Background = new ImageBrush(Helpers.Imaging.ImageManager.BitmapToBitmapImage(map[0].Substrate));
                }
                else
                {
                    Background = Brushes.Gainsboro;
                }
            }

            if (_passengerDensity == null || _passengerLastLocations == null)
            {
                _passengerDensity = new uint[Width, Height];
                _passengerLastLocations = new ulong[Width, Height];
            }
            //_worker = new BackgroundWorker();
            //_worker.DoWork += (s, e) =>
            //{
            //    _spectralBrush = GetSpectorImageBrush();
            //};
            //_worker.RunWorkerCompleted += (s, e) =>
            //{
            //    OnPropertyChanged("SpectralBrush");
            //    //if (e.Result is ImageBrush)
            //    //{
            //    //    SpectralBrush = (ImageBrush)e.Result;
            //    //}
            //};

            OnPropertyChanged("Width");
            OnPropertyChanged("Height");
            OnPropertyChanged("Background");
        }
コード例 #5
0
 public AgentBase GetInstance(Enviroment.Map map, IEnumerable<Contracts.Services.AgentServiceBase> services, Dictionary<string, object> settings)
 {
     var agent = new Vehicle(map, services);
     agent.Initialize(settings);
     return agent;
 }
コード例 #6
0
ファイル: DoNothing.cs プロジェクト: Hengle/IceKori-1
 public override object[] Reduce(Enviroment env, ErrorHandling errorHandling)
 {
     return(new object[] {});
 }
コード例 #7
0
ファイル: BinaryExpression.cs プロジェクト: Pinkuburu/IceKori
        public override BaseExpression Reduce(Enviroment env)
        {
            while (Left.Reducible)
            {
                Left = Left.Reduce(env);
                if (Left.GetType().IsSubclassOf(typeof(Error.Error)))
                {
                    return(Left);
                }
            }

            while (Right.Reducible)
            {
                Right = Right.Reduce(env);
                if (Left.GetType().IsSubclassOf(typeof(Error.Error)))
                {
                    return(Left);
                }
            }
            switch (Operator)
            {
            case BinaryOperator.Add:
                return(_Add());

            case BinaryOperator.Sub:
                return(_Sub());

            case BinaryOperator.Mul:
                return(_Mul());

            case BinaryOperator.Div:
                return(_Div());

            case BinaryOperator.Mod:
                return(_Mod());

            case BinaryOperator.Concat:
                return(_Concat());

            case BinaryOperator.Less:
                return(_Less());

            case BinaryOperator.LessEqual:
                return(_LessEqual());

            case BinaryOperator.Equal:
                return(_Equal());

            case BinaryOperator.MoreEqual:
                return(_MoreEqual());

            case BinaryOperator.More:
                return(_More());

            case BinaryOperator.NotEqual:
                return(_NotEqual());

            case BinaryOperator.And:
                return(_And());

            case BinaryOperator.Or:
                return(_Or());

            default:
                throw new Exception($"error operator,\"{Operator}\" not define.");
            }
        }
コード例 #8
0
        private void bt_Run_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (HasSelectedAlgorithm)
                {
                    string _Error = "";
                    if (!Enviroment.CanRunAlgorithm(out _Error, AlgorithmType.Ensemble))
                    {
                        MessageBox.Show(_Error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    ReflectionTools   _rcet        = new ReflectionTools();
                    ConsensusFunction _EnsembleAlg = ReflectionTools.GetInstance <ConsensusFunction>(Tree.Value.FullName);

                    foreach (CEDS.Property _p in Tree.Value.InProperties)
                    {
                        _rcet.SetProperty(Tree.Value.FullName, _EnsembleAlg, _p);
                    }

                    List <Structuring> _structuringsParams = GetSelectedStructurings();
                    if (_structuringsParams == null || _structuringsParams.Count == 0)
                    {
                        MessageBox.Show("You must select at least one Structuring to apply an Ensemble algorithm.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    VisualUtils.SetGlobalInProperties(_rcet, _EnsembleAlg, Tree, _structuringsParams);

                    #region OLD CODE
                    //Structuring _structuring = _EnsembleAlg.BuildStructuring();

                    //PartitionInfo _partInfo = new PartitionInfo()
                    //{
                    //    AlgorithmName = this.tb_SelectEnsembleAlg.Text,
                    //    ConsensusFunction = _EnsembleAlg,
                    //    Partition = _structuring,
                    //    AlgorithmType = AlgorithmType.Ensemble,
                    //    Index = -1
                    //};
                    //this.uctrl_ListClusterAlgVisualizerEnsemble.AddPartitionInfo(_partInfo);


                    //if (NewStructuringEventHandler != null)
                    //{
                    //    NewStructuringEventHandler(this, new NewStructuringEventArgs(_partInfo));
                    //}
                    #endregion

                    Run _run = RunMethod;
                    _run.BeginInvoke(_EnsembleAlg, RunFinish, new DataThread()
                    {
                        ConsensusFunction = _EnsembleAlg, Run = _run
                    });
                }
                else
                {
                    MessageBox.Show("You must first select an Ensemble algorithm.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception _ex)
            {
                GeneralTools.Tools.WriteToLog(_ex);
            }
        }
コード例 #9
0
ファイル: Break.cs プロジェクト: Pinkuburu/IceKori-1
 public override object[] Reduce(Enviroment env, ErrorHandling errorHandling)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
 public MapServiceBase(Enviroment.Map map, List<Point> mapCells)
 {
     _map = map;
     _mapCells = mapCells;
 }
コード例 #11
0
ファイル: ThrowStatment.cs プロジェクト: Pinkuburu/IceKori
 public override BaseStatement Reduce(Enviroment env)
 {
     throw new NotImplementedException();
 }
コード例 #12
0
        public void DealReturnValue(System.Windows.Forms.ListBox returnaddlistbox, object returnvalue)
        {
            Enviroment env = (Enviroment)returnvalue;

            returnaddlistbox.Items.AddRange(new[] { env.get.GetType().ToString(), env.gh.GetType().ToString(), env.book.GetType().ToString(), env.results.GetType().ToString() });
        }
コード例 #13
0
 public void Invoke(Enviroment env)
 {
     throw new NotImplementedException();
 }
コード例 #14
0
ファイル: Nasdan.cs プロジェクト: gaotisan/Nasdan
 public static void StartServers()
 {
     Nasdan._startProcess(Enviroment.GetFileName(Enviroment.Representation.experiences), Enviroment.GetStartArgument());
     Nasdan._startProcess(Enviroment.GetFileName(Enviroment.Representation.knowloges), Enviroment.GetStartArgument());
 }
コード例 #15
0
 public override BaseExpression Reduce(Enviroment env)
 {
     throw new Exception(ToString());
 }
コード例 #16
0
ファイル: BaseStatement.cs プロジェクト: Pinkuburu/IceKori-1
 /// <summary>
 /// 对语句进行一次求值。
 /// </summary>
 /// <param name="env">环境对象</param>
 /// <param name="errorHandling">错误处理对象</param>
 /// <returns></returns>
 public abstract object[] Reduce(Enviroment env, ErrorHandling errorHandling);
コード例 #17
0
 public ServiceBase GetInstance(ulong serviceId, Enviroment.Map map, Enviroment.WayPoint location, Dictionary<string, object> settings)
 {
     BusStop service = new BusStop(serviceId, map, location);
     service.Initialize(settings);
     return service;
 }
コード例 #18
0
 public override object[] Reduce(Enviroment env, ErrorHandling errorHandling)
 {
     return(new object[] { new Sequence(env.GlobalCommands[Name]), env, errorHandling });
 }
コード例 #19
0
        public Turn Iteration(LevelView level, IMessageReporter reporter, out bool isAttack)
        {
            Enviroment.Update(level, 3);
            var bonusIgnore = new BadObjectMap(level, (view, location) => level.Items.Any(i => i.Location.Equals(location)), view => level.Items.Select(i => i.Location), 1);
            var attackMap   = Map.Sum(Enviroment.WallMap, Enviroment.TrapMap, bonusIgnore);
            var travelMap   = Map.Sum(attackMap, Enviroment.EnemyMap, bonusIgnore);

            if (level.Monsters.Any())
            {
                var monster        = level.Monsters.First();
                var enemyHp        = monster.Health;
                var healingHpLevel = 50;
                if (enemyHp < MonsterStartHp * 0.6) //если враг пытается отрегениться - забираем его аптечку))
                {
                    healingHpLevel = 60;
                }
                if (level.Player.Health < healingHpLevel && level.HealthPacks.Any())
                {
                    var path = travelMap.FindPath(level.Player.Location,
                                                  level.HealthPacks.OrderBy(h => h.Location.Distance(level.Player.Location)).First().Location);
                    isAttack = false;
                    if (path != null && path.Count > 1)
                    {
                        return(Turn.Step(path[1] - path[0]));
                    }
                    return(Turn.None);
                }
            }

            if (level.Monsters.Any(m => m.Location.IsInRange(level.Player.Location, 1)))
            {
                var monster = level.Monsters.Where(m => m.Location.IsInRange(level.Player.Location, 1)).OrderBy(m => m.Health).First();
                isAttack = true;
                return(Turn.Attack(monster.Location - level.Player.Location));
            }
            if (level.Monsters.Any())
            {
                var target  = level.Monsters.First().Location;
                var targets = target
                              .Near(3)
                              .Where(
                    p =>
                    p.X >= 0 && p.Y >= 0 && p.X < Enviroment.TravelMap.Width &&
                    p.Y < Enviroment.TravelMap.Height)
                              .Where(p => Enviroment.TravelMap.IsTravaible(p))
                              .OrderBy(p => p.Distance(target));

                foreach (var location in targets)
                {
                    var path = attackMap.FindPath(level.Player.Location, location);
                    isAttack = false;
                    if (path != null && path.Count > 1)
                    {
                        return(Turn.Step(path[1] - path[0]));
                    }
                }
            }
            if (!ExitIsClosed(level))
            {
                Enviroment = new Enviroment(level, 2);
                var path = travelMap.FindPath(level.Player.Location, Exit);
                isAttack = false;
                if (path == null || path.Count < 2)
                {
                    return(Turn.None);
                }
                return(Turn.Step(path[1] - path[0]));
            }
            isAttack = false;
            return(Turn.None);
        }
コード例 #20
0
 public override object[] Reduce(Enviroment env, ErrorHandling errorHandling)
 {
     Func(env, errorHandling);
     return(new object[] { new DoNothing(), env, errorHandling });
 }