当前位置:网站首页>Card drawing program simulation
Card drawing program simulation
2022-07-27 05:12:00 【Beauty of algorithm and programming】
0 introduction
The popularity of mobile card drawing games , Let's use programs to simulate the game Draw card This part .
1 problem
For those who draw cards Draw card This link is simulated .
2 Method
use python Of random Function to simulate .
3 Experimental results and discussion
Through the experiment 、 Practice has proved that the proposed method is effective , Is able to solve the problem raised at the beginning .
Code list 1
| import random m = input(" Please enter the number of card drawing times ") n = int(m) a = 0 b = 0 c = 0 d = 0 luck = 0 number1 = 0 six = [ Card pool content ] five = [ Card pool content ] four = [ Card pool content ] three = [ Card pool content ] for i1 in range(0,n,1): secret = random.randint(1,100) if luck <= 50: if 1<=secret<=2: number1 = random.randint(0,26) print(six[number1]) a = a + 1 elif secret<=10: number2 = random.randint(0,47) print(five[number2]) b = b + 1 elif secret<=60: number3 = random.randint(0,36) print(four[number3]) c = c + 1 else: number4 = random.randint(0,16) print(three[number4]) d = d + 1 else: if 1 <= secret <= 2 * (luck-49): number5 = random.randint(0,26) print(six[number5]) luck = 0 a = a + 1 elif secret <= 2 * (luck-49) +8: number6 = random.randint(0,47) print(five[number6]) b = b + 1 elif secret <= 2 * (luck-49) +58: number7 = random.randint(0,36) print(four[number7]) c = c + 1 else: number8 = random.randint(0,16) print(three[number8]) d = d + 1 luck = luck + 1 print(" The card drawing is over , Six stars in total " + str(a) + " individual , Five stars " + str(b) + " individual , Four stars " + str(c) + " individual , samsung " + str(d) + " individual , Draw out the six star ratio "+ str(a/n)) p = a / n if p > 0.02: print(" Yes ") else: print(" Oh, Ho ") |
4 Conclusion
For the card drawing problem , Put forward the use of random Function method , Through this experiment , The method is proved to be effective , What are the shortcomings or thoughtlessness of this method , What problems can we continue to study in the future .
边栏推荐
- Select user stories | the false positive rate of hole state in jushuitan is almost 0. How to do this?
- [error reporting]: cannot read properties of undefined (reading 'prototype')
- Laozi cloud and Fuxin Kunpeng achieved a major breakthrough in 3D ofd 3D format documents for the first time
- Sub database and sub table
- 知识点总结(一)
- Transaction database and its four characteristics, principle, isolation level, dirty read, unreal read, non repeatable read?
- 集合框架的使用
- Installation and template setting of integrated development environment pychar
- 34. 分析flexible.js
- Complete Binary Tree
猜你喜欢

Mysql表的约束

Reproduce ssa-gan using the nine day deep learning platform

Sunyanfang, co-founder of WeiMiao: take compliance as the first essence and become the "regular army" of financial and business education

Introduction to Kali system ARP (network disconnection sniffing password packet capturing)

Acticiti中startProcessInstanceByKey方法在variable表中的如何存储
![[acwing] solution to the 61st weekly match](/img/31/765f4ce9f779e8093668e7606e0198.png)
[acwing] solution to the 61st weekly match

The execution process of a select statement in MySQL

Tcp server是如何一个端口处理多个客户端连接的(一对一还是一对多)

How to sinicize the JMeter interface?

QT menu bar, toolbar and status bar
随机推荐
Acticiti中startProcessInstanceByKey方法在variable表中的如何存储
深入 Qt5 信号槽新语法
老子云携手福昕鲲鹏,首次实现3D OFD三维版式文档的重大突破
Detailed description of binary search tree
Invert a Binary Tree
树莓派输出PWM波驱动舵机
ssm框架整合
The execution process of a select statement in MySQL
Raspberry pie output PWM wave to drive the steering gear
Constraints of MySQL table
Li Kou achieved the second largest result
《Robust and Precise Vehicle Localization based on Multi-sensor Fusionin Diverse City Scenes》翻译
再一个技巧,每月稳赚3万+
Two dimensional array summation exercise
抽卡程序模拟
What is the future development direction of software testing engineers?
动态内存函数的介绍(malloc free calloc realloc)
Detailed explanation of mvcc and its principle
Laozi cloud and Fuxin Kunpeng achieved a major breakthrough in 3D ofd 3D format documents for the first time
[untitled] I is circularly accumulated under certain conditions. The condition is usually the length of the loop array. When it exceeds the length, the loop will stop. Because the object cannot judge