private static void RecordPassword(SubGenPredictor predictor, string password) { foreach (char ch in password) { var index = Password.AllChars.IndexOf(ch); predictor.CollectNext(index, Password.AllChars.Length); } }
private static void Test() { var random = new Random(42); var random2 = new Random(43); var predictor = new SubGenPredictor(); for (var i = 0; i < 54; ++i) { var value = random.Next(); var value2 = random2.Next(); predictor.CollectNext(new[] { new PossibleValue ( .5M, value ), new PossibleValue ( .5M, value2 ) }); Console.WriteLine(string.Format("{0}\t{1}", value, value2)); } Console.WriteLine(random.Next()); predictor.Skip(); for (var i = 0; i < 115; ++i) { var value = random.Next(); var predicted = predictor.PredictNext(increment: false).ToList(); var predictedStr = string.Join(", ", predicted); Console.WriteLine(string.Format("{0}\t{1}\t{2}", value == predicted.First().LowerBound, value, predictedStr)); predictor.CollectNext(value); } Console.ReadLine(); }
private static void Test2() { var random = new Random(42); var predictor = new SubGenPredictor(); var max = 10; var step = (double)max / Int32.MaxValue; for (var i = 0; i < 55; ++i) { var value = random.Next(max); predictor.CollectNext(value, max); var lastLaggers = string.Join(", ", predictor.LastLaggers); var lastLeaders = string.Join(", ", predictor.LastLeaders); Console.WriteLine(string.Format("{0}:{1}\t{2}\t{3}", i, value, lastLaggers, lastLeaders)); } for (var i = 0; i < 110; ++i) { var value = random.Next(max); var rawPredicted = string.Join(", ", predictor.PredictNext(increment: false)); //.Select(p => $"[{p.LowerBound * step:F2}, {p.UpperBound * step:F2}]")); var predicted = predictor.PredictNext(max, increment: false).ToList(); var predictedStr = string.Join(", ", predicted); Console.WriteLine(string.Format("{0}:{1}\t{2}\t{3}", i, value == predicted.First().LowerBound, value, predictedStr)); //\t{rawPredicted}"); //Console.WriteLine($"{i}\t{value}\t{rawPredicted}"); predictor.CollectNext(value, max); } Console.ReadLine(); }