Пример #1
0
 def apply(cls, match, result=None, offset=0, team=None):
     result = result or cls.DEFAULT
     gameday = GameDay.get(match.gameday)
     previous_gameday = gameday.get_previous()
     if team:
         if team in match["home"]:
             return result, False, False
         elif team in match["guest"]:
             return tuple(reversed(result)), False, False
     if previous_gameday:
         r_home = previous_gameday['ranking'][match["home"]] - offset
         r_guest = previous_gameday['ranking'][match["guest"]]
         if r_home < r_guest:
             return result, False, False
         else:
             return tuple(reversed(result)), r_home == r_guest, False
     else:
         return result, False, True
Пример #2
0
            "match": match.url,
            "algorithm": name,
            "result": result
        }
        return Tipp(data)


def get_all_subclasses(cls):
    for c in cls.__subclasses__():
        yield c
        for c in get_all_subclasses(c):
            yield c

ALGOS = [x() for x in get_all_subclasses(Algorithm)]
OFFSETS = [3, 4, 8, 11, 12, 13]
TOP_RESULTS = [[1, 0], [2, 1], [2, 0]]
TEAMS = [None, "bayern-muenchen", "hannover-96", "borussia-dortmund", "vfl-wolfsburg", "hamburg"]

if __name__ == "__main__":
    season = Season.from_data("bundesliga", (2011, 2012))
    for i in range(0, 34):
        url = GameDay.get_url(season, i + 1)
        day = GameDay.get(url)
        for m in day.get_matches():
            for r in TOP_RESULTS:
                for i in OFFSETS:
                    for x in ALGOS:
                        for t in TEAMS:
                            x.TEAM = t
                            x.store_result(m, result_fix=r, offset=i)