コード例 #1
0
ファイル: tools.py プロジェクト: SYW23/NBA_stat
 def display_pbp(self):
     gm = self.gm.get()
     if gm:
         try:
             self.gameflow = LoadPickle(gameMarkToDir(gm, 'regular'))
             self.file_name = gameMarkToDir(gm, 'regular')
         except:
             self.gameflow = LoadPickle(gameMarkToDir(gm, 'playoff'))
             self.file_name = gameMarkToDir(gm, 'playoff')
         try:
             box = LoadPickle(gameMarkToDir(gm, 'regular', tp=2))
         except:
             box = LoadPickle(gameMarkToDir(gm, 'playoff', tp=2))
         # self.columns[1], self.columns[5] = ts[0], ts[1]
         print(box[0])
         self.qtrs = len(self.gameflow)
         self.qtr_btns = []
         for i in range(self.qtrs):
             self.qtr_btns.append(
                 Radiobutton(self.qtr_fm,
                             text=self.qtr_text[i],
                             value=i,
                             command=self.qtr_dsp,
                             variable=self.qtr,
                             width=10,
                             height=2))
             self.qtr_btns[i].grid(row=1, column=i)
         if self.title == 'play-by-play修改器':
             self.qtr.set('0')
         else:
             self.qtr.set(str(int(self.title[1]) - 1))
             self.RoW()
         self.qtr_dsp(ori=1)
     else:
         messagebox.showinfo('提示', '请输入game mark!')
     pass
コード例 #2
0
    line = r['R'][RoH]
    return sorted(line, reverse=True)


lines_all = LoadPickle('./data/Lineups/anaSeason5Lineups.pickle')
for season in range(2020, 2021):
    ss = '%d_%d' % (season, season + 1)
    for i in range(2):
        lines_all[i][ss] = {}
        lines = {
        }  # {'tm1': {'line1': ['sum_time', '+/-'], 'line2': ['sum_time', '+/-'] ...}, 'tm2': ...}
        gms = os.listdir('D:/sunyiwu/stat/data/seasons/%s/%s/' %
                         (ss, regularOrPlayoffs[i]))
        for gm in tqdm(gms):
            game = Game(gm, regularOrPlayoffs[i])
            record = LoadPickle(gameMarkToDir(gm, regularOrPlayoffs[i], tp=3))
            rot = game.rotation(record)
            bxs, rot = game.replayer(record, rot)
            et = '%d:00.0' % (48 + 5 * (game.quarters - 4))
            for tmix, tm in enumerate(list(game.bxscr[0])):  # 分别回溯两支球队
                if tm not in lines:
                    lines[tm] = {}
                RoH = list(game.bxscr[0]).index(tm)
                for ix, r in enumerate(rot):
                    line = inline(r)
                    if ' '.join(line) not in lines[tm]:
                        lines[tm][' '.join(line)] = [
                            MPTime('0:00.0'), 0,
                            [np.zeros((21, )),
                             np.zeros((21, ))]
                        ]  # 0时间 1+/- 2详细数据   0本队数据1对手数据
コード例 #3
0
    count_games = [0, 0]  # 0reg1plf
    count_item = np.zeros(
        (2, 3,
         9))  # 0reg1plf    0客场球队1主场球队2总    0总1第一节2第二节3第三节4第四节5f加时6s加时7t加时8f加时
    count_score = np.zeros((2, 3, 9))
    ss = '%d_%d' % (season, season + 1)
    # print(ss)
    for i in range(2):  # 分别统计常规赛、季后赛
        gms = os.listdir('D:/sunyiwu/stat/data/seasons/%s/%s/' %
                         (ss, regularOrPlayoffs[i]))
        for gm in tqdm(gms):
            count_games[i] += 1
            game = Game(gm[:-7], regularOrPlayoffs[i])
            gameplyrs = game.teamplyrs()
            record = LoadPickle(
                gameMarkToDir(gm[:-7], regularOrPlayoffs[i], tp=3))
            zoom = 0
            bp = -1
            pm = ''
            for rec in record:
                if tar_sn[tar_item] in rec:
                    pm = tar_sn[tar_item]
                    pmd = rec[KoS[tar_item]][0]
                    s = rec[KoS[tar_item]][1]

                    count_item[i][0 if rec['BP'] else 1][0] += 1
                    count_item[i][0 if rec['BP'] else 1][rec['Q'] + 1] += 1
                    count_item[i][2][0] += 1
                    count_item[i][2][rec['Q'] + 1] += 1
                    count_score[i][0 if rec['BP'] else 1][0] += s
                    count_score[i][0 if rec['BP'] else 1][rec['Q'] + 1] += s
コード例 #4
0
ファイル: playerSeasonAreaPct.py プロジェクト: SYW23/NBA_stat
        if int(i[6]) >= 1997 and playerMark in top250:
            players.append([playerName, playerMark])

#%%
regularOrPlayoff = 1
ROP = regularOrPlayoffs[regularOrPlayoff]
for i in players:
    print("Analysing player: %s ..." % i[0])
    player = Player(i[1], ROP)
    missing_shot = 0
    areaPct = np.zeros((21,3))    #0miss1make
    for season in player.yieldSeasons():
        for gameInf in player.yieldGames(season):
            gameMark, team = gameInf[1], gameInf[3]
            # 读取比赛文件
            gameDir = gameMarkToDir(gameMark, ROP)
            gameDir_shot = gameMarkToDir(gameMark, ROP, shot=True)
            playerGame = LoadPickle(gameDir)
            playerGame_shot = LoadPickle(gameDir_shot)
            index_shot = 0
            # 判断主客场
            HOA = 1 if team == gameMark[-3:] else 0    # 0客1主
            HomeOrAt = HomeOrAts[HOA-1]
            for index, quarter in enumerate(playerGame):
                for play in quarter:
                    if len(play) == 6:
                        if play[HomeOrAt[1]]:
                            playerPlayed = play[HomeOrAt[1]].split(' ')[0]
                            if playerPlayed == i[1] and (play[HomeOrAt[0]] or 'misses' in play[HomeOrAt[1]]):
                                # 此球员有得分/错失得分
                                score = 0
コード例 #5
0
ファイル: Shooting.py プロジェクト: SYW23/NBA_stat
 def __init__(self, gm, ROP, HOA=None):
     self.gamemark = gm
     self.gameflow = LoadPickle(gameMarkToDir(gm, ROP, shot=True))
     self.HOA = HOA if HOA != None else None