示例#1
0
        public void Rnd_Unit_ReturnsExpectedSequence()
        {
            ResetSeed();

            float actual1   = VBMath.Rnd();
            float expected1 = 0.7055475f;

            Assert.Equal(expected1, actual1);

            float actual2   = VBMath.Rnd();
            float expected2 = 0.533424f;

            Assert.Equal(expected2, actual2);

            float actual3   = VBMath.Rnd();
            float expected3 = 0.5795186f;

            Assert.Equal(expected3, actual3);

            float actual4   = VBMath.Rnd();
            float expected4 = 0.289562464f;

            Assert.Equal(expected4, actual4);

            float actual5   = VBMath.Rnd();
            float expected5 = 0.301948f;

            Assert.Equal(expected5, actual5);
        }
示例#2
0
        public static ISymbol GetASymbolBySymbolType(string SymbolType, IColor aColor)
        {
            if (aColor == null)
            {
                IRgbColor pRgbColor;
                aColor        = new RgbColorClass();
                pRgbColor     = (IRgbColor)aColor;
                pRgbColor.RGB = Information.RGB((int)(VBMath.Rnd(1) * 255), (int)(VBMath.Rnd(1) * 255), (int)(VBMath.Rnd(1) * 255));
            }

            switch (SymbolType)
            {
            case "面状地物符号":
                ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass();
                pFillSymbol.Color = aColor;
                return((ISymbol)pFillSymbol);

            case "线状地物符号":
                ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
                pLineSymbol.Width = 1;
                pLineSymbol.Color = aColor;
                return((ISymbol)pLineSymbol);

            case "点状地物符号":
                IMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();
                pMarkerSymbol.Color = aColor;
                return((ISymbol)pMarkerSymbol);

            default:
                return(null);
            }
        }
        /// <summary>
        /// Method to get coupon id
        /// </summary>
        /// <returns></returns>
        private string GetCouponId()
        {
            string strPrefix = "";
            string strCoupon = "";

            bool found = false;


            strPrefix = DateAndTime.Today.ToString("MMddyy") + "100"; //Date + TillID
            found     = false;
            while (!found)
            {
                var strNum = Conversion.Int(29999 * VBMath.Rnd()).ToString("00000");
                strCoupon = strPrefix + strNum.Trim();
                if (_fuelService.IsExistingCoupon(strCoupon))
                {
                    found = true;
                    break;
                }
                strNum = "";
            }
            var returnValue = strCoupon;

            return(returnValue);
        }
示例#4
0
        private void BeginButton_Click(object sender, EventArgs e)
        {
            //Hide buttons
            BeginButton.Visible      = false;
            QuitButton.Visible       = false;
            DescriptionLabel.Visible = false;

            player.Visible     = true; // show the player
            speed              = 2;    // controls speed of game, will increase as game progresses
            scorelabel.Visible = true; // show score label
            bonusesfound       = 0;

            //Make sure all objects are in the correct position
            object_small.Location  = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), 300);
            object_small2.Location = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), 49);
            object_mid.Location    = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), 377);
            object_mid2.Location   = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), 140);
            object_large.Location  = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), 214);
            PicBonus.Location      = new Point(((int)Math.Ceiling(VBMath.Rnd() * pgcontents.Width)), -20);

            //Reset time
            time = 0;

            usingkeys = false;

            System.Threading.Thread.Sleep(100); // slight delay before game starts (in milliseconds)

            main();                             // start the main game function

            //sig() //infobox sigs -COMMENT THIS OUT
        }
示例#5
0
        public void Rnd_Negative_ReturnsExpected(float input, float expected)
        {
            ResetSeed();
            float actual = VBMath.Rnd(input);

            Assert.Equal(expected, actual);
        }
示例#6
0
        public byte[] XOREncrypt(byte[] up, string BB2)
        {
            byte[] bytes = Encoding.ASCII.GetBytes(BB2);
            VBMath.Randomize();
            int num = Convert.ToInt32(256f * VBMath.Rnd()) + 1;

            byte[] array = new byte[up.Length + 1];
            int    num2  = 0;

            for (int i = 0; i <= up.Length - 1; i++)
            {
                byte[] array2 = array;
                int    num3   = i;
                array2[num3] += Convert.ToByte((int)(up[i] ^ bytes[num2]) ^ num);
                if (num2 == BB2.Length - 1)
                {
                    num2 = 0;
                }
                else
                {
                    num2++;
                }
            }
            array[up.Length] = Convert.ToByte(112 ^ num);
            return(array);
        }
示例#7
0
        public string Return_EncryptDate(DateTime DT)
        {
            string returnValue = "";
            string str_Renamed = "";
            short  i           = 0;
            string DL          = "";

            //    str = Format(DT, "mm/dd/yyyy")
            ///changed by nancy
            str_Renamed = DateAndTime.Month(DT).ToString("00") + "/" +
                          DateAndTime.Day(DT).ToString("00") + "/" +
                          DateAndTime.Year(DT).ToString("0000");

            for (i = 1; i <= 10; i++)
            {
                DL = DL + System.Convert.ToString(Strings.Asc(str_Renamed.Substring(i - 1, 1)) + 7);
            }

            for (i = 1; i <= 10; i++)
            {
                VBMath.Randomize();
                DL = (VBMath.Rnd() * VBMath.Rnd() * i * 5).ToString("00") + DL;
            }

            for (i = 1; i <= 10; i++)
            {
                VBMath.Randomize();
                DL = DL + (VBMath.Rnd() * VBMath.Rnd() * i * 5).ToString("00"); //Format(Rnd() + i * i + (i * Rnd()) / i, "00")
            }

            returnValue = DL;

            return(returnValue);
        }
示例#8
0
        public static void On_SMSG_AUTH_CHALLENGE(ref Packets.PacketClass Packet)
        {
            Console.WriteLine("[{0}][World] Received Auth Challenge.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
            WS_WardenClient.InitWarden();
            Worldserver.ServerSeed = Packet.GetUInt32();
            var temp = Encoding.ASCII.GetBytes(Realmserver.Account.ToCharArray());

            temp = Realmserver.Concat(temp, BitConverter.GetBytes(0));
            temp = Realmserver.Concat(temp, BitConverter.GetBytes(Worldserver.ClientSeed));
            temp = Realmserver.Concat(temp, BitConverter.GetBytes(Worldserver.ServerSeed));
            temp = Realmserver.Concat(temp, Realmserver.SS_Hash);
            var algorithm1 = new SHA1Managed();
            var ShaDigest  = algorithm1.ComputeHash(temp);

            Worldserver.Decoding = true;
            VBMath.Randomize();
            Worldserver.ClientSeed = (uint)(uint.MaxValue * VBMath.Rnd());
            var Response = new Packets.PacketClass(OPCODES.CMSG_AUTH_SESSION);

            Response.AddInt32(Realmserver.Revision);
            Response.AddInt32(0); // SessionID?
            Response.AddString(Realmserver.Account.ToUpper());
            Response.AddUInt32(Worldserver.ClientSeed);
            Response.AddByteArray(ShaDigest);
            Response.AddInt32(0); // Addon size
            Worldserver.Send(Response);
            Response.Dispose();
            Worldserver.Encoding = true;
        }
示例#9
0
        //TODO: CmdSet_Click
        private void CmdSet_Click(object sender, EventArgs e)
        {
            swSelMgr = swModel.SelectionManager;
            if (swSelMgr.GetSelectedObjectCount() == 1) // Проверка выделения
            {
                if (swSelMgr.GetSelectedObjectType(1) == 15)
                {
                    if (m2 == 1)
                    {
                        VBMath.Randomize();
                        oldNoteName = "NN" + Strings.LTrim(Convert.ToString(VBMath.Rnd() * 100));
                        //Debug.Print(oldNoteName);
                        ok = swNote.SetName(oldNoteName);
                    }

                    swNote = swSelMgr.GetSelectedObject2(1);
                    ok     = swNote.SetName(newNoteName);
                    Start();
                }
                else
                {
                    MessageBox.Show("Необходимо выделить заметку");
                }
            }
            else
            {
                MessageBox.Show("Выделите одну заметку...");
            }
        }
示例#10
0
    public static string GetNewKey(string Kind)
    {
        VBMath.Randomize();
        int intRandomNumber = (int)VBMath.Rnd() * 100000;

        return(Kind + DateTime.Now.ToString("yyyyMMddHHmmss") + DateTime.Now.Millisecond.ToString("000") + intRandomNumber.ToString());
    }
示例#11
0
文件: Cell.cs 项目: mitko0/Maze
        public Cell getNeighbor()
        {
            List <Cell> c = new List <Cell>();

            if (!(NeighborNorthID == "none") && Cells[NeighborNorthID].Visited == false)
            {
                c.Add(Cells[NeighborNorthID]);
            }
            if (!(NeighborSouthID == "none") && Cells[NeighborSouthID].Visited == false)
            {
                c.Add(Cells[NeighborSouthID]);
            }
            if (!(NeighborEastID == "none") && Cells[NeighborEastID].Visited == false)
            {
                c.Add(Cells[NeighborEastID]);
            }
            if (!(NeighborWestID == "none") && Cells[NeighborWestID].Visited == false)
            {
                c.Add(Cells[NeighborWestID]);
            }
            int  max         = c.Count;
            Cell currentCell = null;

            if (c.Count > 0)
            {
                Microsoft.VisualBasic.VBMath.Randomize();
                int index = Convert.ToInt32(Conversion.Int(c.Count * VBMath.Rnd()));
                currentCell = c[index];
            }
            return(currentCell);
        }
示例#12
0
            /// GENERATES A RANDOM STRING OF LETTERS AND NUMBERS.
            /// LETTERS CAN BE RANDOMLY CAPITAL OR SMALL. RETURNS THERANDOMLY GENERATED KEY</returns>
            public string Generate()
            {
                int    i_key;
                float  Random1;
                short  arrIndex;
                var    sb = new StringBuilder();
                string RandomLetter;

                /// CONVERT LettersArray & NumbersArray TO CHARACTR ARRAYS
                LettersArray = Key_Letters.ToCharArray();
                NumbersArray = Key_Numbers.ToCharArray();
                var loopTo = Key_Chars;

                for (i_key = 1; i_key <= loopTo; i_key++)
                {
                    /// START THE CLOCK    - LAITH - 27/07/2005 18:01:18 -
                    VBMath.Randomize();
                    Random1  = VBMath.Rnd();
                    arrIndex = -1;
                    /// IF THE VALUE IS AN EVEN NUMBER WE GENERATE A LETTER,
                    /// OTHERWISE WE GENERATE A NUMBER
                    /// THE NUMBER '111' WAS RANDOMLY CHOSEN. ANY NUMBER
                    /// WILL DO, WE JUST NEED TO BRING THE VALUE
                    /// ABOVE '0'
                    if (Conversions.ToInteger(Random1 * 111) % 2 == 0)
                    {
                        /// GENERATE A RANDOM INDEX IN THE LETTERS
                        /// CHARACTER ARRAY
                        while (arrIndex < 0)
                        {
                            arrIndex = Convert.ToInt16(LettersArray.GetUpperBound(0) * Random1);
                        }
                        RandomLetter = Conversions.ToString(LettersArray[arrIndex]);
                        /// CREATE ANOTHER RANDOM NUMBER. IF IT IS ODD,
                        /// WE CAPITALIZE THE LETTER
                        if (Conversions.ToInteger(arrIndex * Random1 * 99) % 2 != 0)
                        {
                            RandomLetter = LettersArray[arrIndex].ToString();
                            RandomLetter = RandomLetter.ToUpper();
                        }

                        sb.Append(RandomLetter);
                    }
                    else
                    {
                        /// GENERATE A RANDOM INDEX IN THE NUMBERS
                        /// CHARACTER ARRAY
                        while (arrIndex < 0)
                        {
                            arrIndex = Convert.ToInt16(NumbersArray.GetUpperBound(0) * Random1);
                        }
                        sb.Append(NumbersArray[arrIndex]);
                    }
                }

                return(sb.ToString());
            }
示例#13
0
        public static string t4_Random_Number_16bit()
        {
            string s;

            int Reference = System.Convert.ToInt32(VBMath.Rnd(1) * 65536); //16bit Reference Number 'See 3GPP Document

            s = Strings.Format(Reference, "X4");;

            return(s);
        }
示例#14
0
        public void Rnd_Positive_EqualsRndUnit(float positive)
        {
            ResetSeed();
            float actual = VBMath.Rnd(positive);

            ResetSeed();
            float expected = VBMath.Rnd();

            Assert.Equal(expected, actual);
        }
 public void generates_same_results_as_VB6(int seed, float[] values)
 {
     VBMath.Rnd(-1);
     VBMath.Randomize(seed);
     float[] results = new float[values.Length];
     for (int index = 0; index < results.Length; index++)
     {
         results[index] = VBMath.Rnd();
     }
     CollectionAssert.AreEqual(values, results, new FloatEpsilonComparer(0.0000001f));
 }
示例#16
0
        public void Rnd_1()
        {
            object resObj;
            string tmpStr;

            VBMath.Randomize();
            resObj = VBMath.Rnd(13);
            tmpStr = Convert.ToString(resObj.GetType().Name);

            Assert.AreEqual("Single", tmpStr);
        }
 public void GetRandomStatic(short X, short Y, short Z, Collection[,] StaticMap)
 {
     if (this.m_Random.Count == 0)
     {
         return;
     }
     VBMath.Randomize();
     if (checked ((int)Math.Round((double)Conversion.Int(unchecked (100f * VBMath.Rnd())))) <= this.m_Freq)
     {
         ((RandomStaticCollection)this.m_Random[checked ((int)Math.Round((double)unchecked ((float)Conversion.Int(checked (this.m_Random.Count - 1)) * VBMath.Rnd())) + 1)]).RandomStatic(X, Y, Z, StaticMap);
     }
 }
示例#18
0
        public void Randomize_IsIdempotent(double seed)
        {
            ResetSeed();

            VBMath.Randomize(seed);
            float actualState1 = VBMath.Rnd(0.0f);

            VBMath.Randomize(seed);
            float actualState2 = VBMath.Rnd(0.0f);

            Assert.Equal(actualState1, actualState2);
        }
示例#19
0
        // Reset seed, without access to implementation internals.
        private void ResetSeed()
        {
            float x = BitConverter.ToSingle(BitConverter.GetBytes(0x8076F5C1), 0);

            VBMath.Rnd(x);

            float startupSeed = (float)0x50000;
            float period      = 16777216.0f;
            float currentSeed = VBMath.Rnd(0.0f) * period;

            Assert.Equal(startupSeed, currentSeed);
        }
 public void GetRandomStatic(short X, short Y, short Z, Collection[,] StaticMap)
 {
     if (this.m_Random.Count != 0)
     {
         VBMath.Randomize();
         if (checked ((int)Math.Round((double)Conversion.Int(100f * VBMath.Rnd()))) <= this.m_Freq)
         {
             int num = checked (checked ((int)Math.Round((double)((float)((float)Conversion.Int(checked (this.m_Random.Count - 1)) * VBMath.Rnd())))) + 1);
             ((RandomStaticCollection)this.m_Random[num]).RandomStatic(X, Y, Z, StaticMap);
         }
     }
 }
示例#21
0
        public static string Random(int len)
        {
            string str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST123456789他是说汉语的Ⓟⓡⓞⓣⓔⓒⓣア尺Ծイ乇ζイ123456789αβγδεζηθικλμνξοπρστυφχψω卍卍卍卍卍卍卍";

            char[] chArray = new char[(len - 1) + 1];
            int    num     = len - 1;

            for (int i = 0; i <= num; i++)
            {
                chArray[i] = str[(int)Math.Round((double)Conversion.Int((float)(VBMath.Rnd() * str.Length)))];
            }
            return(new string(chArray));
        }
示例#22
0
        public void Rnd_0_PreviousNumberInSequenceIsNotAlwaysThePreviouslyGeneratedNumber()
        {
            ResetSeed();

            float previouslyGeneratedNumber = VBMath.Rnd();

            VBMath.Randomize(42.0f);
            float actual   = VBMath.Rnd(0.0f);
            float expected = 0.251064479f;

            Assert.Equal(expected, actual);
            Assert.NotEqual(previouslyGeneratedNumber, actual);
        }
示例#23
0
        // Token: 0x06000037 RID: 55 RVA: 0x00003184 File Offset: 0x00001384
        public static string randomString(int length)
        {
            char[] array = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
            VBMath.Randomize();
            StringBuilder stringBuilder = new StringBuilder();

            for (int i = 1; i < length; i++)
            {
                int num = (int)((float)(array.Length - 2 + 1) * VBMath.Rnd()) + 1;
                stringBuilder.Append(array[num]);
            }
            return(stringBuilder.ToString());
        }
示例#24
0
        public void Randomize_UseExistingStateWhenGeneratingNewState(double seed)
        {
            ResetSeed();

            VBMath.Randomize(seed);
            float actualState1 = VBMath.Rnd(0.0f);

            VBMath.Rnd();
            VBMath.Randomize(seed);
            float actualState2 = VBMath.Rnd(0.0f);

            Assert.NotEqual(actualState1, actualState2);
        }
示例#25
0
        public string vMXFSQfFDrQEePRSb2Yl6edVxzcplo6b(int FqVi3zK6rAXVOoPIYvPFOICtQS0SujSv, [Optional, DefaultParameterValue("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")] string DataSend)
        {
            VBMath.Randomize();
            char[]        chArray = DataSend.ToCharArray();
            StringBuilder builder = new StringBuilder();
            Random        random  = new Random();

            while (Strings.Len(builder.ToString()) != FqVi3zK6rAXVOoPIYvPFOICtQS0SujSv)
            {
                int index = (int)Math.Round((double)(VBMath.Rnd() * (chArray.Length - 1)));
                builder.Append(chArray[index]);
            }
            return(builder.ToString());
        }
示例#26
0
 public void GetRandomStatic(ushort X, ushort Y, ushort Z, Collection[,] StaticMap)
 {
     checked
     {
         if (this.m_Random.Count != 0)
         {
             VBMath.Randomize();
             if ((int)Math.Round((double)Conversion.Int(unchecked (100f * VBMath.Rnd()))) <= this.m_Freq)
             {
                 int index = (int)Math.Round((double)unchecked ((float)Conversion.Int(checked (this.m_Random.Count - 1)) * VBMath.Rnd())) + 1;
                 ((RandomStaticCollection)this.m_Random[index]).RandomStatic(X, Y, Z, StaticMap);
             }
         }
     }
 }
示例#27
0
        public void Randomize_SetsExpectedState()
        {
            ResetSeed();

            VBMath.Randomize(-2E30);
            Assert.Equal(-0.0297851562f, VBMath.Rnd(0.0f));
            VBMath.Randomize(-0.003356);
            Assert.Equal(-0.244613647f, VBMath.Rnd(0.0f));
            VBMath.Randomize(0.0);
            Assert.Equal(-1.0f, VBMath.Rnd(0.0f));
            VBMath.Randomize(10.12345678901);
            Assert.Equal(-0.503646851f, VBMath.Rnd(0.0f));
            VBMath.Randomize(3.5356E99);
            Assert.Equal(-0.462493896f, VBMath.Rnd(0.0f));
        }
示例#28
0
        public static string RandomNameText()
        {
            charset = "他是说汉语的ア尺乇你他是说汉语的ア尺乇你他是说汉语的ア尺乇你abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789123456789123456789123456789123456789123456789ᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠαβγδεζηθικλμνξοπρστυφχψωαβγδεζηθικλμνξοπρστυφχψωαβγδε";
            rename  = "dark#5000-protector|";

            char[] chArray = new char[(20 - 1) + 1];
            int    num     = 20 - 1;

            for (int k = 0; k <= num; k++)
            {
                chArray[k] = charset[(int)Math.Round((double)Conversion.Int((float)(VBMath.Rnd() * charset.Length)))];
            }
            rename += new string(chArray);

            return(rename);
        }
示例#29
0
        public short CheckTop(short TileID)
        {
            short num1;

            if (this.m_TopEdge[(object)TileID] == null)
            {
                num1 = (short)0;
            }
            else
            {
                VBMath.Randomize();
                float num2 = VBMath.Rnd() * 15f;
                if ((double)num2 == 0.0)
                {
                    num1 = (short)-4;
                }
                else if ((double)num2 >= 1.0 && (double)num2 <= 3.0)
                {
                    num1 = (short)-3;
                }
                else if ((double)num2 >= 4.0 && (double)num2 <= 8.0)
                {
                    num1 = (short)-2;
                }
                else if ((double)num2 == 9.0)
                {
                    num1 = (short)-1;
                }
                else if ((double)num2 == 10.0)
                {
                    num1 = (short)0;
                }
                else if ((double)num2 >= 11.0 && (double)num2 <= 13.0)
                {
                    num1 = (short)1;
                }
                else if ((double)num2 == 14.0)
                {
                    num1 = (short)2;
                }
                else if ((double)num2 == 15.0)
                {
                    num1 = (short)3;
                }
            }
            return(num1);
        }
示例#30
0
        public short CheckTop(short TileID)
        {
            short num = 0;

            if (this.m_TopEdge[TileID] != null)
            {
                VBMath.Randomize();
                float single = VBMath.Rnd() * 15f;
                if (single == 0f)
                {
                    num = -4;
                }
                else if (single >= 1f && single <= 3f)
                {
                    num = -3;
                }
                else if (single >= 4f && single <= 8f)
                {
                    num = -2;
                }
                else if (single == 9f)
                {
                    num = -1;
                }
                else if (single == 10f)
                {
                    num = 0;
                }
                else if (single >= 11f && single <= 13f)
                {
                    num = 1;
                }
                else if (single == 14f)
                {
                    num = 2;
                }
                else if (single == 15f)
                {
                    num = 3;
                }
            }
            else
            {
                num = 0;
            }
            return(num);
        }