模擬體育電子競技

2022-09-10 01:24:40 字數 3831 閱讀 5183

單打:

from random import random

def printintro():

print("2020310143123")

def getinputs():

a = eval(input("請輸入隊伍a的能力值(0-1): "))

b = eval(input("請輸入隊伍b的能力值(0-1): "))

n = eval(input("模擬比賽的場次: "))

return a, b, n

def simngames(n, proba, probb):

winsa, winsb = 0, 0

for i in range(n):

for j in range(7):

scorea, scoreb = simonegame(proba, probb)

if scorea > scoreb:

winsa += 1

else:

winsb += 1

return winsa, winsb

def gameover(a, b):

return a == 11 or b == 11

def gameover2(a, b):

return a == 12 or b == 12

def simonegame(proba, probb):

scorea, scoreb = 0, 0

serving = "a"

while not gameover(scorea, scoreb):

if scorea == 10 and scoreb == 10:

return(simtwogame2(proba,probb))

if serving == "a":

if random() < proba:

scorea += 1

else:

serving = "b"

else:

if random() < probb:

scoreb += 1

else:

serving="a"

return scorea, scoreb

def simtwogame2(proba,probb):

scorea, scoreb=10, 10

serving = "a"

while not gameover2(scorea, scoreb):

if serving == "a":

if random() < proba:

scorea += 1

else:

serving = "b"

else:

if random() < probb:

scoreb += 1

else:

serving = "a"

return scorea, scoreb

def printsummary(winsa, winsb):

n = winsa + winsb

print("競技分析開始,共模擬{}場比賽".format(n))

print("隊伍a獲勝{}場比賽,佔比".format(winsa, winsa/n))

print("隊伍b獲勝{}場比賽,佔比".format(winsb, winsb/n))

團體:from random import random

def printintro():

print("2020310143123")

def getinputs():

a = eval(input("請輸入隊伍a的能力值(0-1): "))

b = eval(input("請輸入隊伍b的能力值(0-1): "))

n = eval(input("模擬比賽的場次: "))

return a, b, n

def simngames(n, proba, probb):

winsa, winsb = 0, 0

for i in range(n):

for j in range(5):

scorea, scoreb = simonegame(proba, probb)

if scorea > scoreb:

winsa += 1

else:

winsb += 1

return winsa, winsb

def gameover(a, b):

return a == 11 or b == 11

def gameover2(a, b):

return a == 12 or b == 12

def simonegame(proba, probb):

scorea, scoreb = 0, 0

serving = "a"

while not gameover(scorea, scoreb):

if scorea == 10 and scoreb == 10:

return(simtwogame2(proba,probb))

if serving == "a":

if random() < proba:

scorea += 1

else:

serving = "b"

else:

if random() < probb:

scoreb += 1

else:

serving="a"

return scorea, scoreb

def simtwogame2(proba,probb):

scorea, scoreb=10, 10

serving = "a"

while not gameover2(scorea, scoreb):

if serving == "a":

if random() < proba:

scorea += 1

else:

serving = "b"

else:

if random() < probb:

scoreb += 1

else:

serving = "a"

return scorea, scoreb

def printsummary(winsa, winsb):

n = winsa + winsb

print("競技分析開始,共模擬{}場比賽".format(n))

print("隊伍a獲勝{}場比賽,佔比".format(winsa, winsa/n))

print("隊伍b獲勝{}場比賽,佔比".format(winsb, winsb/n))

模擬體育競技

encoding utf 8 模擬羽毛球競技 比賽規則 2.前四局採用21分制,每個隊只有在贏得至少21分,且同時超過對方2分時才勝一局 from random import random from time import time def printinfo function 列印程式的介紹資訊 ...

模擬體育競技

一.體育競技分析的ipo模式 輸入i input 兩個球員的能力值,模擬比賽的次數 其中,運動員的能力值,可以通過發球方贏得本回合的概率來表示,乙個能力值為0.8的球員,在他發球時,有80 的可能性贏得1分 處理p process 模擬比賽過程 輸出o output 兩個球員獲勝的概率 自頂向下的設...

南韓何以成為電子競技強國

南韓何以成為電子競技強國 如果把南韓稱之為現代電子競技的發源地我想一點都不為過,從最初將星際爭霸從遊戲上公升到競技的高度開始,南韓的電子競技產業就一直扶搖直上,最終成為與汽車,鋼鐵等產業並列的國民經濟的支柱之一。而電子競技也與圍棋,足球並稱為南韓的三大國技。如今的南韓可以算得上是名副其實的電子競技強...