playMaker

Author Topic: Array list distribution random  (Read 2931 times)

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Array list distribution random
« on: February 15, 2014, 04:01:30 AM »
Hello,

i have to create a deck of 126 cards, listed in an arry list, and distribute them randomly to 4 decks of 20 cards.

first i created 5 arrayLists, 1 for each player + 1 containing the 126 cards.
but now, for distributing them i have the problem of the randomly chosen cards, it can be same int variable so duplicated cards.


so, i would like to indicate, when a card is taken from this arrayList, it cannot be chosen a second time, maybe by deleting it, or moving the other cards, i don't know.

by the in the both situation, i'm wonderingn how i can do it to prevent conflict of "unfund card"

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array list distribution random
« Reply #1 on: February 17, 2014, 11:07:49 AM »
Hi,

 this week is looking very busy, but can you come back to me before the end of this week and I'll do a sample.

basically, you duplicate your deck of card array, then you delete each entry that you pick as you distribute the cards, that's all there is to it.


bye,

 Jean

Frogspasm

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Array list distribution random
« Reply #2 on: February 18, 2014, 01:09:19 AM »
I just had to figure this out for an array of fake lights (flipping between an on and off texture).
I did what Jean suggested to you, and made a copy of the array list proxy, and at the start copied the original array to it. Then in the fsm do the random choice of your object in the array, and delete it from the duplicated list. Then loop back to the beginning to pick the next random item from the list. Do this until the duplicate array is empty.

I'll see if I can get a sample together.

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Re: Array list distribution random
« Reply #3 on: February 18, 2014, 06:01:34 PM »
ok, i see, i'll try something like that to do it ;D

PaulH

  • Junior Playmaker
  • **
  • Posts: 50
Re: Array list distribution random
« Reply #4 on: May 31, 2014, 10:17:45 AM »
Hi,

 this week is looking very busy, but can you come back to me before the end of this week and I'll do a sample.

basically, you duplicate your deck of card array, then you delete each entry that you pick as you distribute the cards, that's all there is to it.


bye,

 Jean

Hi jean

did you manage to do the sample for this? if so could you please post as im trying to figure this out now.

many thanks

Paul.

Edit: no worries ive done it. maybe for someone else though.
« Last Edit: June 01, 2014, 07:55:35 AM by elusive52 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array list distribution random
« Reply #5 on: July 01, 2014, 08:19:25 AM »
Hi,

 The sample is done, I'll release it when PlayMaker 1.8 will be out, if you are part of the PlayMaker beta and are interested to get a preview, let me know.

Typically, I use the action "revert to SnapShot", that's all there is to it :) I have implement another variant, using "copy to" whee I have anoriginal deck or cad that I don't touch, and simply copy to a "deck" arrayList, and I pick and remove cards from that "Deck".


 Bye,

 Jean