예제 #1
0
        public Algorithm(
            IPoints points, IRectangle rect, StrategyType type = StrategyType.Grid, ILog2 log = null)
        {
            _log = log ?? new NoLog();
            Rectangle = rect;
            Points = points.Data;
            Singles = new List<IP>();
            Knn = new NearestNeighbor();

            GridContainer = new GridContainer(Rectangle, Points);

            switch (type)
            {
                case StrategyType.Naive:
                    Strategy = new NaiveStrategy(_log);
                    break;
                case StrategyType.Grid:
                    Strategy = new GridStrategy(_log);
                    break;
                case StrategyType.KdTree:
                    Strategy = new KdTreeStrategy(Points);
                    break;
                default:
                    throw new NotImplementedException("Unknown strategy");
            }

            //_log.Info(MethodBase.GetCurrentMethod(), "object init");
        }
예제 #2
0
        private void toolStripRenderer_SelectedIndexChanged(object sender, EventArgs e)
        {
            RenderType   renderType   = this.toolStripRenderer.SelectedItem != null ? (RenderType)this.toolStripRenderer.SelectedItem : RenderType.RayTracer;
            StrategyType strategyType = this.toolStripStrategy.SelectedItem != null ? (StrategyType)this.toolStripStrategy.SelectedItem : StrategyType.Progressive;

            RenderStrategy strategy = new ProgressiveRenderStrategy();

            switch (strategyType)
            {
            case StrategyType.Scanline:
                strategy = new ScanlineRenderStrategy();
                break;

            case StrategyType.Progressive:
                strategy = new ProgressiveRenderStrategy();
                break;
            }
            switch (renderType)
            {
            case RenderType.RayTracer:
                this.tracer = new RayTracer(UnifiedScenesRepository.Scenes[this.TabText], strategy);
                break;

            case RenderType.PhotonTracer:
                this.tracer = new PhotonTracer(UnifiedScenesRepository.Scenes[this.TabText], strategy, 500000);
                break;

            case RenderType.DistributedRayTracer:
                this.tracer = new DistributedRayTracer(UnifiedScenesRepository.Scenes[this.TabText], strategy);
                break;
            }
        }
예제 #3
0
    //目录下所有的文件 包括所有层子文件夹 每个文件一个包
    public List <AssetBundleBuild> HandleOneByOneFile(string path, StrategyType type)
    {
        List <AssetBundleBuild> buildList = new List <AssetBundleBuild>();

        var files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);

        for (int i = 0; i < files.Length; i++)
        {
            var file = files[i];
            var ext  = Path.GetExtension(file);
            if (!IgnorePackageExt.IsCanPackageAsset(ext))
            {
                continue;
            }

            AssetBundleBuild build = new AssetBundleBuild();

            var abName = file.Replace(ext, Const.ExtName).Replace("\\", "/");

            build.assetBundleName = abName;
            var assetName = file.Replace("\\", "/");
            build.assetNames = new string[] { assetName };
            buildList.Add(build);
        }

        return(buildList);
    }
예제 #4
0
 private int getProfit(StrategyType strategy, XElement e)
 {
     if (strategy == StrategyType.SWING)
     {
         return((int)Math.Abs((double)e.Element("LinkedLevels").Descendants("LinkedLevel").ElementAt(1).Element("Distance") / 10));
     }
     return(0);
 }
예제 #5
0
 /// <summary>
 /// 数组,2个参数
 /// </summary>
 /// <param name="name"></param>
 /// <param name="pas">数组</param>
 public Strategy(object name, ArrayList pas)
 {
     this.parameters          = new ArrayList();
     this.m_Name              = name;
     this.m_Type              = StrategyType.StringEqual;
     this.m_RelationFieldName = "";
     this.parameters          = pas;
 }
예제 #6
0
 /// <summary>
 /// 字符串,2个参数
 /// </summary>
 /// <param name="name"></param>
 /// <param name="param0">字符串</param>
 public Strategy(object name, string param0)
 {
     this.parameters          = new ArrayList();
     this.m_Name              = name;
     this.m_Type              = StrategyType.StringEqual;
     this.m_RelationFieldName = "";
     this.parameters.Add(param0);
 }
        public void InvestMoney(double amount, StrategyType type)
        {
            var investment = InvestmentFactory.CreateInvestment(type, amount);

            _account.Investments.Add(investment);
            _account.ChangeBalance(-amount);
            Notify($"Investment has been made. Amount: {amount.ToString("F2")}, name: {investment.Name}");
        }
예제 #8
0
 /// <summary>
 /// 枚组、字符串、数组,4个参数
 /// </summary>
 /// <param name="name"></param>
 /// <param name="type"></param>
 /// <param name="relationFieldName"></param>
 /// <param name="pas"></param>
 public Strategy(object name, StrategyType type, string relationFieldName, ArrayList pas)
 {
     this.parameters          = new ArrayList();
     this.m_Name              = name;
     this.m_Type              = type;
     this.m_RelationFieldName = relationFieldName;
     this.parameters          = pas;
 }
예제 #9
0
 public DefaultStrategyConf(StrategyType _StratType, Exchange platform, string name, bool autostart, SignalSource getfrom)
 {
     this.StratyType = _StratType;
     this.Name       = name;
     this.Exchanger  = Exchange.Binance;
     this.AutoStart  = autostart;
     this.SignalFrom = getfrom;
 }
예제 #10
0
        public FaceToolPath(Face face, CuttingTool tool, CuttingParameters parameters, StrategyType strategy)
            : base(tool, parameters)
        {
            Debug.Assert(tool != null);
            Debug.Assert(parameters != null);

            Face     = face;
            Strategy = strategy;
        }
예제 #11
0
    // Updates the q value of a state-action tuple
    public void UpdateQValue(SimplifiedWorld state, StrategyType strategy, SimplifiedWorld nextState, float reward)
    {
        // Get the key
        float  qValue = getQValue(state, strategy);
        string key    = (new Key(state, strategy)).ToString();

        // Update the QValue
        utilities[key] = qValue + Alpha * (reward + Discount * ComputeValueFromQValues(nextState) - qValue);
    }
예제 #12
0
        private static void CreateObjects(StrategyType strategyType)
        {
            PrintString($"Creating 3 objects ", includeNewLine: false);

            if (strategyType == StrategyType.Traditional)
            {
                PrintString("traditionally");
            }
            else
            {
                PrintString("with prototypes");
            }

            Stopwatch overallTimer = new Stopwatch();

            overallTimer.Start();

            // Print out ui skeleton
            for (int i = 1; i <= objectCount; i++)
            {
                PrintString($" Object {i}: ");
            }

            // Reset the cursor to the first object
            Console.SetCursorPosition(11, Console.CursorTop - 3);

            // Create the objects
            for (int i = 0; i < objectCount; i++)
            {
                Console.Write("Creating...");
                // Time each object's creation
                Stopwatch sw = new Stopwatch();
                sw.Start();

                if (strategyType == StrategyType.Prototype && myObjects.Count > 0)
                {
                    myObjects.Add(myObjects[0].Clone());
                    myObjects[i].Name = $"Object {i + 1}";
                }
                else
                {
                    myObjects.Add(new MyObject($"Object {i + 1}"));
                }

                sw.Stop();
                Console.SetCursorPosition(11, Console.CursorTop);
                PrintString($"Object {i+1} created in {sw.Elapsed.TotalMilliseconds} ms", ConsoleColor.Yellow, false);

                // Move cursor to next line
                Console.SetCursorPosition(11, Console.CursorTop + 1);
            }

            overallTimer.Stop();
            PrintString($"\n {objectCount} objects created in {overallTimer.Elapsed.TotalMilliseconds} milliseconds\n", ConsoleColor.Green);

            myObjects.Clear();
        }
예제 #13
0
파일: Strategy.cs 프로젝트: yuzd/lamar
 public ComplexStrategy(IStrategy[] innerStrategies, string name, long quantity,
                        IStrategy defaultStrategy, StrategyType strategyType)
 {
     _innerStrategies = innerStrategies;
     _name            = name;
     _quantity        = quantity;
     _defaultStrategy = defaultStrategy;
     _strategyType    = strategyType;
 }
예제 #14
0
 public ComplexStrategy(IStrategy[] innerStrategies, string name, long quantity,
                        IStrategy defaultStrategy, StrategyType strategyType)
 {
     _innerStrategies = innerStrategies;
     _name = name;
     _quantity = quantity;
     _defaultStrategy = defaultStrategy;
     _strategyType = strategyType;
 }
예제 #15
0
        public void Analyze(ArmyInfo opponent)
        {
            strategy = (lastScore - score) * lossScoreFactor <(opponent.lastScore - opponent.score) ||
                                                              (opponent.All.Count > All.Count * 1.5)
                                        ? StrategyType.Back
                                                              : (lastScore - score)> (opponent.lastScore - opponent.score) * lossScoreFactor
                                                ? StrategyType.Brave
                                                : StrategyType.Normal;
            foreach (var squad in Squads)
            {
                squad.Value.Target = null;
                squad.Value.IsUnderNuclearAttack = opponent.strike != null && squad.Value.Vehicles
                                                   .Any(v => v.Value.GetDistanceTo(opponent.strike.target.X, opponent.strike.target.Y) < 50);
            }
            lastScore = score;

            var opponentVehicles            = opponent.All.ToArray();
            var opponentVehiclesCoordinates = opponent.All.Select(v => new Coordinate(v.Value.X, v.Value.Y)).ToArray();
            int optimalClusters             = 5;

            int[] clusteredIndices;
            var   minVariance = double.MaxValue;

            for (var i = Min(5, opponentVehiclesCoordinates.Length); i > 0; i--)
            {
                opponent.Squads.Clear();
                clusteredIndices = Clusterization.Cluster(opponentVehiclesCoordinates, i);
                for (var j = 0; j < clusteredIndices.Length; j++)
                {
                    ISquad squad;
                    if (!opponent.Squads.TryGetValue(clusteredIndices[j], out squad))
                    {
                        opponent.Squads.Add(clusteredIndices[j], squad = new Squad(clusteredIndices[j], opponent.All, opponent.Squads));
                    }
                    squad.AddOrUpdateVehicle(opponentVehicles[j].Value);
                }
                var sumVariance = opponent.Squads.Sum(s => s.Value.Target.variance) / opponent.Squads.Count;

                if (minVariance > sumVariance)
                {
                    minVariance     = sumVariance;
                    optimalClusters = i;
                }
            }
            opponent.Squads.Clear();
            clusteredIndices = Clusterization.Cluster(opponentVehiclesCoordinates, optimalClusters);
            for (var j = 0; j < clusteredIndices.Length; j++)
            {
                ISquad squad;
                if (!opponent.Squads.TryGetValue(clusteredIndices[j], out squad))
                {
                    opponent.Squads.Add(clusteredIndices[j], squad = new Squad(clusteredIndices[j], opponent.All, opponent.Squads));
                }
                squad.AddOrUpdateVehicle(opponentVehicles[j].Value);
            }
        }
예제 #16
0
        public string GetString <T>(T obj, StrategyType strategyType)
        {
            Serializer = (ISerializerStrategy)Activator.CreateInstance(strategies[strategyType]);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(WithWhat());
            stringBuilder.AppendLine(Serializer.Serialize(obj));
            stringBuilder.AppendLine(new string(Separator, 40));
            return(stringBuilder.ToString());
        }
예제 #17
0
    public static void CreateWeaponType()
    {
        StrategyType asset = ScriptableObject.CreateInstance <StrategyType>();

        AssetDatabase.CreateAsset(asset, "Assets/Resources/CharacterData/Data/NPCSetup/" + typeof(StrategyType).ToString() + ".asset");
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();

        Selection.activeObject = asset;
    }
예제 #18
0
        public static StrategyBase GetStrategy(StrategyType strategy, StrategyParam param)
        {
            if (!StrategyMap.ContainsKey(strategy))
            {
                strategy = StrategyType.Infinte;
            }
            Type type = StrategyMap[strategy];

            return((StrategyBase)Activator.CreateInstance(type, param));
        }
예제 #19
0
    /// <summary>
    /// Validate if all necessary configurations for the creation of npc exists.
    /// </summary>
    /// <returns></returns>
    private bool ValidateSetup()
    {
        if (_allClass.Count <= 0)
        {
            GUILayout.BeginArea(npcSection);
            EditorGUILayout.HelpBox("No data class found", MessageType.Error);
            if (GUILayout.Button("Create new class"))
            {
                CharacterClass.CreateCharacterClass();
                Selection.activeObject = AssetDatabase.LoadAssetAtPath("Assets/Resources/CharacterData/Data/Character Class/CharacterClass.asset", typeof(CharacterClass));
                this.Close();
            }
            GUILayout.EndArea();
            return(false);
        }

        if (_npcWeaponType == null)
        {
            GUILayout.BeginArea(npcSection);
            EditorGUILayout.HelpBox("No setup for weapons", MessageType.Error);
            if (GUILayout.Button("Create Setup"))
            {
                WeaponType.CreateWeaponType();
                _npcWeaponType = (WeaponType)AssetDatabase.LoadAssetAtPath("Assets/Resources/CharacterData/Data/NPCSetup/WeaponType.asset", typeof(WeaponType));
            }
            GUILayout.EndArea();
            return(false);
        }
        else if (_npcDamageType == null)
        {
            GUILayout.BeginArea(npcSection);
            EditorGUILayout.HelpBox("No setup for Damage type", MessageType.Error);
            if (GUILayout.Button("Create Setup"))
            {
                DamageType.CreateWeaponType();
                _npcDamageType = (DamageType)AssetDatabase.LoadAssetAtPath("Assets/Resources/CharacterData/Data/NPCSetup/DamageType.asset", typeof(DamageType));
            }
            GUILayout.EndArea();
            return(false);
        }
        else if (_npcStrategyType == null)
        {
            GUILayout.BeginArea(npcSection);
            EditorGUILayout.HelpBox("No setup for Strategy type", MessageType.Error);
            if (GUILayout.Button("Create Setup"))
            {
                StrategyType.CreateWeaponType();
                _npcStrategyType = (StrategyType)AssetDatabase.LoadAssetAtPath("Assets/Resources/CharacterData/Data/NPCSetup/StrategyType.asset", typeof(StrategyType));
            }
            GUILayout.EndArea();
            return(false);
        }

        return(true);
    }
 public Strategy_Product_Code_Count_Datum(
     StrategyType st, 
     ProductType pt, 
     String code, 
     long count)
 {
     this._StrategyType = st;
     this._ProductType = pt;
     this.Code = code;
     this.Count = count;
 }
예제 #21
0
 public Call(StrategyType strategy)
 {
     if (strategy == StrategyType.AllUnits)
     {
         this.strategy = new AllUnitsStrategy();
     }
     else
     {
         this.strategy = new OneUnitStrategy();
     }
 }
예제 #22
0
        public int DiscardStrategyTypeCards(StrategyType strategyType)
        {
            List <Card> discardList = pileHand.GetStrategyTypeCards(strategyType);
            int         ret         = discardList.Count;

            foreach (Card card in discardList)
            {
                pileHand.Remove(card);
                pileDiscard.Add(card);
            }

            return(ret);
        }
예제 #23
0
    protected override void OnEnter(StrategyType lastStrategy)
    {
        _screens[_activeScreen].Enter(_lastScreen);

        var gm = GameManager.Instance;

        if (gm.MusicSource.clip != gm.MainMenuClip)
        {
            gm.MusicSource.loop = true;
            gm.MusicSource.clip = gm.MainMenuClip;
        }
        gm.MusicSource.Play();
    }
        public UC_WHControlConfig_VM_Base(string sn, StrategyType stratType)
        {
            _sn = sn;
            List <LedBasicInfo> ledInfoList = MonitorAllConfig.Instance().LedInfoList.FindAll(a => a.Sn == _sn);

            if (ledInfoList.Count != 0)
            {
                _aliaName = ledInfoList[0].AliaName;
            }
            _id        = Guid.NewGuid();
            _stratType = stratType;
            InitialPowerList(new Dictionary <string, PowerCtrl_Type>());
        }
예제 #25
0
        public List <Card> GetStrategyTypeCards(StrategyType strategyType)
        {
            List <Card> ret = new List <Card>();

            foreach (Card card in _pile)
            {
                if (card.GetComponent <MetaData>().strategy == strategyType)
                {
                    ret.Add(card);
                }
            }

            return(ret);
        }
예제 #26
0
        public void Alarm(StrategyType strategy)
        {
            Call new_alarm_call;

            if (strategy == StrategyType.AllUnits)
            {
                new_alarm_call = new Call(StrategyType.AllUnits);
            }
            else
            {
                new_alarm_call = new Call(StrategyType.OneUnit);
            }
            new_alarm_call.Start(ref units, code);
        }
예제 #27
0
    // Returns the q value of a state-action tuple
    public float getQValue(SimplifiedWorld state, StrategyType strategy)
    {
        string key = (new Key(state, strategy)).ToString();

        if (utilities.ContainsKey(key))
        {
            return(utilities [key]);
        }
        else
        {
            StrategyType recommended = strategyRecommendationFromState(state);
            return(recommended == strategy ? 1.0f : 0.0f);
        }
    }
예제 #28
0
    //该目录所有一级文件夹 每个文件夹打成一个包
    public List <AssetBundleBuild> AllInOneBySubFolder(string path, StrategyType type)
    {
        List <AssetBundleBuild> buildList = new List <AssetBundleBuild>();

        var dirs = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly);

        for (int i = 0; i < dirs.Length; i++)
        {
            var dir        = dirs[i];
            var buildRange = HandleAllInOneByFolder(dir, StrategyType.AllInOneByFolder);
            buildList.AddRange(buildRange);
        }

        return(buildList);
    }
예제 #29
0
        static void Main()
        {
            var data = new Data
            {
                Text = "Best example ever",
                Int  = 777
            };

            //This is the class which we can modify run time
            var objectToStringMaker = new ObjectToStringMaker('*');

            Console.WriteLine("1 - XML, 2 - JSON :");
            StrategyType strategyType = (StrategyType)int.Parse(Console.ReadLine());

            Console.WriteLine(objectToStringMaker.GetString(data, strategyType));
        }
예제 #30
0
        /// <summary>
        /// Method to run the strategy specified in the strategyType parameter against the string (or path)
        /// in the sentence parameter
        /// </summary>
        /// <param name="strategyType"> The strategy to be employed </param>
        /// <param name="sentence"> The string (or path) from which accumulated data will be retrieved </param>
        /// <returns> Dictionary of words and their respective counts </returns>
        public Dictionary<string, int> RunStrategy(StrategyType strategyType, string sentence)
        {
            IStrategy strategy;

            switch (strategyType)
            {
                case StrategyType.PrefixTree:
                    strategy = new PrefixTreeStrategy(this._fileService);
                    break;
                default:
                    strategy = new BasicStrategy();
                    break;
            }

            return strategy.Count(sentence);
        }
예제 #31
0
        public StrategyBase Create(StrategyType strategyType)
        {
            switch (strategyType)
            {
            case StrategyType.Default:
                return(new UnknownStrategy());

            case StrategyType.ConnorRsi:
                return(new ConnorRsi());

            case StrategyType.CrossMA:
                return(new CrossMovingAverage());

            default:
                return(new UnknownStrategy());
            }
        }
예제 #32
0
        private PlanningStrategyBase GetStrategyFromType(StrategyType type)
        {
            switch (type)
            {
            case StrategyType.Defensive:
                return(new DefensiveStrategy());

            case StrategyType.Balanced:
                return(new BalancedStrategy());

            case StrategyType.Aggressive:
                return(new AggressiveStrategy());

            default:
                throw new Exception("Unrecognized strategy type.");
            }
        }
예제 #33
0
        public StrategyType GetFallbackStrategy(StrategyType strategyType)
        {
            switch (strategyType)
            {
            case StrategyType.Empty:
                return(StrategyType.Empty);

            case StrategyType.Content:
                return(StrategyType.None);

            case StrategyType.Diff:
                return(StrategyType.Content);

            default:
                return(StrategyType.Content);
            }
        }
예제 #34
0
        public IAppUpdaterStrategy Create(StrategyType type, AppUpdaterContext context)
        {
            switch (type)
            {
            case StrategyType.Empty:
                return(new AppUpdaterEmptyStrategy());

            case StrategyType.Content:
                return(new AppUpdaterContentStrategy(context));

            case StrategyType.Diff:
                return(new AppUpdaterDiffStrategy(context));

            default:
                return(new AppUpdaterContentStrategy(context));
            }
        }
 internal static BlogEditingTemplateStrategy GetTemplateStrategy(StrategyType strategyType)
 {
     switch (strategyType)
     {
         case StrategyType.NoStyle:
             return new NoStyleEditingTemplate();
         case StrategyType.FontsAndPaddingOnly:
             return new WordStyleEditingTemplate();
         case StrategyType.NoSiblings:
             return new ParentElementsOnlyEditingTemplate();
         case StrategyType.Site:
             return new WebsiteEditingTemplate();
         case StrategyType.FramedWysiwyg:
             return new FramedWordStyleEditingTemplate();
         default:
             throw new ArgumentException("Unknown template strategy: " + strategyType.ToString());
     }
 }
        // 執行交易策略
        public string ExecuteStrategy(StrategyType type)
        {
            string procResult;

            // TODO: 這一段未來重構(refactor)時應該要交給工廠物件產生
            switch (type)
            {
                case(StrategyType.GoldenCross):
                    context.SetStrategy(new 黃金交叉Strategy());
                    break;
                case(StrategyType.RSI):
                    context.SetStrategy(new RSI指標Strategy());
                    break;
                default:
                    procResult = string.Empty;
                    break;
            }
            procResult = context.UpdateOnTick();
            
            return procResult;
        }
 public UC_WHControlConfig_VM_Base CreateStrategy(StrategyType type)
 {
     UC_WHControlConfig_VM_Base strategy = null;
     if (type == StrategyType.SmokeStrategy)
     {
         strategy = new UC_WHControlConfig_Smoke_VM(_selectedScreenSN);
     }
     else if (type == StrategyType.TemperatureStrategy)
     {
         strategy = new UC_WHControlConfig_Tem_VM(_selectedScreenSN);
     }
     else if (type == StrategyType.LightStrategy)
     {
         //处理亮度控制初始化
         return null;
     }
     return strategy;
 }
예제 #38
0
파일: Actor.cs 프로젝트: RichieYang/Dotsero
 /// <summary>
 /// Constructs a new type of strategy.
 /// </summary>
 /// <param name="type"></param>
 protected SupervisorStrategy(StrategyType type)
 {
     Type = type;
 }