コード例 #1
0
#Last Updated: 8/26/17
import utils
import DataModel
import pdb
import traceback
import firebaseCommunicator
PBC = firebaseCommunicator.PyrebaseCommunicator()


def mapFuncForCalcAvgsForTeam(team, func, **calcDatas):
    [
        team.calculatedData.__dict__.update({k: func(dataFunc)})
        for k, dataFunc in calcDatas.items()
    ]


def firstCalculationDict(team, calc):
    cd = team.calculatedData
    mapFuncForCalcAvgsForTeam(
        team,
        lambda f: calc.getAverageForDataFunctionForTeam(team, f),
        avgHighShotsTele=lambda tm: tm.calculatedData.numHighShotsTele,
        avgHighShotsAuto=lambda tm: tm.calculatedData.numHighShotsAuto,
        avgLowShotsAuto=lambda tm: tm.calculatedData.numLowShotsAuto,
        avgLowShotsTele=lambda tm: tm.calculatedData.numLowShotsTele,
        incapacitatedPercentage=lambda tm: tm.didBecomeIncapacitated,
        disabledPercentage=lambda tm: tm.didStartDisabled,
        liftoffPercentage=lambda tm: tm.didLiftoff,
        avgAgility=lambda tm: tm.rankAgility,
        avgSpeed=lambda tm: tm.rankSpeed,
        avgGearGroundIntakesTele=lambda tm: tm.numGroundGearIntakesTele,
コード例 #2
0
#Last Updated: 8/26/17
import TBACommunicator
import numpy as np
from schemaUtils import SchemaUtils
import DataModel 
import firebaseCommunicator as f
import Math

#Taking data from TBA, setting up the schemaUtils class, and defining variables to use later on
comp = DataModel.Competition(f.PyrebaseCommunicator())
calculator = Math.Calculator(comp)
su = SchemaUtils(comp, calculator) #Add actual parameters before competition
TBA = TBACommunicator.TBACommunicator()
listOfMatches = TBA.makeEventMatchesRequest()
teamsToListPlacement = {}
listOfTeams = TBA.makeEventTeamsRequest()

#Creates the base array to be added to later
matrix = np.zeros((len(listOfTeams), len(listOfTeams)), dtype = np.int)
print(listOfTeams)

#Enumerates each team from the list of teams into teamsToListPlacement
for listPlacement in range(0, (len(listOfTeams) - 1)): teamsToListPlacement[listOfTeams[listPlacement]] = listPlacement

#Iterates through all of the matches and adds to the matrix
for match in listOfMatches:
	for team in su.teamsInMatch(match):
		if getTeamAllianceIsRedInMatch(team, match) == True:
			for allianceTeam in getAllianceInMatch(match, True):
				matrix[teamsToListPlacement.get(team)][teamsToListPlacement.get(allianceTeam)] += 1
		elif getTeamAllianceIsRedInMatch(team, match) == False: