Ejemplo n.º 1
0
 def __init__(self, window):
     self.teamleft = Team()
     self.teamright = Team()
     self.time = Timer(path="Output/Timer.txt", upCounting=True)
     self.window = window
     self.penalty = {
     }  # all information about a specific penalty will be saved in this dict
    def setUpClass(cls):
        print("setUpClass()")
        cls.arena = Arena.Arena().get()

        # create some pokemon and teams
        cls.p1 = Pokemon.Pokemon("Charizard", 15, "Fire", 100, 150, 50)
        cls.p2 = Pokemon.Pokemon("Pikachu", 1, "Electric", 50, 50, 25)
        cls.p3 = Pokemon.Pokemon("Squirtle", 23, "Grass", 75, 85, 30)
        cls.p4 = Pokemon.Pokemon("Machamp", 5, "Fighting", 50, 75, 45)
        cls.p5 = Pokemon.Pokemon("Charmander", 13, "Fire", 50, 100, 40)
        cls.p6 = Pokemon.Pokemon("Digglet", 151, "Earth", 50, 75, 35)

        cls.p7 = Pokemon.Pokemon("Ghastly", 150, "Fire", 100, 150, 50)
        cls.p8 = Pokemon.Pokemon("Raichu", 12, "Electric", 50, 50, 25)
        cls.p9 = Pokemon.Pokemon("Bulbasaur", 24, "Grass", 75, 80, 30)
        cls.p10 = Pokemon.Pokemon("Machop", 50, "Fighting", 55, 75, 45)
        cls.p11 = Pokemon.Pokemon("Charmander", 17, "Fire", 50, 100, 40)
        cls.p12 = Pokemon.Pokemon("Dugtrio", 78, "Earth", 50, 75, 35)

        cls.p13 = Pokemon.Pokemon("Ghastly", 150, "Fire", 100, 150, 50)
        cls.p14 = Pokemon.Pokemon("Raichu", 12, "Electric", 50, 50, 25)
        cls.p15 = Pokemon.Pokemon("Bulbasaur", 24, "Grass", 75, 80, 30)
        cls.p16 = Pokemon.Pokemon("Machop", 50, "Fighting", 55, 75, 45)
        cls.p17 = Pokemon.Pokemon("Charmander", 17, "Fire", 50, 100, 40)
        cls.p18 = Pokemon.Pokemon("Dugtrio", 78, "Earth", 50, 75, 35)

        cls.teamOne = Team.Team(cls.p1, cls.p2, cls.p3, cls.p4, cls.p5, cls.p6)
        cls.teamTwo = Team.Team(cls.p7, cls.p8, cls.p9, cls.p10, cls.p11,
                                cls.p12)
        cls.teamThree = Team.Team(cls.p13, cls.p14, cls.p15, cls.p16, cls.p17,
                                  cls.p18)
Ejemplo n.º 3
0
 def __init__(self):
     ''' Constructor: TeamGenerator() '''
     self.teamA = Team.Team({'name': 'A-Team', 
                             'players': []
                             })
     self.teamB = Team.Team({'name': 'B-Team', 
                             'players': []
                             })
     self.fullTeam = Team.Team({'name': 'Full-Team', 
                             'players': []
                             })
Ejemplo n.º 4
0
 def __init__(self):
     self.__teamHero = Team()
     self.initTeam()
     self.__map = Map()
     self.__etage = 1
     self.__tailleMapX = 5
     self.__tailleMapY = 5
     self.__map.genererMap(self.__tailleMapX, self.__tailleMapY)
     self.end = 0
     self.bossTue = False  #le boss de l'étage est mort?
     while (self.end != 1):
         self.end = self.tour()
 def gen_teams(self, teams_file):
     team_data_base = open(teams_file, "r")
     team_data = team_data_base.read().split("\n")
     team = Team([])
     for line in team_data:
         if line == "":
             self.teams += [team]
             team = Team([])
         elif is_int(line):
             team.wins = int(line)
         else:
             card = Card(line.lower(), 0)
             team.cards += [card]
     team_data_base.close()
Ejemplo n.º 6
0
def testMatchMenu():
    print("|Test Match|")
    print("What is the first team's name?")
    t1Name = input(">")
    print("What is their overall rating?")
    t1Ovr = input(">")
    print("What is the second team's name?")
    t2Name = input(">")
    print("What is their overall rating?")
    t2Ovr = input(">")

    t1 = Team(t1Name, int(t1Ovr))
    t2 = Team(t2Name, int(t2Ovr))
    testMatch(t1, t2)
Ejemplo n.º 7
0
class Match(object):
    teams = {'team1': Te.Team(), 'team2': Te.Team()}
    idCounter = 0

    def __init__(self, team1=-1, team2=-1):
        teams = {team1, team2}
        Match.idCounter += 1
        self.id = Match.idCounter

    def getMatchMMR(self):
        return self.teams['team1'].getTeamMMR(
        ) + self.teams['team2'].getTeamMMR()

    def __str__(self):
        print("test")
Ejemplo n.º 8
0
    def do_t(self, line):
        teams = dict()  # Name of team, then data
        line = line.split(' ')

        n_games = line[-1][1:]

        try:
            n_games = int(n_games)
            line = line[0:-1]
        except Exception:
            self.default(f'team {line}')
            self.cmdloop()

        found_teams = True
        for team_nickname in line:
            try:
                tmp = Team(team_nickname, n_games)
                teams[team_nickname] = tmp
                print(f"Loaded {team_nickname} stats")
            except Exception:
                print(f"Unable to load {team_nickname} stats")
                found_teams = False

        if found_teams:
            TeamCmd(teams).cmdloop()
        else:
            self.cmdloop()
Ejemplo n.º 9
0
    def __init__(self, tresc_stronki_z_wynikami, druzyny, kraj, liga, sezon):
        years = []
        self.teams = []
        self.team_names = []
        results = []
        half = ""
        whole = ""
        file = 0
        workarea = False
        print("tworze wyluskiwacz wynikow")

        self.team_names = druzyny

        w_tabeli = False
        url = "results_tmp"
        plik_tmp = open(url, "w")
        plik_tmp.write(tresc_stronki_z_wynikami)
        self.znacznik_poczatka_wynikow = "FT"
        self.zespoly = []
        plik_tmp.close()

        self.file = open(url)
        i = 0
        print(self.team_names)

        for name in self.team_names:
            t = Team(name, sezon, kraj, liga)
            self.teams.append(t)
Ejemplo n.º 10
0
def fill_teams():
    global expected, num_teams
    expected = 0
    num_teams = 0
    while expected <= 0:
        expected = int(input("Number of expected students (>1): "))

    while num_teams <= 0 or num_teams > 9:
        num_teams = int(input("Number of teams per color (1-9): "))
    n = 0
    for c in range(0, 5):
        for i in range(0, num_teams):
            t = tm.Team(expected, num_teams)
            t.set_color(colors[c])
            t.set_num(i + 1)
            # fill graph
            G.add_node(n,
                       name=colors[c] + ' ' + str(i + 1),
                       color=colors[c],
                       number=(i + 1),
                       members=[],
                       score=math.floor(t.score() * .7),
                       max=t.score())
            n += 1
            teams.append(t)

    # create edges once the nodes are created
    n = 0
    for c in range(0, 5):
        for i in range(0, num_teams):
            G.add_edge(n, num_teams)
            if n < 5 * num_teams - 1:
                G.add_edge(n, n + 1)
            n += 1
Ejemplo n.º 11
0
 def createTeam(self, name, rating=0):
     """
     Create a team and add it to the currently opened tournament
     :param name: the name of the team.
     :param rating: a rating of the team's playing strength.
     """
     self.tournament.addTeam(Team.Team(name, rating))
Ejemplo n.º 12
0
def match_students(students, projects):
    G = create_graph(students, projects)
    teams = []
    flow_value, flow_dict = nx.maximum_flow(G,
                                            'source',
                                            'sink',
                                            capacity='capacity',
                                            flow_func=edmonds_karp)
    R = edmonds_karp(G, 'source', 'sink', capacity='capacity')
    team_number = 1
    matched_students = []
    for p in projects:
        studs = []
        for s in students:
            if s.assigned == True:
                if p.project_id in flow_dict[s.email]:
                    if flow_dict[s.email][p.project_id] == 1.0:
                        studs.append(s)
                        matched_students.append(s)
        teams.append(Team(p, studs, team_number))
        team_number = team_number + 1
    students_left = find_non_matched_students(R, students, matched_students)
    avaliable_projects = find_avaliable_projects(R, projects)
    if len(students_left) > 0:
        teams = match_remaining_students(teams, G, flow_dict, students_left,
                                         avaliable_projects, projects)
    return teams
Ejemplo n.º 13
0
class Player:
    '''This object containts all qualities of a player. These qualities are saved:
       age
       height
       weight
       overall
       position
       Also it containts the team the player belongs to, with datatype 'Team'
    '''
    name = "None"
    team = Team.Team("None")
    age = -1
    height = -1.0
    weight = -1.0
    overall = -1
    position = "None"

    def __init__(self, name, team, age, height, weight, overall, position):
        self.name = name
        self.team = team
        self.age = age
        self.height = height
        self.weight = weight
        self.overall = overall
        self.position = position

    def __str__(self):
        return self.name
Ejemplo n.º 14
0
def read_matched_students(file):
    with open(file, 'r', encoding='utf-8-sig') as csvfile:
        # create csvread obj
        csvread = csv.reader(csvfile)
        t = 0
        line_count = 0
        teams = []
        team_number = ''
        project_id = ''
        organization_name = ''
        client_first_name = ''
        client_last_name = ''
        client_email = ''
        project_title = ''
        studs = []
        for row in csvread:
            if line_count == 0:
                line_count = line_count + 1
            else:
                if t != int(row[4]):
                    if t != 0:
                        team = Team(
                            Project(project_id, organization_name,
                                    client_first_name, client_last_name,
                                    client_email, project_title), studs,
                            team_number)
                        teams.append(team)
                    studs = []
                    t = int(row[4])
                    team_number = str(t)
                    project_id = row[5]
                    organization_name = row[6]
                    client_first_name = row[7]
                    client_last_name = row[8]
                    client_email = row[9]
                    project_title = row[10]
                studs.append(
                    new_Student(row[0], '1', row[1], row[2], row[3], 'Yes',
                                'n/a', True))
                line_count = line_count + 1
        team = Team(
            Project(project_id, organization_name, client_first_name,
                    client_last_name, client_email, project_title), studs,
            team_number)
        teams.append(team)
        return teams
Ejemplo n.º 15
0
    def read(self, dev):
        self.dev = []
        self.teams = []
        
        self.dev = dev

        for team in dev.get_team():
            self.teams.append(Team(team[0]))
def find_pos(find_by, teamNames, teamRank, teamPoints):
    table = []
    for i in range(0, len(teamNames)):
        if find_by == teamNames[i]:
            my_pos = teamRank[i] + '. ' + teamNames[i] + ' with ' + teamPoints[
                i] + 'pts'
    for i in range(0, 5):
        table.append(Team(teamNames[i], teamRank[i], teamPoints[i]))
    return my_pos, table
Ejemplo n.º 17
0
 def add_team(self):
     if self.team_name.get().isspace() or self.team_name.get() == "":
         self.warning_text.set("Name cannot be empty")
         return
     self.team_list.append(Team(self.team_name.get()))
     cur_num = len(self.team_list)
     self.team_list_box.insert(cur_num,
                               f"{cur_num}: " + self.team_name.get())
     self.team_name.set("")
Ejemplo n.º 18
0
def create():
    print("WELCOME TO THE ECOLOGICAL INTERACTIVE GOOSE GAME")
    num_team = int(input("How many teams ?"))
    list_team = list()
    for i in range(num_team):
        team_pawn = get_pawn()
        list_team.append(Team.Team(team_pawn))
    print(" !! AND NOW THE GAME CAN BEGIN !! ")
    return list_team
Ejemplo n.º 19
0
    def transformTeamList(self,team_dict):

        team_coll = []
        for i in team_dict:
            dates = team_dict[i]

            team = Team.Team(i)
            team.set_match_dates(dates)
            team_coll.append(team)
        return team_coll
Ejemplo n.º 20
0
    def __init__(self, x1, x2, window):

        self.window = window
        self.teamup = Team(GameConfig.teamup_vy, GameConfig.teamup_color,
                           GameConfig.teamup_yspawn, None)
        self.teamdown = Team(GameConfig.teamdown_vy, GameConfig.teamdown_color,
                             GameConfig.teamdown_yspawn, self.teamup)

        self.init_players()
        #player=PlayerDown(pygame.K_LEFT,pygame.K_RIGHT,pygame.K_UP,window)
        #self.players.append(player)

        #player=Bot(0,0,0,window)
        #self.players.append(player)

        self.zone = Zone_neutre(GameConfig.zonex1, GameConfig.zoney1,
                                GameConfig.zonex2, GameConfig.zoney2,
                                (GameConfig.zonex2 / 10) * 2, window)
        self.timer = time.time()
Ejemplo n.º 21
0
def get_team_data(year, team):
    """Fetches data for a given team and year, returns a Team object"""
    url = "http://www.cfbstats.com/" + year + "/team/" + str(
        team) + "/index.html"
    response = requests.get(url)
    data = response.text

    souped_data = BeautifulSoup(data, "html.parser")
    tables = souped_data.find_all("table")
    return Team.Team(tables[0], tables[1], tables[2])
Ejemplo n.º 22
0
class Main:

    print(1, 2)
    data = DM.DataManagement()
    data.createTournament(123)
    print(data.tournament)
    tournament = TN.Tournament(1)
    official = Off.Official("Max Mustermann", [1, 2, 3])
    print(type(official.team))
    match = Match.Match(Team.Team("Flying Foxes", tournament),
                        Team.Team("Mighty Ducks", tournament))
    # match.setResult(120,80)
    print(match.getResult())

    example = TN.Tournament("Example tournament")
    foxes = Team.Team("Flying Foxes", example, rating=2100)
    ducks = Team.Team("Mighty Ducks", example, rating=1800)
    example.addTeam(foxes)
    example.addTeam(ducks)
    example.addPhase("Swiss System", 7)
    match2 = Match.Match(foxes, ducks)
    example.getCurrentPhase().addMatch(match)
    example.getCurrentPhase().addMatch(match2)
    for mat in example.getCurrentPhase().matches:
        mat.print()
    algo = Algorithms.Algorithms(None, Scheduling.Scheduling())
    algo.schedule(example.getCurrentPhase())
    print(example.getCurrentPhase().getMatches()[0].getResult())
    match2.setResult((150, 100))
    print(example.getCurrentPhase().getMatches()[0].getResult())
    data.storeTournament(example)

    for mat in example.getCurrentPhase().matches:
        mat.print()

    data.loadTournament("Example tournament")
    tn = data.getTournament()
    print("Serialized")
    print(tn.getIdentifier())
    print(tn.getCurrentPhase())
    print(example.getCurrentPhase())
    print(data.listStoredTournaments())
    def createTeamsAndPopulateList(self, jsonObject: dict):
        """creates the teams objects and populates the lists

        Args:
            jsonObject (dict): json object of teams
        """
        for i in range(0,len(jsonObject)):
            rawTeam = jsonObject.pop()
            userId = rawTeam['user_id']
            displayName = rawTeam['display_name']
            team = Team.Team(userId, displayName)
            self.TeamsDict[team.UserId] = team
Ejemplo n.º 24
0
    def display_result_board(self):
        time.sleep(2)
        print(f'''
                    ------------------------------------------------------------
                        ******** ARENA #{self.counter_arena} RESULTS ********
                    ------------------------------------------------------------
                ''')

        if self.player_team.check_alive_units():
            self.winner = self.player_team
        elif self.enemy_team.check_alive_units():
            self.winner = self.enemy_team
        else:
            self.winner = None
            print(f"There is no winners in this Arena. Both teams are DEAD")

        if self.winner:
            print(f"The winner of #{self.counter_arena} Arena is: ",
                  self.winner.name)

            time.sleep(2)
            print()
            print(f"ALIVE UNITS of {self.winner.name} squad:")
            alive_team_obj = Team.Team(self.winner.make_alive_team(),
                                       self.winner.name)
            alive_team_obj.team_info()

            time.sleep(2)
            print()
            print("DEAD UNITS of {self.winner.name} squad:")
            dead_team_obj = Team.Team(self.winner.dead_team_in_arena(),
                                      self.winner.name)

            if self.winner.dead_team_in_arena() != []:
                dead_team_obj.team_info()
            else:
                print("List of dead is empty")
            print()
            self.fight_counter += 1
Ejemplo n.º 25
0
def team_tests():
    """
    Tests for the Team module.
    """
    print("Starting Team Tests")
    
    import Team
    
    t = Team.create_random_team()
    r = t.get_full_roster()
    s = t.show_roster()
    t.generate_default_lines()
    s = t.show_lines()
    t.add_stat("game", "Goals For", 5)
    assert t.get_stat("game", "Goals For") == 5
    t.add_stat("season", "Wins", 10)
    assert t.get_stat("season", "Wins") == 10
    t.add_stat("playoff", "Losses", 15)
    assert t.get_stat("playoff", "Losses") == 15
    t.add_stat("career", "Goals Against", 20)
    assert t.get_stat("career", "Goals Against") == 20
    s = t.show_team_stats("game")
    s = t.show_team_stats("season")
    s = t.show_team_stats("playoff")
    s = t.show_team_stats("career")
    assert t.get_roster_total("game", "Goals") == 0
    s = t.get_roster_statline("game")
    s = t.get_roster_statline("season")
    s = t.get_roster_statline("playoff")
    s = t.get_roster_statline("career")
    s = t.show_roster_stats("season")
    t.age_year()
    assert t.get_stat("season", "Wins") == 0
    assert t.get_stat("career", "Wins") == 10
    
    import Player
    p = Player.create_random_player()
    assert len(t.get_line("Scratch")) == 1
    t.add_player(p)
    assert p.team == t
    assert len(t.get_line("Scratch")) == 2
    l = t.get_line("L1")
    l[0] = p
    t.set_line("L1", l)    
    t.remove_player(p)
    assert t.get_line("L1")[0] == None
    assert p.team == None
    
    print("Team Tests Passed")
Ejemplo n.º 26
0
def testMatchFromDB():  #load from what the player says to load from
    testLG = League()
    t1 = Team()
    t2 = Team()
    print("|Test Match from Database|")
    print("What is the name of your database? (xml)")
    n = input(">")
    loadDB(n, testLG)
    if (foundFile == True):
        print("What is the first team's id?")
        fID = input(">")
        fID = fID.lower()
        #check for team 1 id and then team 2 id
        print("What is the second team's id?")
        sID = input(">")
        sID = sID.lower()
        t1 = findTeamInDB(testLG, str(fID))
        t2 = findTeamInDB(testLG, str(sID))
        try:
            testMatch(t1, t2)
        except AttributeError:
            print("Valid team ID's must be entered")
    else:
        pass
Ejemplo n.º 27
0
def create_random_league():
    """Create a random league.
    
    This creates a random 32 team league.
    
    Args:
        None
        
    Returns:
        A league consisting of 32 randomly-generated teams consisting of 
        randomly-generated players.
    """
    teams = [Team.create_random_team() for i in range(32)]
    l = League(teams)
    return l
Ejemplo n.º 28
0
 def gererEvent(self, event):
     teamEnnemi = Team()
     if event == "sortie":
         if (self.bossTue == False):
             self.combatDeBoss()
         if (self.bossTue == True):
             print("Voulez-vous continuer? (o : oui, n : non)")
             rep = ""
             while rep not in ["o", "n"]:  #o,n
                 rep = self.getch()
             if rep == "o":
                 self.nouvelleEtage()
     if event == "bagarre":
         teamEnnemi = Team()
         i = randint(1, 3)
         for x in range(0, i):
             teamEnnemi.ajouterPersonnage(self.getEnnemi())
         combat = Combat(self.__teamHero, teamEnnemi)
         combat.lancerCombat()
     if event == "salle cache":
         self.loot("legendaire")
     if event == "cache":
         self.loot("legendaire")
     if event == "garde manger":
         self.loot("normal")
     if event == "buffet":
         self.loot("ressource")
     if event == "cuisine":
         self.loot("normal")
     if (event == "piege"):
         i = randint(0, 1)
         if (i):
             print("Tous les heros perdent 5PV!!!")
             for hero in self.__teamHero.getPersonnages():
                 hero.setPV(hero.getPV() - 5)
                 if (hero.getPV() <= 0):
                     print(hero.getNom() + " a succombé...")
         else:
             print("Des ennemies vous tombent dessus!!!")
             for x in range(0, 3):
                 teamEnnemi.ajouterPersonnage(self.getEnnemi())
             combat = Combat(self.__teamHero, teamEnnemi)
             combat.lancerCombat()
Ejemplo n.º 29
0
def read_csv_data(filename, sport):
    with open(filename) as csv_file:
        csv_reader = csv.reader(csv_file, delimiter=',')

        line_count = 0
        teams = []

        for row in csv_reader:
            if line_count == 0:
                # skip the header row
                line_count += 1
            else:
                name = row[2]
                conference = row[1]
                team = Team.Team(name, sport, conference)
                teams.append(team)
                line_count += 1
    return teams
Ejemplo n.º 30
0
def player_to_team(team_list: list, player: Player):
    i = 0

    for team in team_list:
        if team.name == player.team:
            # Assumption player is not already in team is correct
            # add player to team list
            team_list[i].players.append(player)
            return
        else:
            i += 1

    #create new team in team list
    newteam = Team.Team(player_list[j].team)
    team_list.append(newteam)
    team_list[i].players.append(player)
    #print("Newteam with first player",  player_list[j].team, player.fullname)
    return
Ejemplo n.º 31
0
	def loadDB(self, name, lg): #file name plus league
		try:
			fileName = name 
			fullPath = os.path.abspath(os.path.join('', fileName))
			dom = ElementTree.parse(fullPath)
			leag = dom.findall('league')
			for l in leag:
				n = l.get('name')
				lg.name = n
			teams = dom.findall('league/team') #check teams
			# 'league/conf/team'
			for t in teams:
				n = t.find('name')
				o = t.find('overall')
				id = t.get('id') #id name/number
				c = t.find('conf') # add the conference
				lg.addTeam(Team(n.text, int(o.text), id, c))
			self.foundFile = True
		except FileNotFoundError:
			print(fileName + " does not exist!")
Ejemplo n.º 32
0
time1 = time.time()

gameInfo = GameInfo()

calculator = FactorGraphTrueSkillCalculator()
#

player1 = Player(1)
player2 = Player(2)
#player3 = Player(3)
#player4 = Player(4)
#player5 = Player(5)
#player6 = Player(6)

test1 = Team()
test2 = Team()
#test3 = Team()
#test4 = Team()
#test5 = Team()
#test6 = Team()
test1.addPlayer(player1, Rating(1500.0,500.0))
test2.addPlayer(player2, Rating(1500.0,500.0))
#test3.addPlayer(player3, Rating(27.0,8.0))
#test4.addPlayer(player4, Rating(40.0,5.0))
#test5.addPlayer(player5, Rating(32.0,2.0))
#test6.addPlayer(player6, Rating(24.0,4.0))

print "player 1 : "
print test1.getRating(player1)
print "player 2 : "
Ejemplo n.º 33
0
def generate_standard_inning():
	lineup = Team.generate_uniform_lineup(Batter.generate_standard_batter())
	pitcher = Pitcher.generate_standard_pitcher()
	return Inning(1.0, pitcher, lineup, 0, Game.generate_standard_game())
Ejemplo n.º 34
0
def main(debug=False, disabledCommands=[], reloaded=False):
    if not reloaded:
        h=logging.StreamHandler()
        h.setLevel(logging.DEBUG)
        f=logging.Formatter("[%(name)s] (%(asctime)s) %(levelname)s: %(message)s")
        h.setFormatter(f)
        log.addHandler(h)
        log.setLevel(logging.INFO)
    #We need some special settings. Set it
    Global.set_script_settings()
    for x in dir(LadderLogHandlers):
        if not x[0].isupper():
            continue
        if inspect.isfunction(getattr(LadderLogHandlers,x)):
            x="".join([i.upper() if i.islower() else "_"+i for i in x])
            Armagetronad.SendCommand("LADDERLOG_WRITE"+x+" 1") # X has already a underscore at beginning.
    if not reloaded:
        if Global.debug:
            log.info("Starting in debug mode.")
            Player.enableLogging(logging.DEBUG)
            Team.enableLogging(logging.DEBUG)
            LadderLogHandlers.enableLogging(logging.DEBUG)
            Poll.enableLogging(logging.DEBUG)
        else:
            Player.enableLogging(logging.WARNING)
            Team.enableLogging(logging.WARNING)
            LadderLogHandlers.enableLogging(logging.INFO)
            Poll.enableLogging(logging.WARNING)

    Commands.disabled=Commands.disabled+disabledCommands    
    #Init
    AccessLevel.load()
    if not reloaded:
        log.info("Script started")    
        Armagetronad.PrintMessage("0xff0000Script started")
    else:
        log.info("Script reloaded")
    #We need to refresh player list
    Global.reloadPlayerList()
    while(True):
        line=""
        if Global.handleLadderLog==False:
            time.sleep(1)
            continue
        try:
            line=input()
        except KeyboardInterrupt:
            log.info("Exiting")
            break
        line=line.strip()
        keywords=line.split(" ")
        command=keywords[0]
        args=keywords[1:]
        del keywords
        #make command name CamelCase
        real_commandname=command.upper()
        command=command.lower()
        command=command.replace("_"," ")
        command=command.title()
        command=command.replace(" ","")
        #call handler
        if(hasattr(LadderLogHandlers,command) ):
                getattr(LadderLogHandlers,command)(*args)
        if real_commandname in LadderLogHandlers.extraHandlers:
            for extraHandler in LadderLogHandlers.extraHandlers[real_commandname]:
                try: extraHandler(*args)
                except TypeError as e: 
                    log.error("Extension "+extraHandler.__package__+" registered a wrong ladderlog handler. This is a bug.")
                    if debug: raise e
Ejemplo n.º 35
0
from Team import *

H = Team('Harvard', 2014)
C = Team('Cincinnati', 2014)

P_Log5 = Log5(H.Pyth, C.Pyth)
print 'Harvard (Log5): {:.2%}'.format(P_Log5)

H.nearest_neighbor(C, k=10)
C.nearest_neighbor(H, k=10)

P_kNN = H.Match(C, k=10)
print 'Harvard (kNN): {:.2%}'.format(P_kNN)

WB, LB = C.nearest_neighbor(H, k=10)
WA, LA = H.nearest_neighbor(C, k=10)
TA, TB = WA + LA, WB + LB

p_A = (WA + LB) / (TA + TB)
p_B = (LA + WB) / (TA + TB)

print p_A, p_B