The Shuffling problem.

Talk about CTI.
Rothaon
Created software for the community!
Created software for the community!
Keys: 125,59 
Posts: 421
Joined: 13 Mar 2016, 16:25
Location: Spain
Gender: Male
Type: Dominant
Orientation: Gay
Contact:

So, I was editing the CTI Slideshow program in order to automate the Skirmish set with it.

And then I found the part where it shuffles instructions and images. There was a formula I can't understand. And I haven't find (yet) a formula I like.

So, here's the question, how do you handle the deck shuffling?
0131
Site Admin
Keys: 1 036,90 
Posts: 1021
Joined: 06 Jun 2015, 18:12
Gender: Female
Type: Switch
Orientation: Bi
Contact:

Card Creator

Hi, do you mean the part where you merge the images with the cards?

I handle it that way:

1. Create an Array or a List in the size of the images for tease
2. Do the same for each card type you use.
Now you have a bunch of arrays.
-----------------loop-----------------
3. Add their sizes together and draw a randomnumber between 0 and their size.
4. Make a method wich calculates which array has been hit with that randomnumber.
For example:
Images [0-200]
Nice Mitress [201-216]
...
Randomnumber = 205 -> add a Nice Mistress
5. Now you should know if a picture or a card (and the card type) has to be added.
6. Add the path of the picture or card to the slidelist.
7. Substract 1 from the size the Nice Mistress size and all following arrays.
8. Repeat X times where X is the total number of slides in the tease (= the size of all arrays added together at the start of the loop)
----------------------------------------
༼ つ ◕_◕ ༽つ Can i has CTI pls
Rothaon
Created software for the community!
Created software for the community!
Keys: 125,59 
Posts: 421
Joined: 13 Mar 2016, 16:25
Location: Spain
Gender: Male
Type: Dominant
Orientation: Gay
Contact:

Yes, that part exactly. Your method is too random for me though. Specially, for the Skirmish set.

I can fix the number of images between monsters between a range. But I'm not sure about doing that, I'd have to request at least X pictures before starting.

Btw, I have 4 lists. 3 lists of monsters (1 per level) and a list of pictures.
0131
Site Admin
Keys: 1 036,90 
Posts: 1021
Joined: 06 Jun 2015, 18:12
Gender: Female
Type: Switch
Orientation: Bi
Contact:

Card Creator

Well that doesn´t seem to be a problem, you can add extra rules to that algorithm.

1. Be sure for the first X loops that only a image is added thats very easy, just count the loops and add the rule to the randomnumber generator.
2. You could add more extra rules to the randomnumber generator so that if a card/monster was added then only images are added for x loops.

The only difficult part is to ensure that there are enough images in the tease to do that.
༼ つ ◕_◕ ༽つ Can i has CTI pls
Rothaon
Created software for the community!
Created software for the community!
Keys: 125,59 
Posts: 421
Joined: 13 Mar 2016, 16:25
Location: Spain
Gender: Male
Type: Dominant
Orientation: Gay
Contact:

That would be a good idea.

Anyways, I've started to think that it isn't good to fix the number of images. Instead let the user to set a range between cards and get as many images as needed.
Inside7shadows
Created software for the community!
Created software for the community!
Keys: 5,55 
Posts: 230
Joined: 25 Jun 2015, 02:34
Location: Colorado
Gender: Male
Type: Dominant
Orientation: Straight
Contact:

I create an array, then for each element in the array, I swap it with a random element in the array.

Code: Select all

Sub ShuffleArrayInPlace(InArray() As Variant)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ShuffleArrayInPlace
' This shuffles InArray to random order, randomized in place.
'http://www.cpearson.com/excel/ShuffleArray.aspx
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Dim N As Long
    Dim Temp As Variant
    Dim J As Long
   
    Randomize
    For N = LBound(InArray) To UBound(InArray)
        J = CLng(((UBound(InArray) - N) * Rnd) + N)
        If N <> J Then
            Temp = InArray(N)
            InArray(N) = InArray(J)
            InArray(J) = Temp
        End If
    Next N
End Sub
This works well if you stack an instructions array with each type of instruction, then zip through it once with this. I don't remember how I populate the arrays with file locations. I also randomize the pictures between instructions using Standard Distribution.
Post Reply

Return to “CTI - Talk”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests