*Author

Offline rosutosefiTopic starter

  • Sr. Member
  • ****
  • Posts: 727
  • Reputation Power: 10
  • rosutosefi is taking their first peeks out of the Antlion's burrow.rosutosefi is taking their first peeks out of the Antlion's burrow.
  • Dead.
  • Awards: Slice of Elements 2nd Birthday Cake
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396073#msg396073
« Reply #12 on: September 20, 2011, 09:41:03 am »
should the loop be <10? I'm having a hard time understanding that, but I'll try to
Not so active.

Offline Xenocidius

  • Legendary Member
  • ******
  • Posts: 2696
  • Reputation Power: 49
  • Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.
  • Fear the Darkness ...
  • Awards: Slice of Elements 3rd Birthday CakeFavorite Community Member of 2011Weekly Tournament WinnerWinner of Design a Competition Competition
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396085#msg396085
« Reply #13 on: September 20, 2011, 10:07:12 am »
here is how the spin works
  • 1. (init) loop:=0, ncard:=0
  • 2. C:=random card from deck, loop:=loop+1
  • 3. if loop > 8 goto step 5.
  • 4. if C is a tower/pillar goto step 2.
  • 5. ncard:=ncard+1
  • (error)5bis. loop:=0 (error)
  • 6. if C is upped and lvl is not 5 or 6 then C:= downgrade version of C
  • 7. if C is a banned card then C:= relic (upped one if C is still upped)
  • 8. if ncard <= 4 goto step 2.
  • 9. the 4 first cards = the reel
I'll go back and comment my code a bit more.

Although now that you mention it, it should actually be <9. Let me edit that and see what effect it has ...

Edit: Nope, virtually no effect.
Don't cry because it's over, smile because it happened.

Offline Xenocidius

  • Legendary Member
  • ******
  • Posts: 2696
  • Reputation Power: 49
  • Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.
  • Fear the Darkness ...
  • Awards: Slice of Elements 3rd Birthday CakeFavorite Community Member of 2011Weekly Tournament WinnerWinner of Design a Competition Competition
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396087#msg396087
« Reply #14 on: September 20, 2011, 10:19:28 am »
Alright, I've heavily commented the code. Can you see any possible errors in it? I'll look over yours too.
Don't cry because it's over, smile because it happened.

Dark Weaver

  • Guest
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396110#msg396110
« Reply #15 on: September 20, 2011, 11:57:15 am »
I corrected the python code, I don’t know the python sythax so don’t copy paste it but you should understand the correction.
The error was that the loop counter is incremented at the start and each time a card is found or discarded.
def select(): #This selects 4 cards to use in the spinner
    ncard = 0 #0 cards have been selected
    loop = 0 #No cards have been pillars
    card = [0, 0, 0, 0] #Generate an array for the 4 cards to be used
    while ncard <= 3: #Do this 4 times
        loop = loop + 1 #Add 1 to loop
        index = random.randint(0, (len(cards)-1)) #Pick a random integer/card between 0 and the length of the card array (it holds the card code list)
        if cards[index] not in pillarcodes or loop > 8: #If card is not a pillar or loop >8 then pick the card
            card[ncard] = cards[index] #The nth card in the array is now the card code of the card selected
            ncard = ncard + 1 #Add 1 to number of cards picked
    return card #At the end, output the array of the 4 cards picked

def spin(): #This spins the wheel three times and returns the number of cards won
    wins = 0 #0 cards have been won
    for i in range(0, 3): #repeat 3 times
        card = select() #Generate a card array of the cards picked in the select() function
        card1 = card[random.randint(0, 3)] #Assign one of the 4 cards to the first card spun
        card2 = card[random.randint(0, 3)] #Assign one of the 4 cards to the second card spun
        card3 = card[random.randint(0, 3)] #Assign one of the 4 cards to the third card spun
        if card1 == card2 and card2 == card3: #If all cards are equal
            wins += 1 #Increase number of cards won by 1
    return wins #Return the number of cards won (for use in a different function)

Offline rosutosefiTopic starter

  • Sr. Member
  • ****
  • Posts: 727
  • Reputation Power: 10
  • rosutosefi is taking their first peeks out of the Antlion's burrow.rosutosefi is taking their first peeks out of the Antlion's burrow.
  • Dead.
  • Awards: Slice of Elements 2nd Birthday Cake
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396202#msg396202
« Reply #16 on: September 20, 2011, 05:02:24 pm »
so the pillar loops 8 times only? nooooooooooooooooooooo!

(that's 2 days of simulation down the drain)
Not so active.

Offline GG

  • Legendary Member
  • ******
  • Posts: 2253
  • Reputation Power: 28
  • GG is a proud Wyrm taking wing for the first time.GG is a proud Wyrm taking wing for the first time.GG is a proud Wyrm taking wing for the first time.GG is a proud Wyrm taking wing for the first time.GG is a proud Wyrm taking wing for the first time.
  • Retired from everything...
  • Awards: Slice of Elements 5th Birthday Cake3rd Trials - Master of Gravity2nd Trials - Master of GravityC-C-C-Combo Maker Winner!Weekly Tournament WinnerChampionship League 1/2011 WinnerWeekly Tournament WinnerWeekly Tournament WinnerChampionship League 3/2010 2nd PlaceNew Passive Ability Competition Winner
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396234#msg396234
« Reply #17 on: September 20, 2011, 06:03:27 pm »
Ewww MATLAB

When I'm bored ima write the whole thing in C++
Ex-Master of :gravity, still a fervid supporter! GO GRAVY!

Offline Sevs

  • Legendary Member
  • ******
  • Posts: 2007
  • Country: us
  • Reputation Power: 26
  • Sevs is a proud Wyrm taking wing for the first time.Sevs is a proud Wyrm taking wing for the first time.Sevs is a proud Wyrm taking wing for the first time.Sevs is a proud Wyrm taking wing for the first time.Sevs is a proud Wyrm taking wing for the first time.
  • My favorite element is Oxygen
  • Awards: Slice of Elements 3rd Birthday CakeWeekly Tournament WinnerWeekly Tournament Winner
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396249#msg396249
« Reply #18 on: September 20, 2011, 06:37:48 pm »
so the pillar loops 8 times only? nooooooooooooooooooooo!

(that's 2 days of simulation down the drain)
no it isnt 8 times it runs through the loop on increments 0,1,2,3,4,5,6,7,8,9 which is 10 times in total
"Elements is the greatest game ever made" - Abraham Lincoln

Offline Xenocidius

  • Legendary Member
  • ******
  • Posts: 2696
  • Reputation Power: 49
  • Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.
  • Fear the Darkness ...
  • Awards: Slice of Elements 3rd Birthday CakeFavorite Community Member of 2011Weekly Tournament WinnerWinner of Design a Competition Competition
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396434#msg396434
« Reply #19 on: September 21, 2011, 12:15:37 am »
I corrected the python code, I don’t know the python sythax so don’t copy paste it but you should understand the correction.
The error was that the loop counter is incremented at the start and each time a card is found or discarded.
def select(): #This selects 4 cards to use in the spinner
    ncard = 0 #0 cards have been selected
    loop = 0 #No cards have been pillars
    card = [0, 0, 0, 0] #Generate an array for the 4 cards to be used
    while ncard <= 3: #Do this 4 times
        loop = loop + 1 #Add 1 to loop
        index = random.randint(0, (len(cards)-1)) #Pick a random integer/card between 0 and the length of the card array (it holds the card code list)
        if cards[index] not in pillarcodes or loop > 8: #If card is not a pillar or loop >8 then pick the card
            card[ncard] = cards[index] #The nth card in the array is now the card code of the card selected
            ncard = ncard + 1 #Add 1 to number of cards picked
    return card #At the end, output the array of the 4 cards picked

def spin(): #This spins the wheel three times and returns the number of cards won
    wins = 0 #0 cards have been won
    for i in range(0, 3): #repeat 3 times
        card = select() #Generate a card array of the cards picked in the select() function
        card1 = card[random.randint(0, 3)] #Assign one of the 4 cards to the first card spun
        card2 = card[random.randint(0, 3)] #Assign one of the 4 cards to the second card spun
        card3 = card[random.randint(0, 3)] #Assign one of the 4 cards to the third card spun
        if card1 == card2 and card2 == card3: #If all cards are equal
            wins += 1 #Increase number of cards won by 1
    return wins #Return the number of cards won (for use in a different function)
Oh, it increments it after every card picked, not just every pillar picked?

That explains it. I'll run Osiris through it again when I get home.
Don't cry because it's over, smile because it happened.

Offline rosutosefiTopic starter

  • Sr. Member
  • ****
  • Posts: 727
  • Reputation Power: 10
  • rosutosefi is taking their first peeks out of the Antlion's burrow.rosutosefi is taking their first peeks out of the Antlion's burrow.
  • Dead.
  • Awards: Slice of Elements 2nd Birthday Cake
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396490#msg396490
« Reply #20 on: September 21, 2011, 01:49:00 am »
so the pillar loops 8 times only? nooooooooooooooooooooo!

(that's 2 days of simulation down the drain)
no it isnt 8 times it runs through the loop on increments 0,1,2,3,4,5,6,7,8,9 which is 10 times in total
yay! thank you for telling me, I was about to jump off a building!

Ewww MATLAB

When I'm bored ima write the whole thing in C++
Y U all have grudges on matlab?
Not so active.

Offline Xenocidius

  • Legendary Member
  • ******
  • Posts: 2696
  • Reputation Power: 49
  • Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.
  • Fear the Darkness ...
  • Awards: Slice of Elements 3rd Birthday CakeFavorite Community Member of 2011Weekly Tournament WinnerWinner of Design a Competition Competition
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396587#msg396587
« Reply #21 on: September 21, 2011, 07:25:20 am »
Alright, I corrected it but it has minimal effect. It's still returning nearly 0.85 cards per game.
Don't cry because it's over, smile because it happened.

Dark Weaver

  • Guest
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396636#msg396636
« Reply #22 on: September 21, 2011, 10:45:05 am »
so the pillar loops 8 times only? nooooooooooooooooooooo!

(that's 2 days of simulation down the drain)
no it isnt 8 times it runs through the loop on increments 0,1,2,3,4,5,6,7,8,9 which is 10 times in total
yay! thank you for telling me, I was about to jump off a building!
Prepare to jump ... :-[

The step 5bis should not be followed, it was an mistake I did previously.
Your matlab code repeat this mistake, you can see that in the results with the very low tower cards won.

I don’t have anything against matlab, it’s more the opposite, but running simulation is way faster in c/c++ than in matlab especially if you don’t use the matlab strength (vector and matrix manipulation) but its weakness (loops on single numbers).
Quote
Code: [Select]
tc = 0;
for c = 1:length(a)
    tc = tc + a(c);
    cumulative(c) = tc;
end
for d = 1:length(b)
    tc = tc + b(d);
    cumulative(length(a)+d) = tc;
end
seriously ? I mean ... SERIOUSLY ?????????
Code: [Select]
cumulative = cumsum([a b]);
Quote
Code: [Select]
f = floor(rand(1)*(cumulative(end)));
        g = 0;
        cp = 0;
        while g <= length(cumulative) && cp == 0; % use < not <=
            g = g + 1;
            if f < cumulative(g)
                four(e) = g;
                cp = 1;
            end
        end
although correct, why not do it the simple way
Code: [Select]
f = floor(cumulative(end)*rand);
four(e) = find(f < cumulative , 1);

Offline rosutosefiTopic starter

  • Sr. Member
  • ****
  • Posts: 727
  • Reputation Power: 10
  • rosutosefi is taking their first peeks out of the Antlion's burrow.rosutosefi is taking their first peeks out of the Antlion's burrow.
  • Dead.
  • Awards: Slice of Elements 2nd Birthday Cake
Re: Card Drop Rate https://elementscommunity.org/forum/index.php?topic=31068.msg396641#msg396641
« Reply #23 on: September 21, 2011, 10:52:15 am »
Wee! Thanks for the protips. :)
(I'm a beginner.)

5bis?
Not so active.

 

anything
blarg: