Array shuffle...suffers from insanity?

Not favoritedFavorited Favorited 0 favourites
  • 9 posts
From the Asset Store
Simple but fun word game. Restore an original word from shuffled letters.
  • Why the hell does the array shuffle interfere with only one line but not the entire index (column)?

    Tagged:

  • The Array object has a number of features intended for one-dimensional arrays, because it's a particularly useful case to have a list of items. Push, pop and shuffle are some of the features oriented around that usage, but they can also be applied to 2D and 3D arrays.

    If you want to shuffle a 2D array, you should be able to do that by shuffling twice, first on the X axis (shuffling every row), and then on the Y axis (shuffling every column).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ashley I didn't get the idea "by shuffling twice, first on the X axis (shuffling every row), and then on the Y axis (shuffling every column)." when each shuffle is random. Can you explain please?

    Good idea XHXIAIEIN, I did something pretty similar with a temporary 1D array to shuffle indices without using of Advanced Random. Honestly, I feel two arrays (main and temporary) is overkill for such a simple task, and the third plugin is even more, but this is just my opinion :)

  • I think there is a misunderstanding, currently the shuffle action breaks collumns. But it may be desired to shuffle along the x axis while moving the whole collumn with it.

    IMO the shuffle action could use a similar change to the sort action:

  • If you're into addons, Rex's CSV has better sorting than built-in array (Hopefully one day, built-in array can be as powerful as that addon). But not shuffling tho, although you could work around it by having a column with random values.

  • fedca that solution looks great! Having just a simple efficient method like that

  • What does array sorting have to do with random array shuffling? The discussion was exclusively about random array shuffling.

  • Say you have array that is 10x3 (e.g. Each X is Y0 = Apple, Y1 = Food, Y2 = £5... And then 8 other foods in the array).

    Have your array be 10x4 instead, and the first Y0 is now a number (then Y1 = Apple, Y2 = Food, etc).

    For each X, set Y0 to random number.

    Sort via X.

    Random shuffle that keeps relationship!

    ... I think, just guessing.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)