SAIL - Shuffle (losowy porządek w tablicy)

Gotowe kody SAIL'a, informacje na temat moddingu, itd.

Moderator: zoNE

Post Reply
User avatar

Topic author
zoNE
The Great Uniter & Site Administrator
The Great Uniter & Site Administrator
Posts: 1799
Joined: Fri Feb 17, 2006 3:44 pm
Location: Poland
Contact:

SAIL - Shuffle (losowy porządek w tablicy)

#1

Post by zoNE » Fri May 15, 2020 5:17 am

Serpent wrote:
Thu May 14, 2020 9:33 pm
Funkcja ustawia elementy zadanej tablicy w losowej kolejności.

Code: Select all

Export Function Shuffle(array);
var i, index;
begin
result := [];

if not array then
   exit;

Randomize;

for i = array downto 1 do
    begin
    index := rand(1, array);
    result := Insert(result, result + 1, array[index]);
    array := Delete(array, index);
    end;
End;
Author: Serpent
Topic: viewtopic.php?f=42&t=6204

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest