Using Advanced Random's Permutation Tables

12

Index

Features on these Courses

Attached Files

The following files have been attached to this tutorial:

.c3p

ar-permutation-table-card.c3p

Download now 80.19 KB

Contributors

Stats

4,382 visits, 9,070 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.

Published on 26 Aug, 2021. Last updated 5 Jan, 2023
.C3P

ar-permutation-table-card.c3p

Download now 80.19 KB

The Advanced Random plugin is really useful for a variety of things, notably procedural generation via its noise-generation functions. But it also allows you to build Permutation and Probability tables. We'll be focussing on Permutation tables in this tutorial but you can check out this one if you want to learn about Probability tables.

A permutation table is simply a sequence of numbers that are randomly ordered. This is useful for retrieving random, non-repeating numbers. For example, you could use the numbers 0-51 to represent a deck of cards and create a permutation table to represent a shuffled deck of cards. Then if you read through the permutation table in order with the Permutation expression, it will return a random sequence of cards, like dealing from a shuffled deck – we'll be turning this into an example in this tutorial.

One of the other handy things you can do with a permutation table is shuffle it again once you've created it. I've not included that functionality in this tutorial, but you could use it in a card game if you wanted to reshuffle the deck as you play.

  • 5 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • ótimo, obrigado

  • Hey, I want to create a set of numbers, and pick a random number from the set. Then I want to assign each number from the set to a sprite, so that if the table picks a number, then the sprite will pop up or do a action. How do I do that?

      • [-] [+]
      • 1
      • Laura_D's avatar
      • Laura_D
      • Construct Team Community Manager
      • 1 points
      • (0 children)

      These sorts of questions are best asked in the forums really, but as a basic example, you could create the permutation table on the start of the layout, then when a key is pressed you'd iterate through a 'For' loop the same size as the permutation table to spawn that many sprites and assign them an animation frame that matches the loopindex.

  • Hello, thanks for the tutorial it's super useful ! Is there any way to chose the animation of the FaceUpCard the same way we chose the frame ? For example, if I want to make a moving animation for each card, I would create multiple animations on the same object and just call the right one with the matching AdvancedRandom.Perutation(CardNumber), but it does not seem to be possible since changing the animation requires its name, and not a number. Is there a way to do that ? Thanks in advance

      • [-] [+]
      • 2
      • Laura_D's avatar
      • Laura_D
      • Construct Team Community Manager
      • 2 points
      • (0 children)

      There is a system expression to turn an integer or float into a string - try adding str() around the Advanced Random expression.