public Demo(Map map) { Map = map; Units = 4; Turns = 5; algo = new Algo(); }
void ProcessText() { Scene scene = SceneManager.GetActiveScene(); ItemName = ItemNameIF.text; int.TryParse(XValueIF.text, out XValue); int.TryParse(YValueIF.text, out YValue); int.TryParse(ZValueIF.text, out ZValue); if (scene.name == "CreatingWarehouse") { WarehouseInstance.instance.length = XValue; WarehouseInstance.instance.width = YValue; WarehouseInstance.instance.height = ZValue; WarehouseInstance.instance.setWarehouse(); Algo.initWarehouse(XValue, YValue, ZValue); Debug.Log("Warehouse"); } else if (scene.name == "NewItem") { Algo.Item NewItem = new Algo.Item(ItemName, XValue, YValue, ZValue); Algo.addItem(NewItem); Debug.Log(NewItem.Name); // Algo.printWarehouse(); } }
public void Algo_should_return_multiple_double_options_with_min_current() { //Arrange decimal capacity = 10; var chargeGroup = new ChargeGroup(Guid.Empty, "", capacity, null); var chargeStation = new ChargeStation(Guid.NewGuid(), "", chargeGroup); chargeGroup.AddChargeStation(chargeStation); var expectedConnectorId_1 = 9; var expectedConnectorId_2 = 8; var expectedConnectorId_3 = 5; chargeStation.AddConnector(0.4m, expectedConnectorId_1); chargeStation.AddConnector(0.5m, expectedConnectorId_2); chargeStation.AddConnector(0.9m, expectedConnectorId_3); chargeStation.AddConnector(2); chargeStation.AddConnector(3); var needToFree = 0.9m; //Act var result = new Algo().FindOptions(chargeGroup, needToFree); //Assert result.Count.ShouldBe(2); //0.4 + 0.5 result.Find(l => l.Exists(c => c.ConnectorId == expectedConnectorId_1)).Count.ShouldBe(2); result.Find(l => l.Exists(c => c.ConnectorId == expectedConnectorId_1)) .Find(c => c.ConnectorId == expectedConnectorId_1).Amps.ShouldBe(0.4m); result.Find(l => l.Exists(c => c.ConnectorId == expectedConnectorId_1)) .Find(c => c.ConnectorId == expectedConnectorId_2).Amps.ShouldBe(0.5m); //0.9 result.Find(l => l.Exists(c => c.ConnectorId == expectedConnectorId_3)).Count.ShouldBe(1); result.Find(l => l.Exists(c => c.ConnectorId == expectedConnectorId_3)).FirstOrDefault().Amps.ShouldBe(0.9m); }
public void Algo_should_return_multiple_single_options_with_min_current() { //Arrange decimal capacity = 10; var chargeGroup = new ChargeGroup(Guid.Empty, "", capacity, null); var chargeStation = new ChargeStation(Guid.NewGuid(), "", chargeGroup); chargeGroup.AddChargeStation(chargeStation); var expectedConnectorId = 9; chargeStation.AddConnector(1, expectedConnectorId); chargeStation.AddConnector(1); chargeStation.AddConnector(2); chargeStation.AddConnector(2); chargeStation.AddConnector(3); var needToFree = 0.9m; //Act var result = new Algo().FindOptions(chargeGroup, needToFree); //Assert result.Count.ShouldBe(2); result[0].Count.ShouldBe(1); result[1].Count.ShouldBe(1); result.Find(c => c[0].ConnectorId == expectedConnectorId)[0].Amps.ShouldBe(1); result.Find(c => c[0].ConnectorId != expectedConnectorId)[0].Amps.ShouldBe(1); }
private void OnGUI() { if (!m_displayGUI) return; GUILayout.BeginVertical ("Box"); GUILayout.BeginHorizontal (); GUILayout.Label ("Algo : " + algo.ToString () + "\nKernelSize : " + quality.ToString ()); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); if (GUILayout.Button ("NAIVE")) algo = Algo.NAIVE; if (GUILayout.Button ("TWO_PASS")) algo = Algo.TWO_PASS; if (GUILayout.Button ("TWO_PASS_LINEAR_SAMPLING")) algo = Algo.TWO_PASS_LINEAR_SAMPLING; GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); if (GUILayout.Button ("LITTLE_KERNEL")) quality = Quality.LITTLE_KERNEL; if (GUILayout.Button ("MEDIUM_KERNEL")) quality = Quality.MEDIUM_KERNEL; if (GUILayout.Button ("BIG_KERNEL")) quality = Quality.BIG_KERNEL; GUILayout.EndHorizontal (); GUILayout.EndVertical (); if (GUI.changed) Init (); }
public async Task <SelectedSymbolsChanges> UpdateAsync(TimeSlice slice) { if (NextSwapTime < Algo.Market.Time) { NextSwapTime = Algo.Market.Time + UpdatePeriod; var filtered = OnUpdate(slice); var removedSymbols = (from sym in _SymbolsSelected.Values where !filtered.Any(s => s.Key == sym.Key) select sym) .ToArray(); var added = (from sym in filtered where !_SymbolsSelected.ContainsKey(sym.Key) select sym).ToArray(); //remove unused symbols foreach (var sym in removedSymbols) { _SymbolsSelected.Remove(sym.Key); } //add new symbols foreach (var sym in added) { ISymbolFeed feed = await Algo.GetSymbolFeed(sym.Key); _SymbolsSelected.Add(feed.Symbol.Key, feed.Symbol as SymbolInfo); } var retVal = new SelectedSymbolsChanges(added.ToArray(), removedSymbols.ToArray()); return(retVal); } return(SelectedSymbolsChanges.None); }
// ---------------------------------------------- // // ------------ MonoBehavior Component ---------- // // ---------------------------------------------- // private void Awake() { // UI setup Algo algo = GetComponent <Algo>(); GameObject.Find("Button_FastestPath").GetComponent <Button>().onClick.AddListener(RunFastestPath); GameObject.Find("Button_Exploration").GetComponent <Button>().onClick.AddListener(delegate { RunExploration(false); }); GameObject.Find("Button_ExplorationTest").GetComponent <Button>().onClick.AddListener(delegate { RunExploration(true); }); GameObject.Find("Button_Image").GetComponent <Button>().onClick.AddListener(RunImageRecognition); GameObject.Find("Button_RPI").GetComponent <Button>().onClick.AddListener(ConnectToRPI); GameObject.Find("Button_Calibrate_Start").GetComponent <Button>().onClick.AddListener(CalibrateStart); //GameObject.Find("Button_Calibrate_Start").GetComponent<Button>().onClick.AddListener(LoadMapFromFile); sliderCoverage = GameObject.Find("Slider_Coverage").GetComponent <Slider>(); sliderInterval = GameObject.Find("Slider_Interval").GetComponent <Slider>(); toggleDiagonal = GameObject.Find("Toggle_Diagonal").GetComponent <Toggle>(); toggleTemp = GameObject.Find("Toggle_Temp").GetComponent <Toggle>(); inputTimeLimit = GameObject.Find("InputField_TimeLimit").GetComponent <InputField>(); sliderCoverage.onValueChanged.AddListener(delegate { ValueChangeCoverage(); }); sliderInterval.onValueChanged.AddListener(delegate { ValueChangeInterval(); }); inputTimeLimit.onEndEdit.AddListener(delegate { ValueChangeTimeLimit(); }); toggleDiagonal.onValueChanged.AddListener(delegate { ToggleDiagonal(); }); toggleTemp.onValueChanged.AddListener(delegate { ToggleTemp(); }); Arena.gridCubesContainer = GameObject.Find("GridCubes").transform; Arena.gridCubeWallsContainer = GameObject.Find("GridCubeWalls").transform; Arena.gridPrefab = gridPrefab; Arena.robotPrefab = robotPrefab; Arena.gridEmpty = gridEmpty; Arena.gridVirtualWall = gridVirtualWall; Arena.gridUnexplored = gridUnexplored; }
public void DoGUI() { selectedGame = RGUI.Field(selectedGame, "Game"); selectedAlgo = RGUI.Field(selectedAlgo, "Algo"); if (selectedAlgo == Algo.MonteCarlo) { GUILayout.Label("Disable ES for more options."); mcES = RGUI.Field(mcES, "ES"); if (!mcES) { mcOnPolicy = RGUI.Field(mcOnPolicy, "On/Off Policy"); mcFirstVisit = RGUI.Field(mcFirstVisit, "First/Every Visit"); } } if (selectedGame == Game.Sokoban) { selectedSokobanLevel = RGUI.Field(selectedSokobanLevel, "Level"); } if (elapsedMs != -1) { GUILayout.Label("In " + elapsedMs + " milliseconds"); } }
public static Challenge GetRandomChallenge(Fight Fight) { var c = TemplateList.Select(t => t.Value).ToArray(); var rnd = Algo.Random(0, c.Count() - 1); return((Challenge)Activator.CreateInstance(c[rnd], Fight)); }
public void Algo_should_return_connector_with_min_current() { //Arrange decimal capacity = 10; var chargeGroup = new ChargeGroup(Guid.Empty, "", capacity, null); var chargeStation = new ChargeStation(Guid.NewGuid(), "", chargeGroup); chargeGroup.AddChargeStation(chargeStation); var expectedConnectorId = 9; chargeStation.AddConnector(1, expectedConnectorId); chargeStation.AddConnector(1.5m); chargeStation.AddConnector(2); chargeStation.AddConnector(2); chargeStation.AddConnector(3); var needToFree = 1.0m; //Act var result = new Algo().FindOptions(chargeGroup, needToFree); //Assert result.Count.ShouldBe(1); result.FirstOrDefault().Count.ShouldBe(1); result.FirstOrDefault().FirstOrDefault().ConnectorId.ShouldBe(expectedConnectorId); result.FirstOrDefault().FirstOrDefault().Amps.ShouldBe(1); result.FirstOrDefault().FirstOrDefault().StationId.ShouldBe(chargeStation.Id); }
/// <summary> /// Returns true if Key instances are equal /// </summary> /// <param name="other">Instance of Key to be compared</param> /// <returns>Boolean</returns> public bool Equals(Key other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Status == other.Status || Status != null && Status.Equals(other.Status) ) && ( Algo == other.Algo || Algo != null && Algo.SequenceEqual(other.Algo) ) && ( Len == other.Len || Len != null && Len.Equals(other.Len) ) && ( Curve == other.Curve || Curve != null && Curve.Equals(other.Curve) )); }
public override void Initialize() { var res = TimeSpan.FromHours(1); if (VOL_PROTECT) { AddEquity("VIXM", Resolution.Hour); } foreach (var s in symbols) { AddEquity(s, Resolution.Minute).SetLeverage(2); pfe[s] = new PolarisedFractalEfficiency(); Algo.RegisterIndicator(s, pfe[s], res); ppfe[s] = 0; eit[s] = new EhlerInstantaneousTrend(); Algo.RegisterIndicator(s, eit[s], res); pvalue[s] = 0; activate[s] = false; // if (riskProtectSymbols.Contains(s)) // { // prevPerf[s] = 1; // reference[s] = 1; // _pfeReference[s] = new PolarisedFractalEfficiency(); // } } }
private void AlgoLookupSubscription_OnData(object sender, AlgoLookupEventArgs e) { if (e.Event == ProductDataEvent.Found) { Console.WriteLine("Algo Instrument Found: {0}", e.AlgoLookup.Algo.Alias); m_algo = e.AlgoLookup.Algo; // Create an Algo TradeSubscription to listen for order / fill events only for orders submitted through it m_algoTradeSubscription = new AlgoTradeSubscription(tt_net_sdk.Dispatcher.Current, m_algo); m_algoTradeSubscription.OrderUpdated += new EventHandler <OrderUpdatedEventArgs>(m_algoTradeSubscription_OrderUpdated); m_algoTradeSubscription.OrderAdded += new EventHandler <OrderAddedEventArgs>(m_algoTradeSubscription_OrderAdded); m_algoTradeSubscription.OrderDeleted += new EventHandler <OrderDeletedEventArgs>(m_algoTradeSubscription_OrderDeleted); m_algoTradeSubscription.OrderFilled += new EventHandler <OrderFilledEventArgs>(m_algoTradeSubscription_OrderFilled); m_algoTradeSubscription.OrderRejected += new EventHandler <OrderRejectedEventArgs>(m_algoTradeSubscription_OrderRejected); m_algoTradeSubscription.OrderBookDownload += new EventHandler <OrderBookDownloadEventArgs>(m_algoTradeSubscription_OrderBookDownload); m_algoTradeSubscription.Start(); } else if (e.Event == ProductDataEvent.NotAllowed) { Console.WriteLine("Not Allowed : Please check your Token access"); } else { // Algo Instrument was not found and TT API has given up looking for it Console.WriteLine("Cannot find Algo instrument: {0}", e.Message); Dispose(); } }
private void Button_Click(object sender, RoutedEventArgs e) { var s = System.IO.Path.GetFileNameWithoutExtension(ShowPath); Algo.Name = s; Algo.Remesh1(); }
private static void HandleIndexStyles(MethodCall[] methodCalls, Algo algo, ParsingErrors parsingErrors) { var setIndexStyleCalls = methodCalls.Where(call => call.MethodName == "SetIndexStyle"); var indexesStyles = new Dictionary <int, DrawingShapeStyle>(); foreach (var methodCall in setIndexStyleCalls) { int index; if (!int.TryParse(methodCall.Parameters[0], out index)) { parsingErrors.Add(ErrorType.NotSupportedWarning, "SetIndexStyle", "Can't cast to int: " + methodCall.Parameters[0]); continue; } var drawingShapeStyle = methodCall.Parameters[1].ToDrawingShapeStyle(); indexesStyles[index] = drawingShapeStyle; if (methodCall.Parameters.Length >= 4) { int width; if (int.TryParse(methodCall.Parameters[3], out width)) { algo.Widths[index] = width; } } } foreach (var keyValuePair in indexesStyles) { algo.Styles[keyValuePair.Key] = keyValuePair.Value; } }
public Small(Map m) { Map = m; Units = 6; Turns = 20; algo = new Algo(); }
// Menreturn string yang berisi alur dari Awal ke Tujuan (saat ini masih DFS saja) public Tuple <string, int> alur(string awal, string tujuan, Algo algo) { List <string> alurnya; if (algo == Algo.DFS) { alurnya = DFS(awal, tujuan); } else { alurnya = BFSAlur(awal, tujuan); } if (!alurnya.Contains(tujuan)) { return(Tuple.Create("Tidak Bisa Terhubung ke " + tujuan, 0)); } string str = "Cara menuju " + tujuan + ":"; foreach (var friend in alurnya) { str += " " + friend; } int degree = alurnya.Count() - 2; return(Tuple.Create(str, degree)); }
public Standard(Map map) { Map = map; Units = 8; Turns = 30; algo = new Algo(); }
public Algorithm(string title, string code, string pseudo, Algo algorithm) { Title = title; Code = code; Pseudo = pseudo; this.algo = algorithm; }
public static void Main(string[] args) { NakedNode[][] nodes = new NakedNode[5][]; nodes[0] = new NakedNode[1]; nodes[1] = new NakedNode[2]; nodes[2] = new NakedNode[3]; nodes[3] = new NakedNode[4]; nodes[4] = new NakedNode[5]; nodes[0][0] = new NakedNode(5, "A"); nodes[1][0] = new NakedNode(7, "B"); nodes[1][1] = new NakedNode(2, "C"); nodes[2][0] = new NakedNode(4, "D"); nodes[2][1] = new NakedNode(8, "E"); nodes[2][2] = new NakedNode(3, "F"); nodes[3][0] = new NakedNode(2, "G"); nodes[3][1] = new NakedNode(6, "H"); nodes[3][2] = new NakedNode(9, "I"); nodes[3][3] = new NakedNode(4, "J"); nodes[4][0] = new NakedNode(7, "K"); nodes[4][1] = new NakedNode(2, "L"); nodes[4][2] = new NakedNode(5, "M"); nodes[4][3] = new NakedNode(3, "N"); nodes[4][4] = new NakedNode(6, "O"); Algo algorithm = new Algo(); algorithm.Run(nodes); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Status != null) { hashCode = hashCode * 59 + Status.GetHashCode(); } if (Algo != null) { hashCode = hashCode * 59 + Algo.GetHashCode(); } if (Len != null) { hashCode = hashCode * 59 + Len.GetHashCode(); } if (Curve != null) { hashCode = hashCode * 59 + Curve.GetHashCode(); } return(hashCode); } }
private void HandleFunctions(string code, Algo algo, ParsingErrors parsingErrors) { var withoutProperties = code.RemoveMq4Properies(); var mq4Functions = FunctionsParser.Parse(withoutProperties).ToArray(); algo.Code.Functions = mq4Functions.ToList(); HandleInit(algo, mq4Functions, parsingErrors); }
public Bundle(String name, Algo algo, Double hashrate, Double est, int type) { this.Name = name; this.Mining = true; this.Algo = algo; this.Hashrate = hashrate; this.Estimates = est; this.Type = type; }
public FixedRiskMoneyManager(IAccount account, Algo algo, double oneDayMaxLoss, double risk) : base(account, algo, oneDayMaxLoss) { if (risk < 0) { throw new Exception(string.Format("risk is negtive, risk={0}", risk)); } this.risk = risk; }
public SimplerAES(Algo UserChoiceAlgo, byte[] InnerK, byte[] InnerV) { AlgorithmChoice = UserChoiceAlgo; if (AlgorithmChoice == Algo.AES128CBC128) { rm = new RijndaelManaged(); kSize = 128; vSize = 128; rm.KeySize = kSize; rm.BlockSize = vSize; rm.Mode = CipherMode.CBC; mkey = InnerK; mvector = InnerV; encryptor = rm.CreateEncryptor(mkey, mvector); decryptor = rm.CreateDecryptor(mkey, mvector); encoder = new UTF8Encoding(); } else if (AlgorithmChoice == Algo.AES256CBC128) { rm = new RijndaelManaged(); kSize = 256; vSize = 128; rm.KeySize = kSize; rm.BlockSize = vSize; rm.Mode = CipherMode.CBC; mkey = InnerK; mvector = InnerV; encryptor = rm.CreateEncryptor(mkey, mvector); decryptor = rm.CreateDecryptor(mkey, mvector); encoder = new UTF8Encoding(); } else if (AlgorithmChoice == Algo.AES256CBC256) { rm = new RijndaelManaged(); kSize = 256; vSize = 256; rm.KeySize = kSize; rm.BlockSize = vSize; rm.Mode = CipherMode.CBC; mkey = InnerK; mvector = InnerV; encryptor = rm.CreateEncryptor(mkey, mvector); decryptor = rm.CreateDecryptor(mkey, mvector); encoder = new UTF8Encoding(); } else if (AlgorithmChoice == Algo.AES256CFB128) { rm = new RijndaelManaged(); kSize = 256; vSize = 128; rm.KeySize = kSize; rm.BlockSize = vSize; rm.Mode = CipherMode.CFB; mkey = InnerK; mvector = InnerV; encryptor = rm.CreateEncryptor(mkey, mvector); decryptor = rm.CreateDecryptor(mkey, mvector); encoder = new UTF8Encoding(); } }
public static bool Piv_Helper(List <double> ClosePrices, int HiLo = -1) { var res = Algo.Pivot(ClosePrices, HiLo); if (res != (-1, -1.0)) { return(true); } return(false); }
public override PlayerAction GetSkill(Chara source, List <Chara> allChara) { skill = new Algo(); skill.source = source; skill.level = skillLevel; skill.duration = duration; skill.needTarget = true; skill.mpCost = mpCost + (skillLevel - 1); return(skill); }
public static void Main88(string[] args) { string st1 = "hello, world!"; string st2 = "world"; Algo algo = new Algo(); Console.WriteLine("BruteForceSearch return : " + algo.BruteForceSearch(st1, st2)); Console.WriteLine("RobinKarp return : " + algo.RobinKarp(st1, st2)); Console.WriteLine("KMP return : " + algo.KMP(st1, st2)); }
// Token: 0x0600008A RID: 138 RVA: 0x00005834 File Offset: 0x00003A34 public virtual bool AssetProperty(Algo instance, PrototypeSerializerManager token, IEnumerable <SystemReponseAnnotation> field, IEnumerable <IndexerItemResolver> var12, IEnumerable <string> visitor3, IEnumerable <StructPolicySchema> reference4) { bool flag = this.ListProperty(instance); bool flag2 = this.ListProperty(token); bool flag3 = this.AddProperty(field); bool flag4 = this.FillProperty(var12); bool flag5 = this.RunProperty(visitor3); bool flag6 = this.WriteProperty(reference4); return(flag || flag2 || flag3 || flag4 || flag5 || flag6); }
public void FindGCDEuclidTest() { int a = 2806; int b = 345; int expected = 23; int actual; long time = 0; Algo Algo = new Algo(); actual = Algo.FindGCDEuclid(a, b, out time); Assert.AreEqual(expected, actual); }
private void Optimize() { Invoke(new Action(() => { LockControls(); timer.Start(); ElapsedTime = new TimeSpan(0); EsitmatedTime = new TimeSpan(0); startDateTime = DateTime.Now; })); Algo.StartOptimization(); }
private static void Test(int count, int k, Algo algo, int b = 65536) { Console.WriteLine("Test " + algo + " on " + count + " elements, k = " + k + " b = " + b); // always produce the same pseudo-random numbers m_z = 6531; m_w = 1365801; System.IO.StreamWriter file = new System.IO.StreamWriter("result.txt", true); var before = DateTime.UtcNow; IList <uint> list; switch (algo) { case Algo.List: list = new List <uint>(count); break; case Algo.External: list = new ExternalMemoryList <uint>("directory", count / k); break; default: list = new KMerge <uint>("directory", k, b); break; } for (int i = 0; i < count; i++) { list.Add(get_random()); } var then = DateTime.UtcNow; if (list is List <uint> ) { (list as List <uint>).Sort(); } else { (list as ExternalMemoryList <uint>).Sort(); } var now = DateTime.UtcNow; Console.WriteLine("===" + list.ToString() + " on " + count + " elements:"); Console.WriteLine("All:" + (now - before)); Console.WriteLine("Sort: " + (now - then)); Console.WriteLine("==================================="); file.WriteLine("===" + list.ToString() + " on " + count + " elements:"); file.WriteLine("All:" + (now - before)); file.WriteLine("Sort: " + (now - then)); file.WriteLine("==================================="); file.Close(); }
static void Main(string[] args) { var startingTags = new[] { "trip-hop" } .Select(t => new Node(t, FSharpOption<IDictionary<Node, int>>.None)); var q = new Algo("ff03f5b2e6d5c55b4c0b74b8e203bb7c", "64804b95f74e40b3b968304c59d97c08", 5); q.fillGraphAsync(startingTags.First(), 3).Wait(); Console.ReadLine(); }
public DrawAPI GetAPI(Algo apiname) { return APIList[apiname] as DrawAPI; }
private void AlgoBox_SelectedIndexChanged(object sender, EventArgs e) { AlgorithmChoice = (Algo)AlgoBox.SelectedIndex; if (AlgorithmChoice == Algo.AES128CBC128) { kSize = 16; vSize = 16; randarrays_Click(sender, e); } else if (AlgorithmChoice == Algo.AES256CBC128) { kSize = 32; vSize = 16; randarrays_Click(sender, e); } else if (AlgorithmChoice == Algo.AES256CBC256) { kSize = 32; vSize = 32; randarrays_Click(sender, e); } else if (AlgorithmChoice == Algo.AES256CFB128) { kSize = 32; vSize = 16; randarrays_Click(sender, e); } /*else if (AlgorithmChoice == Algo.ECDH512) { //the below three are busted for XP, intentional gimping by MS, only work for Vista and up myAES = new SimplerAES((AES256.SimplerAES.Algo)Algo.ECDH512, true); } else if (AlgorithmChoice == Algo.ECDH384) { myAES = new SimplerAES((AES256.SimplerAES.Algo)Algo.ECDH384, true); } else if (AlgorithmChoice == Algo.ECDH256) { myAES = new SimplerAES((AES256.SimplerAES.Algo)Algo.ECDH256, true); }*/ InitArrayBoxes(); CheckCounts(); }