private int GetNext() { var s1Val = HexHashUtil.GetHexVal(_seed1[_i1]); var s2Val = HexHashUtil.GetHexVal(_seed2[_i2]); var s3Val = HexHashUtil.GetHexVal(_seed3[_i3]); var value = s1Val + s2Val + s3Val; _i1 = (_i1 + 1) % _seed1.Length; _i2 = _i1 == 0 ? (_i2 + 1) % _seed2.Length : _i2; _i3 = _i2 == 0 ? (_i3 + 1) % _seed3.Length : _i3; return(value); }
private int GetNext() { int s1val = HexHashUtil.GetHexVal(seed1[i1]); int s2val = HexHashUtil.GetHexVal(seed2[i2]); int s3val = HexHashUtil.GetHexVal(seed3[i3]); int value = s1val + s2val + s3val; i1 = (i1 + 1) % seed1.Length; i2 = i1 == 0 ? (i2 + 1) % seed2.Length : i2; i3 = i2 == 0 ? (i3 + 1) % seed3.Length : i3; return(value); }
public void GenderTest() { var genderAttr = AttributeBuilder.Create("Gender") .Salted(false).SetPosition(2).SetSize(1).SetCreation(2).SetMaxRange(2).Build(); var dict = new Dictionary <int, int>(); foreach (var b1 in Base58Encoding.Digits.ToCharArray()) { foreach (var b2 in Base58Encoding.Digits.ToCharArray()) { var addr = "M" + b1 + b2 + "KtKS3AeNuRFWE5Qj9tFiNAahWvQMTiz"; var pubMogAddressHex = HexHashUtil.ByteArrayToString(Base58Encoding.Decode(addr)); var hexValue = new HexValue( new Shift(0, 1530914381, pubMogAddressHex, 7234, "00000000090d6c6b058227bb61ca2915a84998703d4444cc2641e6a0da4ba37e", 2, "163d2e383c77765232be1d9ed5e06749a814de49b4c0a8aebf324c0e9e2fd1cf", 1.00m, 0.0001m)); genderAttr.CreateValue(hexValue); var value = genderAttr.GetValue(); var orgValue = HexHashUtil.GetHexVal(pubMogAddressHex[1]); if (dict.TryGetValue(value, out var count)) { dict[value] = count + 1; } else { dict.Add(value, 1); } } } Assert.Equal(2, dict.Count); var enumerator = dict.Keys.GetEnumerator(); enumerator.MoveNext(); Assert.Equal(1, enumerator.Current); enumerator.MoveNext(); Assert.Equal(0, enumerator.Current); Assert.Equal(1692, dict[0]); Assert.Equal(1672, dict[1]); }
/// <summary> /// /// </summary> /// <param name="cuurentLevel"></param> /// <param name="shift"></param> /// <returns></returns> internal double GetExp(int cuurentLevel, Shift shift) { var hexSize = shift.BkHex.Length; var lazyExpLevel = cuurentLevel / 10; var lazyExp = 0; for (var i = 0; i <= lazyExpLevel; i++) { var exPat = _expPats[i % 18]; var indExp = shift.BkHex.IndexOf(exPat, StringComparison.Ordinal); if (indExp != -1) { var charMultiplierA = shift.BkHex[(hexSize + indExp - 1) % hexSize]; var charMultiplierB = shift.BkHex[(indExp + exPat.Length) % hexSize]; var exp = HexHashUtil.GetHexVal(charMultiplierA) * HexHashUtil.GetHexVal(charMultiplierB); lazyExp += exp; } } return(lazyExp); }
/// <summary> /// /// </summary> /// <param name="cuurentLevel"></param> /// <param name="shift"></param> /// <returns></returns> internal double GetExp(int cuurentLevel, Shift shift) { int hexSize = shift.BkHex.Length; int lazyExpLevel = (int)cuurentLevel / 10; int lazyExp = 0; for (int i = 0; i <= lazyExpLevel; i++) { string exPat = expPats[i % 18]; int indExp = shift.BkHex.IndexOf(exPat); if (indExp != -1) { var charMultiplierA = shift.BkHex[(hexSize + indExp - 1) % hexSize]; var charMultiplierB = shift.BkHex[(indExp + exPat.Length) % hexSize]; var exp = HexHashUtil.GetHexVal(charMultiplierA) * HexHashUtil.GetHexVal(charMultiplierB); lazyExp += exp; } } return(lazyExp); }