Popular pages:

Roulette System

The Roulette Systems That Really Work

Roulette Computers

Hidden Electronics That Predict Spins

Roulette Strategy

Why Roulette Betting Strategies Lose

Roulette System

The Honest Live Online Roulette Casinos

Bubble sort method for Roulette Xtreme

Started by RXGuru, March 07, 2009, 03:13:06 PM

0 Members and 1 Guest are viewing this topic.

RXGuru

Hello

While creating your systems using RX Scripting for Roulette Xtreme, did you ever have the need to sort a list of numeric values in a data record?  Posted here is a method that will perform that task.  You can sort the list Ascending or Descending.  The posted test system will generate 38 random numbers from 1 to 200.  To use the Bubble Sort method, just copy/paste to your system and call the method "bubble sort".

Have fun!

Les

system "bubble sort"
{
   To test Bubble sorting
}
method "main"
begin
    while starting a new session
    begin
        // Generate a set of 38 random numbers

        clear record "Items" data
        Put 1 on record "Items" data index
       
        Loop Until record "Items" data index > 38
        begin
            Generate Random Number from 1 to 200 into record "Items" data
            Add 1 to record "Items" data index
        end

        // True to sort Descending or False to sort Ascending
        set flag "Descending" to true
    end
   
    while on each spin
    begin
        //Do the sort  - all you need is just 1 spin for this test
        //
        //To use this method as a common function, duplicate (copy) or
        //record containing a list of numeric values to a record "X()"

        Duplicate record "Items" to record "X()"

        call "Bubble Sort"

        //The copy it back after the sort operation is performed
        Duplicate record "X()" to record "Items"

        //clean up the array
        Clear record "X()" data

    end

end

method "Bubble Sort"
{
    Bubble Sort to sort data items from a Data record "X()"
   
    Algorithm
   
      X() = an array of items
      N = # of items in the array
      H = temporary variable to swap data in the X() array
     
      FOR I = 1 TO N - 1
        FOR J = I + 1 TO N
          IF X(I)>X(J) THEN
          BEGIN
             H = X(I)
             X(I) = X(J)
             X(J) = H
          END
        NEXT J
      NEXT I
     
******* REQUIRED INPUTS for this METHOD **********

        record "X()" data - contains a list of numeric values
        flag "Descending"
            True  = sort Descending
            False = sort Ascending

}
begin
    set max to record "X()" Data index
    put 100% of record "X()" data index to record "N-1" data
    put 100% of record "X()" data index to record "N" data
    subtract 1 from record "N-1" data

    put 1 on record "I" data

    Loop until record "I" data > record "N-1" data
    begin
        put 100% of record "I" data to record "J" data
        add 1 to record "J" data

        Loop until record "J" data > record "N" data
        begin
            put 100% of record "I" data to record "X()" data index
            put 100% of record "X()" data to record "X(I)" data
            put 100% of record "J" data to record "X()" data index
            put 100% of record "X()" data to record "X(J)" data
           
            if Flag "Descending" is False
            begin
                if record "X(I)" data > record "X(J)" data
                begin
                    put 100% of record "X(I)" data to record "H" data
                    put 100% of record "X(J)" data to record "X(I)" data
                    put 100% of record "H" data to record "X(J)" data
               

                    put 100% of record "I" data to record "X()" data index
                    put 100% of record "X(I)" data to record "X()" data
                    put 100% of record "J" data to record "X()" data index
                    put 100% of record "X(J)" data to record "X()" data
                end
            end
            else
            begin
                if record "X(I)" data < record "X(J)" data
                begin
                    put 100% of record "X(I)" data to record "H" data
                    put 100% of record "X(J)" data to record "X(I)" data
                    put 100% of record "H" data to record "X(J)" data


                    put 100% of record "I" data to record "X()" data index
                    put 100% of record "X(I)" data to record "X()" data
                    put 100% of record "J" data to record "X()" data index
                    put 100% of record "X(J)" data to record "X()" data
                end
            end

            Add 1 to record "J" data
        end
       
        Add 1 to record "I" data
    end
end


VLSroulette

Thanks for the tip Les! :thumbsup:

Would you like it moved to roulette coding zone Section?  :)

RXGuru

Yes,

Please move it to coding zone.

Thanks

Les

RXGuru

-