My Math Forum Scenario calculating optimal strategy of drawing cards

 Probability and Statistics Basic Probability and Statistics Math Forum

 August 19th, 2017, 09:13 PM #1 Newbie   Joined: Aug 2017 From: Cali Posts: 6 Thanks: 1 Scenario calculating optimal strategy of drawing cards Hey, sorry to ask this of you guys, but while I can handle basic probability fairly well, this is a bit beyond me - or at least I can't make the logical jump needed to figure it out. Basically, the scenario is there are 80 cards in a deck of cards. You draw cards in packs of 4 and so you have twenty packs of cards in a card deck. Each pack costs say 1 unit to buy and when the deck is completely depleted it refreshes. Alternatively you can come back a day later to a new deck. In each deck of cards, there are: -2 Aces worth 120 points -4 Kings worth 30 points -6 Queens worth 6 points -68 Jacks worth 1 point Now as a rational person attempting to maximize return with unlimited time but limited currency we would only draw cards until the EMV of the deck was somewhat lower than the average since when that happens we can just wait for the deck to reset the next day and give us a better EMV. On the other hand if the EMV of the deck increases as we play (as in we don't get the Aces early on) then it makes sense to play until the EMV has dropped below the average amount of the box (which will usually happen when the player has gotten 1 Ace before 10 packs or 2 Aces before the deck is empty). I understand how to calculate EMV at any given point and compare that to EMV average which should be EMV(start) = [(120*2)+(30*4)+(6*6)+(1*68​)]/20 = 23.8 points. So for any given turn I could and used to make an optimal decision. On the other hand, I want to calculate what the EMV of a perfect rational player is, given optimal playing strategy, where you only bet until EMV is lower than 23.8 (maybe by at least one point so getting a single King doesn't stop the strategy but if that's too tricky than by any amount). If you don't feel like doing the math, but have a hint you could throw me on how I might tackle this myself I'd appreciate it but at the moment I'm kind of stumped. I'm sure a computer could also run a scenario (I actually have a feeling I could do this in Excel Solver if I asked the right way) but I don't know how to do that either. Context (irrelevant to problem): BTW this isn't actually for gambling - it uses a free resource that is impossible to be paid for in a strictly action game. It's a F2P mechanic of a game I like that was changed to a much worse but more confusing model to try to hide how bad the change is for players. However at least the new model is easy to calculate return on for optimal play. I wanted to figure out optimal return based on the old strategy and show how bad it is comparatively now to try to get some community/developer response. They're good developers and if the community was more informed I think they'd make efforts to help them again. Frankly, I sometimes wonder how well the developers are at doing the math themselves; I kinda doubt they meant to gut it this hard. No idea where to ask for help except a probability forum sorry. All the best, Charles Last edited by skipjack; August 20th, 2017 at 02:41 AM.
 August 20th, 2017, 05:36 AM #2 Senior Member   Joined: May 2016 From: USA Posts: 1,030 Thanks: 420 I do not understand the question at all. What is the ratio of units to points?
 August 20th, 2017, 07:02 AM #3 Math Team     Joined: Jul 2013 From: काठमाडौं, नेपाल Posts: 878 Thanks: 60 Math Focus: सामान्य गणित Does the used deck get replaced with a new(complete) deck everyday?
August 20th, 2017, 04:38 PM   #4
Newbie

Joined: Aug 2017
From: Cali

Posts: 6
Thanks: 1

Quote:
 Originally Posted by JeffM1 I do not understand the question at all. What is the ratio of units to points?
Sorry, I think I made this problem more difficult to understand than it needs to be.

There is a cost associated with obtaining one pack of cards, but since it's the same cost for every pack of cards its value doesn't really matter. Just assume you have a limited amount of packs you can open and are trying to get as many points from that as possible. The ratio of units to points is just 1 unit = 23.8 points (on a fresh deck). However, we only want to play while the deck is favourable and then wait for a new deck when the deck has become unfavourable. I guess it's kind of like card counting, except you can't change the value of your bet, you only control when you leave a deck because it's no longer as good as a new deck.

Quote:
 Originally Posted by MATHEMATICIAN Does the used deck get replaced with a new(complete) deck everyday?
Yes the deck gets replaced every day. Or every minute. The length of time doesn't really matter just assume we have unlimited time but limited currency. For simplicity's sake, we can just say the player can start with a brand new deck whenever they feel like it but can never revisit an old deck (so your choice is always to either draw from the same deck as last draw or draw from a brand new deck).

Last edited by skipjack; August 21st, 2017 at 07:17 PM.

 August 20th, 2017, 04:48 PM #5 Newbie   Joined: Aug 2017 From: Cali Posts: 6 Thanks: 1 If I were to restate the problem more succinctly with concrete numbers in case it is only reasonably solvable by modelling: -You are gambling with a deck of 80 cards. -You draw 4 cards at a time from the deck. Each draw costs 1 dollar -You plan to spend 100 dollars (so you have 100 draws) and your objective is to maximize 'points' -The 80 card deck contains 4 different types of cards, all worth different amounts of points. They are as follows:2 Aces worth 120 points 4 Kings worth 30 points 6 Queens worth 6 points 68 Jacks worth 1 point This is the card make up of every deck. -Your first draw is made from a complete deck and then on each subsequent draw you choose to either draw from the deck you just drew from or draw from a new deck of those 80 cards. That's everything you need to know to answer the question - only read further for my stab at it. And this is how far I can get: From the above, we can calculate the expected point value of one draw from a deck at any point with the following formula: Expected Return in points = $[(120A)+(30K)+(6Q)+(J​)]/D$ Where A = Aces left in deck K = Kings left in deck Q = Queens left in deck J = Jacks left in deck D = Draws of cards left in deck (this is just the number of cards remaining left in deck / 4 since you draw cards in multiples of 4) Therefore your expected point value of a draw of a new deck (remember each deck starts with 2 Aces, 4 Kings, 6 Queens and 62 Jacks): $[(120*2)+(30*4)+(6*6)+(62​)]/20 = 23.8$ points/draw Now since you can choose to start with a new deck at any point you should never continue playing an old deck if the expected point value of a draw is below 23.8. However, when the expected point value of a draw is above 23.8 then you should continue playing the same deck until that's no longer the case. And in case it's helpful, let's look at an example of how you would play. Imagine these are your first three draws of a brand new deck: [J] [J] [J] [J] [J] [J] [J] [Q] [J] [J] [A] [J] Aces are worth the most by far in this game and getting one of the two aces in one of your first few draws is quite lucky. Now the deck is kind of depleted in points relative to the cards left over and we would expect a perfectly rational player to draw from a new deck but let's check the math. After your first three draws, your expected point value of a draw is: $[(120A)+(30K)+(6Q)+(J​)]/D$ $[(120*1)+(30*4)+(6*5)+(58​)]/17 = 19.29$ So indeed that value is much lower than a draw from a new deck (23.8​) and therefore our next draw should be made from a new deck. I understand the above is how I calculate the correct decision at any given point, however I don't know how to calculate what my actual expected point value per draw is, given I play perfectly rationally. If I made 100 draws in a row and never used a new deck, I'd get 23.8*100 = 2380 points. But if I make 100 draws in a row using a new deck whenever it is rational to do so, my expected points would be higher... but what would they likely be? That's the part I don't know how to do and the question I'm trying to solve. Last edited by skipjack; August 21st, 2017 at 07:15 PM.
 August 23rd, 2017, 11:16 PM #6 Newbie   Joined: Aug 2017 From: Cali Posts: 6 Thanks: 1 Update: I made a mistake in calculating the expected point gain of a new deck of cards. It should be 23.2 I tried to brute force results through Excel. I seemed to get lucky with good finds in early packs more often than I expected and I've read that Excel random number generator was pretty bad until the last 5 or so years. I'm hoping =randbetween in Mac's version of Excel 2017 is decent... idk how to really check that. My results on 253 draws of four cards were: Points per draw - 30.079 Average packs drawn before switching - 7.906 That's a huge improvement over 23.2 on a new pack. I'm kind of skeptical of this result. When I have more time I'll try for a bigger sample though obviously that doesn't help if their random generator isn't good. But if anyone knows how to do actual math to see what the average would be I'm curious how that matches up with the 'experimental' result.
 August 24th, 2017, 07:48 PM #7 Senior Member     Joined: Jul 2012 From: DFW Area Posts: 614 Thanks: 83 Math Focus: Electrical Engineering Applications Hi Charles, I think that your strategy (of changing decks when the expected return is lower than that of a new deck) is logical. I wrote a Ruby program to simulate the problem. Three runs of 10 million draws gave the following results: Average points per draw: 30.28 Average draws per deck: 6.54 Percentage of decks where 20 draws were made: 5.03% So my average points per draw is similar to your run, but my average draws per deck is a little lower. I was just curious about the percentage of decks where all 20 draws are made so I included it. It is possible that I have made a mistake in programming so it would be nice to compare our results if you are able to run a larger sample. Of course, if you or anyone else would like the code, I will post it. I have no idea how to calculate the expected value as it seems to me that there are just too many possibilities. Thanks from CharlesGBuick
 August 27th, 2017, 02:47 AM #8 Newbie   Joined: Aug 2017 From: Cali Posts: 6 Thanks: 1 Wow, thanks so much! It's awesome to get confirmation of a number this high; puts my mind at ease regarding the random number generator of Excel. Unfortunately, I can't easily produce large samples. I have no coding experience and basically made two Excel spread sheets instead, one that would create a new twenty draw deck whenever I hit delete on an empty cell and show where exactly a rational player would stop. The other I would place the results of the draws in and get information like average draws per deck, card distribution, average points, etc. While producing samples with this only takes me a few minutes per 100 draws, there's no feasible way for me to generate, say, tens of thousands of draws. That said, I feel pretty comfortable with the numbers, given your program's results fit mine so well. In all likelihood, the small difference is a result of a small constraint I put into my Excel spreadsheet. I worked on the assumption that a player wouldn't wait for a new deck if their EMV is almost exactly the same as a new deck. Their EMV had to be one point higher or more than the old deck to have them switch over. This is to prevent say getting a single king early and starting a whole new deck. The difference this would likely be small, but the strategy is slightly imperfect so a small positive difference for your results makes sense. You might get very similar results if you added that constraint. Thanks again for writing a script as well. I'm happy to send my files if you're interested. Charles Last edited by skipjack; August 30th, 2017 at 05:16 PM.
 August 27th, 2017, 07:42 PM #9 Newbie   Joined: Aug 2017 From: Cali Posts: 6 Thanks: 1 Not sure why Quick Replies don't get vetted but regular ones do. Anyways at the risk of repeating part of a message that will get approved later - thanks a lot for writing that program. I feel a lot more confident in the results now. Unfortunately since I lack coding skills I just brute forced a results page for a single deck in Excel and quickly repeat it to gain average draws. While it's possible to generate thousands of results quickly doing that, and there's no real way to move that to millions. Additionally to gain point value took another longer step that I did for my initial sample of 253. The reason for the discrepancy other than the small sample size is likely that I put an additional constraint on my simulation that being that EMV had to be at least one higher in a new deck to justify switching to it. This is because there was a wait time associated with using a new box and realistically people wouldn't quit if there was a tiny EMV gain from a new deck (like after getting a King and three Jacks on your first draw). For the program to run a switch EMV of new deck had to be one point higher than current deck (so only switch if current deck had EMV below 22.2). That would explain the small EMV gain your results saw as well as a significantly decreased average draw rate. To confirm I took out the EMV+1 constraint and modeled another 3000 packs. I got draws per deck of 6.13 and deck completion (20 draws) of 4.96% so much more similar to what yours were. Again thanks for helping me confirm my results. If you're interested in the files I'm happy to send them as well. Thanks from jks Last edited by CharlesGBuick; August 27th, 2017 at 07:51 PM. Reason: .
August 30th, 2017, 05:06 PM   #10
Senior Member

Joined: Jul 2012
From: DFW Area

Posts: 614
Thanks: 83

Math Focus: Electrical Engineering Applications
Quote:
 Unfortunately since I lack coding skills ...
If you like working on this sort of problem and you think that you might work on some others (in other words, if this is not a one-off problem), the following is a self-confession, meant for encouragement:

I do not consider myself worthy of creating production quality code - I will leave that to others who are much more experienced and skilled. However, I absolutely love to write software to try to give myself insight into problems such as the one that you presented and to make my job easier. Examples of the latter include automating repeated tasks and tests of electronic assemblies, number crunching), etc.

There are many free languages and programming tutorials out there, so give it a try of you like. After all, you learned Excel (probably better than me), and in the long run, learning to program will probably be easier and more comprehensive.

 Tags calculating, cards, drawing, optimal, scenario, strategy

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post mobel Probability and Statistics 1 May 24th, 2016 09:22 AM Andrewtomas Advanced Statistics 2 May 15th, 2016 05:16 AM immortalvictor Probability and Statistics 2 December 12th, 2015 06:18 AM immortalvictor Advanced Statistics 0 December 6th, 2015 01:49 PM Kinead Advanced Statistics 2 October 16th, 2014 10:07 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top