Exemple #1
0
 def detectgame(self, gm, playeres, season=0):
     game = Game(gm[:-7], 'playoff' if self.RoP else 'regular')
     for qtr in range(3, game.quarters):
         for ply in game.yieldPlay(qtr):
             play = Play(ply, qtr)
             if play.time() <= MPTime(self.lm):  # 在规定时间内
                 rec, ind = play.record()
                 s = play.score(ind=ind)
                 if s and play.diffbeforescore(s) <= self.dp:
                     try:
                         p = self.pm2pn[rec.split(' ')[0]]
                     except KeyError:
                         p = rec.split(' ')[0]
                     if season:
                         p += ' %d_%d' % (season, season + 1)
                     if p not in playeres:
                         playeres[p] = np.zeros((1, len(self.columns)))
                     if 'makes' in rec:  # 得分增加命中数
                         playeres[p][0, 0] += s
                         playeres[p][0, s * 3 - 1] += 1
                         if 'assist' in rec:  # 受助攻
                             playeres[p][0, s + 11] += 1
                             playeres[p][0, 15] += 1
                             try:
                                 astp = self.pm2pn[rec.split(' ')[-1][:-1]]
                             except:
                                 astp = rec.split(' ')[-1][:-1]
                             if season:
                                 astp += ' %d_%d' % (season, season + 1)
                             if astp not in playeres:
                                 playeres[astp] = np.zeros(
                                     (1, len(self.columns)))
                             playeres[astp][0, s + 14] += 1
                             playeres = self.onlycountonce(
                                 astp, gm[:-7], playeres)
                     playeres[p][0, s * 3] += 1  # 得分或投失增加出手数
                     playeres = self.onlycountonce(p, gm[:-7], playeres)
                     # if 'LeBron James' in p and season == 2019:
                     #     print(s, play.play, gm[:-7], self.plyrcgs['LeBron James 2019_2020'])
     return playeres
Exemple #2
0
max_diff = 40
diff_inter = 5
# 1、2、3分 x 命中数、出手数 x -40~40分差 x 间隔统计时间
shoots = np.zeros((3, 2, max_diff * 2 // diff_inter + 1, whole // inter))
prctg = np.zeros((3, max_diff * 2 // diff_inter + 1, whole // inter))

for season in player.yieldSeasons():
    for gameInf in player.yieldGames(season):
        # score += int(gameInf[26])
        gm = gameInf[1]
        team = gameInf[3]
        op = gameInf[5]
        game = Game(gm, ROP, team, op)

        for qtr in range(game.quarters):
            for playInf in game.yieldPlay(qtr):
                play = Play(playInf, qtr, pm=pm, HOA=game.HOA)
                if play.playRecord() and play.teamPlay():
                    if play.playerAst():  # 助攻
                        asts += 1
                    elif play.playerMadeShoot():  # 命中投篮
                        s, d, t = score_diff_time(play, game, max_diff)
                        d -= s  # 关注的是球员得分前的分差
                        score += s
                        t = tailTime(t, inter_s)
                        d = groupDiff(d + 40, max_diff, diff_inter)
                        shoots[s - 1, 0, d, t] += 1
                        shoots[s - 1, 1, d, t] += 1
                    elif play.playerMissShoot():  # 投丢投篮
                        s, d, t = score_diff_time(play, game, max_diff)
                        t = tailTime(t, inter_s)