Implementing Fisher-Yates shuffling algorithm

3
  • 13 favourites

Index

Stats

7,388 visits, 16,355 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Edit: I updated the tutorial. You can check Online example and download capx file.

kittiewan has a similar technique for shuffling, but i used a more common technique called Fisher-Yates shuffling. I used only 2 text objects to use the concept. But it can be easily used with sprites. If you are an experienced user you can skip to the last page for general event view.

Layout Part

Insert a Text object and name it BeforeText.

Don't forget: If you want to use lots of numbers, you will need a bigger text area. Insert another Text object and name it AfterText. Also you can change default Text in properties

Insert an array. Default size of an array is 10, but we will change it in events.

Event sheet part

Add an global variable to events area for keeping the total number of values.

Add another variable to use in a loop

  • 2 Comments

  • Order by
Want to leave a comment? Login or Register an account!