Randomly Distribute Table Contents - Plz Help
BrackAttack
Member Posts: 22
Hi gang, I'm trying to distribute the values from one table, split into two different tables - randomly and without duplication. So if there are 20 rows of data in table1, then table2, & table3 will acquire 10 new rows each. Table 1 will go back to 0 rows. (if there are odd rows, it will just distribute an odd number to one of the tables.)
I was actually able to get this to work with my tangled code, however it only works for one transfer per table for some reason, I can't get it to go all the way to completion.
How would you do it? Thanks.
I was actually able to get this to work with my tangled code, however it only works for one transfer per table for some reason, I can't get it to go all the way to completion.
How would you do it? Thanks.
Comments
http://forums.gamesalad.com/discussion/53553/demo-randomize-table-rows
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I like your approach to randomizing. I had been using the other way to randomize, seemingly successfully. But my biggest issue seems to be figuring out how to split and transfer half the table into the two other tables.
The demo counts down from the number of rows, so you'd need to stop one loop at the first row (when self.i>1) and stop the other loop at the halfway point (when self.i2>ceil(#rows/2)+1).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
If you haven't yet read these two threads, they are worth the time:
https://forums.gamesalad.com/discussion/53770/how-to-call-multiple-values-from-a-table-row
http://forums.gamesalad.com/discussion/44707/timers-are-for-chumps-gs-optimization-tips
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I've been playing around with it a bit. I changed the reset game button and put the whole time-stamp loop randomization into a rule 'if attribute game.button = true then randomize, And had the loop change game.button back to false when done. But I noticed that the randomization doesn't seem to be as robust now and I am seeing a lot of dominant repeats.
I should note that I'm really not very clever, so getting my head around some of this stuff takes me awhile.
Another Fail I managed: I created two new tables: |T| RandomHalfA and |T| RandomHalfB, with the simple goal of splitting the table |T| Values between the two new tables. I think I did what you suggested: I had one actor do the ceil(#rows/2), and stopped one loop at the first row (when self.i>1) and assigning the values to one of the new tables, and then had a second actor stop the other loop at the halfway point (when self.i2>ceil(#rows/2)+1), but I couldn't get it to populate the new tables. I'm not doing it right. Still working on it.