0
$\begingroup$

I'm trying to simulate a card drawing game (as following below, I think it is popular problem!), Almost it is clear for me except one part, that is 2th rule in description. Actually I don't know how to change probability of the Legendry cards and how to decrease others , because sum of probabilities must be one. I implemented my idea but I don't know it is correct or not . thanks for your help in advance.

my code :

card=['C','R','L']
dist=[.943,.051,0.006]
draw={"C":0,"R":0,"L":0}
drawl=[]
f=0
n=1000
for i in range(n):
  r=np.random.choice(card,p=dist)
  if f==1:
    if np.random.rand()<0.3:
      drawl.append("L")
    else:
      drawl.append(r)
  else:
    drawl.append(r)
  if i>=9 and ("R" not in drawl[-9:]):
    drawl.append("R")
    continue
  if i>=75 and ("L" not in drawl[-75:]):
    
      f=1
  if i>=90 and ("L" not in drawl[-89:]):
    drawl.append("L")
    continue

image of my question :

enter image description here

$\endgroup$
4
  • $\begingroup$ In answer to your question, you need to change dist in your gap and reset after a Legendary card appears. You are not told bow to do this but anything linear between dist=[.649,.051,0.300] and dist=[.700,.000,0.300] would do it $\endgroup$
    – Henry
    Nov 20 at 14:59
  • $\begingroup$ But there is a further problem: what happens if you draw 9 Common then 1 Rare repeating the pattern for the first 89 draws. You then must draw a Rare and draw a Legendary on the 90th draw, but this is not possible since the sum of dist indicates that no card is both Rare and Legendary $\endgroup$
    – Henry
    Nov 20 at 15:05
  • $\begingroup$ my problem is that how to change dist list, i did my idea and effective probabilities were [0.685,0.13,0.277] after 1000 simulation $\endgroup$
    – amir1122
    Nov 20 at 15:15
  • $\begingroup$ I'm voting to close this question as this is clearly a homework problem and is not tagged as a self-study problem. The question can still be asked but should be designed as "self-study." Please review this information: stats.stackexchange.com/tags/self-study/info. In addition, please do not post images of your question. Further the text, which is clearly not yours is not properly attributed: stats.stackexchange.com/help/on-topic. It is also unclear. I don't see any description so what do you mean by the "2th [sic] rule in the description?" $\endgroup$ Nov 20 at 15:27