public void TestGetBestAlgorPrice() { string json = System.IO.File.ReadAllText("miner.json"); MinerModel miners = JsonConvert.DeserializeObject <MinerModel>(json); List <AlgorithmResult> algors = new List <AlgorithmResult>(); List <KeyValuePair <string, string> > paths = new List <KeyValuePair <string, string> >(); AlgorithmResult algorX17 = new AlgorithmResult(); algorX17.name = "x17"; algorX17.Pool = PoolName.Zpool; algorX17.estimate_current = 600; algorX17.estimate_last24h = 700; algors.Add(algorX17); AlgorithmResult algorSkein = new AlgorithmResult(); algorSkein.name = "skein"; algorSkein.Pool = PoolName.Zpool; algorSkein.estimate_current = 500; algorSkein.estimate_last24h = 400; algors.Add(algorSkein); paths.Add(new KeyValuePair <string, string>("x17@zpool", "c:\\miner\\start-t-rex.bat")); miners.Path = paths; string algorAtPool; double price; (algorAtPool, price) = MinerControl.FindBestPrice(algors, true, miners); Assert.AreEqual(0, String.Compare("x17@zpool", algorAtPool, true)); }
public void TestDeserializeMinerControl() { string json = System.IO.File.ReadAllText("miner.json"); MinerModel miners = JsonConvert.DeserializeObject <MinerModel>(json); Assert.AreEqual(true, miners.SwapTime > 0); }
public void MinerModelSimulation_OneStepUpDown() { Dictionary <int, int> bestListCounts = new Dictionary <int, int>(); // Keyed using the hash code. Dictionary <int, IMovieList> bestLists = new Dictionary <int, IMovieList>(); // Keyed using the hash code. ElapsedTime elapsed = new ElapsedTime(); var moviePicker = new MsfMovieSolver { DisplayDebugMessage = false }; var builder = new StringBuilder(); var test = new MinerModel(true, null, null); var defaultWeights = CreateDefaultWeights(); var weights = GenerateWeightLists(new List <int>(), defaultWeights); //foreach (var list in weights) //{ // foreach (var weight in list) // { // builder.Append(weight); // } // builder.Append("\r"); //} //Debug.Write(builder); foreach (var list in weights) { SetWeights(test, list); moviePicker.AddMovies(test.CreateWeightedList()); var best = moviePicker.ChooseBest(); var hashCode = best.GetHashCode(); int value; // Increment (or add to) the best list counts if (bestListCounts.TryGetValue(hashCode, out value)) { bestListCounts[hashCode] = value + 1; } else { bestListCounts.Add(hashCode, 1); bestLists.Add(hashCode, best); } } // Sort through the MOST times a list is counted. foreach (var item in bestListCounts.OrderByDescending(item => item.Value).Take(5)) { Debug.WriteLine($"Number of votes: {bestListCounts[item.Key]}/{weights.Count}"); WriteMovies(bestLists[item.Key]); } }
private void SetWeights(MinerModel model, List <int> weights) { if (weights.Count != MAX_MINERS) { throw new ArgumentException($"The weight list MUST contain {MAX_MINERS} weights."); } int index = TODD_INDEX; foreach (var weight in weights) { model.Miners[index++].Weight = weight; } }
public void TestDoMining() { List <AlgorithmResult> algors = new List <AlgorithmResult>(); List <KeyValuePair <string, string> > paths = new List <KeyValuePair <string, string> >(); string json = System.IO.File.ReadAllText("miner.json"); MinerModel miners = JsonConvert.DeserializeObject <MinerModel>(json); AlgorithmResult algorX17 = new AlgorithmResult(); algorX17.name = "x17"; algorX17.Pool = PoolName.Zpool; algorX17.estimate_current = 600; algorX17.estimate_last24h = 700; algors.Add(algorX17); AlgorithmResult algorSkein = new AlgorithmResult(); algorSkein.name = "skein"; algorSkein.Pool = PoolName.Zpool; algorSkein.estimate_current = 500; algorSkein.estimate_last24h = 400; algors.Add(algorSkein); paths.Add(new KeyValuePair <string, string>("x17@zpool", "C:\\SoftwareMiner\\CryptoDredge_0.9.3\\start-BCD-bcd-zpool.bat")); miners.Path = paths; string bestAlgorAtPool; double bestPrice; (bestAlgorAtPool, bestPrice) = MinerControl.FindBestPrice(algors, true, miners); MinerControl.DoMining(bestAlgorAtPool, miners.Path); System.Threading.Thread.Sleep(12000); AlgorithmResult algorNewGreater = new AlgorithmResult(); algorNewGreater.name = "skein"; algorNewGreater.Pool = PoolName.Zpool; algorNewGreater.estimate_current = 1000; algorNewGreater.estimate_last24h = 1000; algors.Add(algorNewGreater); (bestAlgorAtPool, bestPrice) = MinerControl.FindBestPrice(algors, true, miners); MinerControl.DoMining(bestAlgorAtPool, miners.Path); Assert.AreEqual(true, miners.SwapTime > 0); }
public void TestSerializeMinerControl() { MinerModel miners = new MinerModel(); List <KeyValuePair <string, string> > path = new List <KeyValuePair <string, string> >(); List <string> exclude = new List <string>(); path.Add(new KeyValuePair <string, string>("skein@zpool", @"C:\SoftwareMiner\CryptoDredge_0.9.2\start-BTC-skein-zpool.bat")); path.Add(new KeyValuePair <string, string>("x17@zpool", @"C:\SoftwareMiner\z-enemy.1-16-cuda9.2_x64\start-BTC-x17-zpool.bat")); exclude.Add("x16r@zerg"); exclude.Add("x17@zerg"); miners.SwapTime = 1; miners.UseCurrent = true; miners.Path = path; miners.Exclude = exclude; string json = JsonConvert.SerializeObject(miners); System.IO.File.WriteAllText("miner.json", json); Assert.AreEqual(true, json.Length > 0); }
static void ParseArgument(string[] args) { if (args.Length > 0) { for (int i = 0; i < args.Length; i++) { if (args[i] == "-debug") { _isDebug = true; } else if (args[i] == "-f") { try { _needWriteFile = true; _filename = args[i + 1]; } catch (IndexOutOfRangeException) { Console.WriteLine("please specify a correct filename like -f output.csv"); } } else if (args[i] == "-g") { try { _keepMoreThan = int.Parse(args[i + 1]); } catch (IndexOutOfRangeException) { Console.WriteLine("please specify a valid argument for example -g 100"); return; } catch (FormatException) { Console.WriteLine("please specify a valid argument for example -g 100"); return; } } else if (args[i] == "-help" || args[i] == "-h") { ShowUsage(); return; } else if (args[i] == "-m") { _needMonitor = true; try { _monitorCoin = args[i + 1]; _monitorCoin = _monitorCoin.ToUpper(); } catch (IndexOutOfRangeException) { Console.WriteLine("please specify a valid coin symbol for example -m MANO"); return; } } else if (args[i] == "-t") { _needToShowCoinsNumPerDay = true; } else if (args[i] == "-c") { try { string fiatCurrency = args[i + 1].ToLower(); _fiat = (fiatCurrency == "usd") ? FiatCurrency.USD : FiatCurrency.THB; } catch { Console.WriteLine("please specify a valid parameter -c eg. -c usd or -c baht"); } } else if (args[i] == "-dig") { string minerConfig = ""; try { minerConfig = args[i + 1].ToLower(); string json = System.IO.File.ReadAllText(minerConfig); _miners = JsonConvert.DeserializeObject <MinerModel>(json); _needDig = true; } catch (Exception err) { Console.WriteLine(string.Format("Invalid configuration please verify file {0}. Reason: {1}", minerConfig, err.Message)); Console.WriteLine("Press Enter to exit."); Console.ReadLine(); System.Environment.Exit(-1); } } } } }