VerseIsland
FeedLearnLeaderboardGuidesReferenceExploreSearchDocsVerse Library
Sign in
Feed Learn 📖 Codex Leaderboard Guides Reference Explore Search Docs Verse Library
Browse Community Snippets›Devices·Up to Community Snippets · Devices·31 of 70 in Devices

Random Permutation Picker Device

41,520 Views

Report

  • using { /Fortnite.com/Devices }
    using { /Verse.org/Random }
    using { /Verse.org/Simulation }
    using { /UnrealEngine.com/Temporary/Diagnostics }
    
    # The random_permutation_picker device generates a random permutation of
    # its Choices and then picks them one at a time, without item repetition, with Pick.
    # When the last choice has been picked, a new permutation is generated.
    random_permutation_picker_device := class(creative_device):
        @editable
        PickButton:button_device = button_device{}
        # The Choices array is the set of elements to be picked.
        @editable
        var<private> Choices:[]switch_device = array{}
       
        var<private> PickStartIndex<private>:int=0
       
        # Pick one of the Choices, without repetition.
        # The algorithm uses a form of the Fisher-Yates shuffle to generate a random permutation.
        # See https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
        # for a description of the Fisher-Yates shuffle algorithm.
        Pick<public>()<transacts><decides>:switch_device=
            # Imagine a hat with all the Choices in it.
            # The hat is full at the start of the permutation.
            # PickStartIndex is the index of the first element in the hat.
            # We pick an element from the hat, remove it from the hat, and return it.
            # When the hat is empty, we refill it and start a new permutation.

You're reading a preview

The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.

Sign in with Discord — free for members Read the original at Epic Games documentation

Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.

Guided course

Add this to your free study plan — we’ll suggest related material and stitch it into one compile-checked lesson.

Keep exploring
More in Devices · 31 of 70
Prev
fortnite double damage with button
Next
fortnite force sit on chairs device

Source

Epic Games documentation

View original

Last updated 2026-07-26T13:01:26.005627+00:00

VerseIsland· an archipelago of Verse & UEFN knowledge
🗺️ Island atlasLearnGuidesHistoryAbout & PressSources & LicensingPrivacy PolicyTermsStatus

Not affiliated with Epic Games. Fortnite, UEFN, Unreal Engine, and Verse are trademarks of Epic Games, Inc. Content is attributed to its source — see Sources & Licensing.

🦜

Scout · your island guide

The Isle of Verse