예제 #1
0
def get_matches_by_id(match_ids):
    """
    Returns match data for each match_id in the list match_ids
    """
    dbName = "competitiveGameData.db"
    conn = sqlite3.connect("tmp/"+dbName)
    cur = conn.cursor()
    match_data = []
    for match_id in match_ids:
        match = dbo.get_match_data(cur, match_id)
        match_data.append(match)
    conn.close()
    return match_data
예제 #2
0
def build_match_pool(num_matches, randomize=True):
    """
    Args:
        num_matches (int): Number of matches to include in the queue (0 indicates to use the maximum number of matches available)
        randomize (bool): Flag for randomizing order of output matches.
    Returns:
        match_data (dictionary): dictionary containing two keys:
            "match_ids": list of match_ids for pooled matches
            "matches": list of pooled match data to process

    Builds a set of matchids and match data used during learning phase. If randomize flag is set
    to false this returns the first num_matches in order according to the tournaments list.
    """
    dbName = "competitiveGameData.db"
    conn = sqlite3.connect("tmp/"+dbName)
    cur = conn.cursor()
    patches = [
        "8.2",
        "8.3"
    ]
    tournaments = [
        "2018/EU/Spring_Season",
        "2018/NA/Spring_Season",
        "2018/LCK/Spring_Season",
        "2018/LPL/Spring_Season",
        "2018/LMS/Spring_Season",
        "2018/NA_ACA/Spring_Season",
        "2018/KR_CHAL/Spring_Season"
    ]
    match_pool = []
    # Build list of eligible match ids
    for patch in patches:
        for tournament in tournaments:
            game_ids = dbo.get_game_ids_by_tournament(cur, tournament, patch="8.2")
            match_pool.extend(game_ids)

    print("Number of available matches for training={}".format(len(match_pool)))
    if(num_matches == 0):
        num_matches = len(match_pool)
    assert num_matches <= len(match_pool), "Not enough matches found to sample!"
    if(not randomize):
        selected_match_ids = match_pool[:num_matches]
    else:
        selected_match_ids = random.sample(match_pool, num_matches)

    selected_matches = []
    for match_id in selected_match_ids:
        match = dbo.get_match_data(cur, match_id)
        selected_matches.append(match)
    conn.close()
    return {"match_ids":selected_match_ids, "matches":selected_matches}
예제 #3
0
#with open('worlds_matchids_by_stage.txt','r') as infile:
#    data = json.load(infile)
#match_ids = data["groups"]
#match_ids.extend(data["knockouts"])
#match_ids.extend(data["finals"])
#match_ids.extend(data["play_ins_rd1"])
#match_ids.extend(data["play_ins_rd2"])
with open('match_pool.txt', 'r') as infile:
    data = json.load(infile)
match_ids = data['validation_ids']
#match_ids.extend(data['training_ids'])
dbName = "competitiveGameData.db"
conn = sqlite3.connect("tmp/" + dbName)
cur = conn.cursor()
#match_ids = dbo.get_game_ids_by_tournament(cur,"2017/INTL/WRLDS")
matches = [dbo.get_match_data(cur, match_id) for match_id in match_ids]
conn.close()
if (specific_team):
    matches = [
        match for match in matches if (match["blue_team"] == specific_team
                                       or match["red_team"] == specific_team)
    ]

count = 0
print("************************")
print("Match Schedule:")
print("************************")
with open("{}/_match_schedule.txt".format(out_dir), 'w') as outfile:
    outfile.write("************************\n")
    for match in matches:
        output_string = "Match {:2}: id: {:5} tourn: {:20} game_no: {:3} {:6} vs {:6} winner: {:2}".format(
예제 #4
0
        print("Committing changes to db..")
        conn.commit()

    query = ("SELECT game_id, champion_id, selection_order, side_id"
             "  FROM ban"
             " WHERE game_id = 1 AND side_id = 0")
    df = pd.read_sql_query(query, conn)
    print(df)

    query = (
        "SELECT game.tournament, game.tourn_game_id, blue.team, red.team, ban.side_id,"
        "       ban.champion_id AS champ, ban.selection_order AS ord"
        "  FROM (game "
        "       JOIN (SELECT id, display_name as team FROM team) AS blue"
        "         ON game.blue_teamid = blue.id)"
        "       JOIN (SELECT id, display_name as team FROM team) AS red"
        "         ON game.red_teamid = red.id"
        "  LEFT JOIN (SELECT game_id, side_id, champion_id, selection_order FROM ban) AS ban"
        "         ON game.id = ban.game_id"
        "  WHERE game.id IN (SELECT game_id FROM ban WHERE champion_id IS ?)")
    params = (None, )
    db = pd.read_sql_query(query, conn, params=params)
    print(db)

    gameIds = dbo.get_game_ids_by_tournament(cur, "2017/INTL/WRLDS")
    for i in gameIds:
        match = dbo.get_match_data(cur, i)
        print("{} vs {}".format(match["blue_team"], match["red_team"]))
    print("Closing db..")
    conn.close()