Jump to content
UBot Underground

Recommended Posts

Hello fellow ubotters, it's been awhile since my last share so I though today would be the day to share some of my personal code. I don't know if this has been covered yet so here it is. We all know that the random list item is not always what we need. so I made this code to randomize a list in ubot. Below you will find the code. You can make the list randomizer faster by removing the wait, but if your distributing bots with this code I would recommend leaving it in, so you don't have any freezing problems with users that have slow processing speeds.

clear list(%templist)
clear list(%loadedactionlist)
ui open file("Load * List:", #loadedfile)
ui stat monitor("{#visualeffectsone} {#visualeffectstow}", "")
set(#visualeffectsone, "<font color=\"#01DF01\">Randomizing List</font> ", "Global")
add list to list(%loadedactionlist, $list from file(#loadedfile), "Delete", "Global")
set(#position, 0, "Global")
loop($list total(%loadedactionlist)) {
    set(#randomlistitem, $random list item(%loadedactionlist), "Global")
    set(#position, 0, "Global")
    add list to list(%templist, $list from text(#randomlistitem, $new line), "Delete", "Global")
    loop($list total(%loadedactionlist)) {
        if($comparison($list item(%loadedactionlist, #position), "=", #randomlistitem)) {
            then {
                remove from list(%loadedactionlist, #position)
                decrement(#position)
            }
        }
        increment(#position)
    }
    set(#visualeffectstow, $list total(%templist), "Global")
    wait(0.0000000000000000000001)
}
clear list(%loadedactionlist)
add list to list(%loadedactionlist, %templist, "Delete", "Global")
clear list(%templist)
set(#visualeffectstow, "", "Global")
set(#visualeffectsone, "<font color=\"#DF0101\">Randomized Complete</font> ", "Global")
  • Like 1
Link to post
Share on other sites

Good job for sharing Giganut!!

 

 

I wanted to add another way that may be easier or just to provide another option for folks. In the spirit of sharing...

 

and  probably a hidden gem that some may not be aware of too

clear list(%numbers shuffled)
clear list(%numbers)
set(#index, 1, "Global")
loop(50) {
    add item to list(%numbers, #index, "Delete", "Global")
    increment(#index)
}
add list to list(%numbers shuffled, $plugin function("File Management.dll", "$shuffle list", %numbers), "Delete", "Global")
alert(%numbers shuffled)

hidden prolly cuz it's called shuffle and not random but awesome in my opinion

 

TC

  • Like 1
Link to post
Share on other sites

Yes like 3 seconds for 10k and 17sec for 100k

set(#numbers LT, 0, "Global")
set(#shuffled LT, 0, "Global")
set(#elapsed, "00:00:00", "Global")
random list genereator UL(10000)
Shuffle UL()
Save to DT and clear list UL()
stop script
define random list genereator UL(#Loop Count) {
    clear list(%numbers)
    set(#index, 1, "Global")
    loop(#Loop Count) {
        add item to list(%numbers, "{#index} -- {$random text(8)}", "Delete", "Global")
        increment(#index)
    }
    set(#numbers LT, $list total(%numbers), "Global")
}
define Shuffle UL {
    clear list(%numbers shuffled)
    set(#start, $plugin function("DateTime Manipulation.dll", "$datetime manipulation", $date, "UBOT", "UNIX", "en-US", "en-US"), "Global")
    add list to list(%numbers shuffled, $plugin function("File Management.dll", "$shuffle list", %numbers), "Delete", "Global")
    set(#end, $subtract($plugin function("DateTime Manipulation.dll", "$datetime manipulation", $date, "UBOT", "UNIX", "en-US", "en-US"), #start), "Global")
    set(#elapsed, $plugin function("DateTime Manipulation.dll", "$datetime manipulation", #end, "UNIX", "HH:mm:ss", "en-US", "en-US"), "Global")
    set(#shuffled LT, $list total(%numbers shuffled), "Global")
}
define Save to DT and clear list UL {
    save to file("{$special folder("Desktop")}\\numbers-test.txt", %numbers)
    clear list(%numbers)
    save to file("{$special folder("Desktop")}\\SHUFFLEDnumbers-test.txt", "BAM!!!!!!!!!!!
{%numbers shuffled}")
    plugin command("File Management.dll", "open file", "{$special folder("Desktop")}\\numbers-test.txt")
    plugin command("File Management.dll", "open file", "{$special folder("Desktop")}\\SHUFFLEDnumbers-test.txt")
    clear list(%numbers shuffled)
}
ui stat monitor("Numbers: {#numbers LT}", "<BR>Shuffle: {#shuffled LT}
<br>Elapsed time: {#elapsed}
<br>
<br>List Position: {$list position(%numbers)}")

Peace, B) :rolleyes:

TC

Link to post
Share on other sites

Thanks for the shares!! I'm always trying to learn more so I appreciate them.

 

No problem, if you ever need help just let me know, and I will do my best to help you out.

Link to post
Share on other sites
  • 8 months later...

In some UBOT pseudocode, this one destroy the original list.

loop list_total(original)
 add_item_list(rand_item_list(original),destination)
 delete_item(current_pos(original))
end

(*) questions, current position in list points the right way after a get rand list item? after a remove item the get rand works on the remain i guess ... I dont have Ubot here so I cant test the code.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...