Example #1
0
 def intersect(self, ray):
     hit = Hit(self, ray, None, None)
     for o in self.objs:
         hit = hit.union(o.intersect(ray))
     if hit.entry < hit.exit:
         return hit
     return None
Example #2
0
    def intersect(self, ray):
	hit = Hit(self, ray, None, None)
	for o in self.objs:
	    hit = hit.union(o.intersect(ray))
	if hit.entry < hit.exit:
	    return hit
	return None
Example #3
0
 def intersect(self, ray):
     hit = Hit(self, ray, float('-inf'), float('-inf'))
     for o in self.objs:
         hit = hit.union(o.intersect(ray))
     if hit.entry < hit.exit:
         return hit
     return None
Example #4
0
    def intersect(self, ray):
	hit = Hit(self, ray, None, None)
	for o in self.objs:
	    hit = hit.intersection(o.intersect(ray))
	    if hit == None or hit.miss(): 
	        if self.objs.index(o) != 0:
	            self.objs.remove(o)
		    self.objs = [o] + self.objs
		return None
	return hit
Example #5
0
 def intersect(self, ray):
     hit = Hit(self, ray, float('-inf'), float('-inf'))
     for o in self.objs:
         hit = hit.intersection(o.intersect(ray))
         if hit is None or hit.miss():
             if self.objs.index(o) != 0:
                 self.objs.remove(o)
                 self.objs = [o] + self.objs
             return None
     return hit
Example #6
0
	def read_hits(self, txt=None, path=None, format=None, using=None, inplace=False, **kwargs):
		"""Create a list of Hit objects from a file or a given text.

		Arguments:
			- str `txt`: the text to read hits from (if it's given, format="txt" and using="txt").
			- pathlib.Path `path`: the file to read hits from.
			- str `format`: (if `path` is given) how to read hits; one of the following:
				- txt: file contains just the words
				- csv: file contains columns with words (reads from self.path by default but
					you can define path to override that)
					Define column names as a dict in kwargs["colnames"]. Available keys are
						"word", "t0", "tx", "conf" (weight) and "spk" (speaker), and default values
						are the same as the keys.
					You can also define kwargs for pandas.read_csv in kwargs.
				- nuance: lattice file from Nuance Transcription Engine
				- google: lattice file from Google Speech-to-Text
				- spraak: lattice file from SPRaak
			- str `using`: where to read the hits from; one of the following:
				- file: open a file and read the contents (also, set self.txt)
				- txt: use self.txt
				- None: use self.file if it exists, else use self.txt
			- bool `inplace`: save hits in self.hits if True, else just return them
		"""

		if txt is not None:
			pass
		elif self.path is None or using == "txt":
			txt = self.txt
		elif using == "file":
			with self.path.open() as lines:
				txt = lines.read()
		else:
			raise ValueError("Argument `using` should be 'file', 'txt' or None.")

		if format == "txt":
			hits = []
			for word in txt.split():
				hit = Hit(word)
				hits.append(hit)
		elif format == "csv":
			path = self.path or Path(path)
			docdf = pandas.read_csv(path.as_posix(), **kwargs). \
				rename(columns=kwargs.get("colnames", {}))
			for row in docdf.itertuples():
				hit = Hit.from_namedtuple(row)
				hits.append(hit)
		else:
			raise NotImplementedError("Reading hits from {} doesn't work yet.".format(format))

		if inplace:
			self.hits = hits

		return hits
Example #7
0
    def intersect(self, ray):
        """The ray t value of the first intersection point of the
        ray with self, or None if no intersection occurs"""
        hit = None
        q = self.centre - ray.start
        vDotQ = dot(ray.dir, q)
        squareDiffs = dot(q, q) - self.radius*self.radius
        discrim = vDotQ * vDotQ - squareDiffs
        if discrim >= 0:
            root = sqrt(discrim)
            t0 = (vDotQ - root)
            t1 = (vDotQ + root)
            if t0 < t1:
	    	hit = Hit(self, ray, t0, t1, None, self.material)
	    else:
		hit = Hit(self, ray, t1, t0, None, self.material)
	    if hit.entry > 0:
		hit.normal = self.normal(ray.pos(hit.entry))
	    if hit.exit > 0:
	    	hit.normal2 = self.normal(ray.pos(hit.exit))
        return hit
Example #8
0
    def intersect(self, ray):
        """Returns a hit, or None if the ray is parallel to the plane"""

	t = None
	hit = None
	angle = ray.dir.dot(self.norm)
	if angle != 0:
	    t = (self.point - ray.start).dot(self.norm)/angle
	    if angle < 0:
	        hit = Hit(self, ray, t, (), self.norm, self.mat)
	    else :
	        hit = Hit(self, ray, None, t, self.norm, self.mat)
	else:
	    vector = unit(ray.start - self.point)
	    if vector.dot(self.norm) < 0:
	    	hit = Hit(self, ray, None, (), self.norm, self.mat)
	    else:
	    	return None
	if self.mat.texture and hit.entry > 0:
	    hit.texCords = self.texCords(ray.pos(t))
	return hit
Example #9
0
def make_hits_lists(event):
    hits_tracker1 = []
    hits_tracker2 = []
    hits_calorimeter = []

    for (sector, pad, layer, energy, hit_type, track_len, p_x, p_y, p_z, p_px,
         p_py, p_pz,
         p_e) in zip(event.tr1_sector, event.tr1_pad, event.tr1_layer,
                     event.tr1_energy, event.tr1_type, event.tr1_track_len,
                     event.tr1_x, event.tr1_y, event.tr1_z, event.tr1_px,
                     event.tr1_py, event.tr1_pz, event.tr1_p_energy):

        # Selection as in data for tracker1
        if (pad < 20 or sector == 0 or sector == 3 or energy <= 0.
                or bad_pad(sector, pad, layer)):
            continue

        # If passed the selection create hit and add to corresponding list
        hit = TrHit(sector, pad, layer, energy, hit_type, track_len, p_x, p_y,
                    p_z, p_px, p_py, p_pz, p_e)

        hits_tracker1.append(hit)

    for (sector, pad, layer, energy, hit_type, track_len, p_x, p_y, p_z, p_px,
         p_py, p_pz,
         p_e) in zip(event.tr2_sector, event.tr2_pad, event.tr2_layer,
                     event.tr2_energy, event.tr2_type, event.tr2_track_len,
                     event.tr2_x, event.tr2_y, event.tr2_z, event.tr2_px,
                     event.tr2_py, event.tr2_pz, event.tr2_p_energy):
        # Selection as in data for tracker2
        if (pad < 20 or sector == 0 or sector == 3 or energy <= 0.
                or bad_pad(sector, pad, layer)):
            continue

        # If passed the selection create hit and add to corresponding list
        hits_tracker2.append(
            TrHit(sector, pad, layer, energy, hit_type, track_len, p_x, p_y,
                  p_z, p_px, p_py, p_pz, p_e))

    for (sector, pad, layer, energy) in zip(event.cal_sector, event.cal_pad,
                                            event.cal_layer, event.cal_energy):

        # Selection as in data for calorimeter
        if (pad < 20 or layer == 7 or sector == 0 or sector == 3
                or bad_pad(sector, pad, layer)):
            continue

        # If passed the selection create hit and add to corresponding list
        hits_calorimeter.append(Hit(sector, pad, layer, energy))

    return hits_tracker1, hits_tracker2, hits_calorimeter
Example #10
0
    def intersect(self, ray):
        """Returns a hit, or None if the ray is parallel to the plane"""

        t = None
        hit = None
        angle = ray.dir.dot(self.norm)
        if angle != 0:
            t = (self.point - ray.start).dot(self.norm) / angle
            if angle < 0:
                hit = Hit(self, ray, t, (), self.norm, self.mat)
            else:
                hit = Hit(self, ray, None, t, self.norm, self.mat)
        else:
            vector = unit(ray.start - self.point)
            if vector.dot(self.norm) < 0:
                hit = Hit(self, ray, None, (), self.norm, self.mat)
            else:
                return None
        if self.mat.texture and hit.entry > 0:
            hit.texCords = self.texCords(ray.pos(t))
        return hit
Example #11
0
    def intersect(self, ray):
        """Returns a hit, or None if the ray is parallel to the plane"""

        t = None
        hit = None
        angle = ray.dir.dot(self.norm)
        if angle != 0:
            t = (self.point - ray.start).dot(self.norm) / angle
            if angle < 0:
                hit = Hit(self, ray, t, float('inf'), self.norm, self.mat)
            else:
                hit = Hit(self, ray, float('-inf'), t, self.norm, self.mat)
        else:
            vector = unit(ray.start - self.point)
            if vector.dot(self.norm) < 0:
                hit = Hit(self, ray, float('-inf'), float('inf'), self.norm,
                          self.mat)
            else:
                return None
        if (self.mat.texture is not None and not isninf(hit.entry)) > 0:
            hit.texCords = self.texCords(ray.pos(t))
        return hit
def marshall_hits(hits):
    """
    Substitues highlights into fields and returns valid JSON
    :param hits:
    :return:
    """
    import re

    hits_list = []
    for hit in hits:
        hit_dict = Hit(hit.to_dict())
        if hasattr(hit.meta, "highlight"):
            highlight_dict = hit.meta.highlight.to_dict()
            for highlight_key in highlight_dict:
                for fragment in highlight_dict[highlight_key]:
                    fragment = fragment.strip()
                    if "<strong>" in fragment and "</strong>" in fragment:
                        highlighted_text = " ".join(
                            re.findall("<strong>(.*?)</strong>", fragment))

                        val = get_var(hit_dict, highlight_key)

                        if hasattr(val, "__iter__"):
                            highlighted_vals = []
                            for v in val:
                                highlighted_vals.append(
                                    _highlight(highlighted_text, v))
                            hit_dict.set_value(highlight_key, highlighted_vals)
                        else:
                            hit_dict.set_value(
                                highlight_key,
                                _highlight(highlighted_text, val))

        # rename 'type' field to '_type'
        hit_dict["_type"] = hit_dict.pop("type")
        hits_list.append(hit_dict)
    return hits_list
Example #13
0
 def intersect(self, ray):
     """The ray t value of the first intersection point of the
     ray with self, or None if no intersection occurs"""
     hit = None
     q = self.centre - ray.start
     vDotQ = dot(ray.dir, q)
     squareDiffs = dot(q, q) - self.radius * self.radius
     discrim = vDotQ * vDotQ - squareDiffs
     if discrim >= 0:
         root = sqrt(discrim)
         t0 = (vDotQ - root)
         t1 = (vDotQ + root)
         if t0 < t1:
             hit = Hit(self, ray, t0, t1, None, self.material)
         else:
             hit = Hit(self, ray, t1, t0, None, self.material)
         if hit.entry > 0:
             hit.normal = self.normal(ray.pos(hit.entry))
         if hit.exit > 0:
             hit.normal2 = self.normal(ray.pos(hit.exit))
     return hit
Example #14
0
def menu_options(p_counter):

    selection = player_turn(p_counter)
    if selection == 1:  #LISTO
        action = Entry(players, p_counter)
        action.a_entry()
        var = change_player(p_counter)
        if var == 1:
            return 0
    elif selection == 2:  #LISTO
        block = Counter_attack(p_counter, players, 2)
        block = block.attack()
        if block == 0:  #Nadie quiso contraatacar, entonces se ejecuta la acción.
            action = Abroad_help(players, p_counter)
            action.a_abroad_help()
        else:  #En este caso se puede hacer un desafío
            attacking = block  #El jugador "block" quiso contraatacar
            action = Challenge(attacking - 1, players, 2, 2)
            a, b, c = action.challenge_player()
            if a == 0 and b == 0:  #Nadie quiso desafiar el contra-ataque, entonces no se ejecuta la acción y le toca al siguiente jugador
                var = change_player(p_counter)
                if var == 1:
                    return 0

            elif a == 0 and b == 1:  #El que contra-atacó mintió, la acción si se ejecuta
                action = Abroad_help(players, p_counter)
                action.a_abroad_help()
            elif b == 3:
                if a == 1:
                    players[attacking - 1]._Players__influence1 = return_card(
                        players[attacking - 1]._Players__influence1)
                elif a == 2:
                    players[attacking - 1]._Players__influence2 = return_card(
                        players[attacking - 1]._Players__influence2)
        var = change_player(p_counter)
        if var == 1:
            return 0

    elif selection == 3:  #LISTO
        action = Hit(players, p_counter)
        result = action.hit()
        if result == 0:
            menu_options(p_counter)
        var = change_player(p_counter)
        if var == 1:
            return 0

    elif selection == 4:  #LISTO
        action = Challenge(
            p_counter, players, 1,
            4)  #El 1 significa que se verifican las influencias de acciones
        a, b, c = action.challenge_player()
        if a == 0 and b == 0:  #Nadie quiso desafiar, entonces se ejecuta la acción
            action = Tax(players, p_counter)
            action.a_tax()
        elif b == 3:
            if a == 1:
                players[p_counter]._Players__influence1 = return_card(
                    players[p_counter]._Players__influence1)
            elif a == 2:
                action = Tax(players, p_counter)
                action.a_tax()
                players[p_counter]._Players__influence2 = return_card(
                    players[p_counter]._Players__influence2)
            action = Tax(players, p_counter)
            action.a_tax()
        var = change_player(p_counter)
        if var == 1:
            return 0

    elif selection == 5:  #ASESINATO---------------
        verif = Murder(players, p_counter)
        verif = verif.verif()
        if verif == 0:
            menu_options(p_counter)

        action = Challenge(p_counter, players, 1, 5)
        a, b, c = action.challenge_player()
        if a == 0 and b == 0:  #Nadie quiso desafiar, luego van los contra-ataques
            action = Counter_attack(p_counter, players, 5)
            player_attack = action.attack()
            if player_attack == 0:  #Nadie quiso contra-atacar ni desafiar, entonces se ejecuta la acción
                action = Murder(players, p_counter)
                action.murder()
            else:  #Nadie quiso desafiar pero si contra-atacar, se pregunta si desafían al que contra-atacó (supuestamente tiene a la Condesa)
                action = Challenge(player_attack - 1, players, 2, 5)
                a, b, c = action.challenge_player(
                )  #c es el jugador que desafió
                if a == 0 and b == 0:  #Nadie desafía el contra-ataque, la acción no se cumple, pierde las monedas
                    players[p_counter]._Players__coins = -3
                    var = change_player(p_counter)
                    if var == 1:
                        return 0
                elif a == 0 and b == 1:  #Pierde el desafío el que contra-atacó, se ejecuta la acción
                    action = Murder(players, p_counter)
                    action.murder()
                elif b == 3:  #El que contraatacó ganó el desafío.
                    if a == 1:
                        players[c]._Players__influence1 = return_card(
                            players[c]._Players__influence1)
                    else:
                        players[c]._Players__influence2 = return_card(
                            players[c]._Players__influence2)

        elif a == 0 and b == 1:  #Alguien quiso contra-atacar, el jugador pierde el desafío entonces no realiza la acción y cambia de turno
            var = change_player(p_counter)
            if var == 1:
                return 0
        elif b == 3:  #Si poseía la carta influencia, entonces pasa a contra-ataques
            if a == 1:
                players[p_counter]._Players__influence1 = return_card(
                    players[p_counter]._Players__influence1)
            elif a == 2:
                players[p_counter]._Players__influence2 = return_card(
                    players[p_counter]._Players__influence2)
            action = Counter_attack(p_counter, players, 5)
            player_attack = action.attack()
            if player_attack == 0:  #Nadie quiso contra-atacar ni desafiar, entonces se ejecuta la acción
                action = Murder(players, p_counter)
                action.murder()
            else:  #Nadie quiso desafiar pero si contra-atacar, se pregunta si desafían al que contra-atacó (supuestamente tiene a la Condesa)
                action = Challenge(player_attack - 1, players, 2, 5)
                a, b, c = action.challenge_player(
                )  #c es el jugador que desafió
                if a == 0 and b == 0:  #Nadie desafía el contra-ataque, la acción no se cumple
                    var = change_player(p_counter)
                    if var == 1:
                        return 0
                elif a == 0 and b == 1:  #Pierde el desafío el que contra-atacó, se ejecuta la acción
                    action = Murder(players, p_counter)
                    action.murder()
                elif b == 3:  #El que contraatacó ganó el desafío.
                    if a == 1:
                        players[c]._Players__influence1 = return_card(
                            players[c]._Players__influence1)
                    else:
                        players[c]._Players__influence2 = return_card(
                            players[c]._Players__influence2)
        var = change_player(p_counter)
        if var == 1:
            return 0

    elif selection == 6:  #EXTORSIÓN-------------
        action = Challenge(p_counter, players, 1, 6)
        a, b, c = action.challenge_player()
        if a == 0 and b == 0:  #Nadie quiso contra-atacar, luego van los contra-ataques
            action = Counter_attack(p_counter, players, 6)
            player_attack = action.attack()
            if player_attack == 0:  #Nadie quiso contra-atacar ni desafiar, entonces se ejecuta la acción
                action = Extortion(players, p_counter)
                action.extortion()
            else:  #Nadie quiso desafiar pero si contra-atacar, se pregunta si desafían al que contra-atacó (supuestamente tiene a la Condesa)
                action = Challenge(player_attack - 1, players, 2, 6)
                a, b, c = action.challenge_player(
                )  #c es el jugador que desafió
                if a == 0 and b == 0:  #Nadie desafía el contra-ataque, la acción no se cumple
                    var = change_player(p_counter)
                    if var == 1:
                        return 0
                elif a == 0 and b == 1:  #Pierde el desafío el que contra-atacó, se ejecuta la acción
                    action = Extortion(players, p_counter)
                    action.extortion()
                elif b == 3:  #El que contraatacó ganó el desafío.
                    if a == 1:
                        players[c]._Players__influence1 = return_card(
                            players[c]._Players__influence1)
                    else:
                        players[c]._Players__influence2 = return_card(
                            players[c]._Players__influence2)

        elif a == 0 and b == 1:  #el jugador pierde el desafío entonces no realiza la acción y cambia de turno
            var = change_player(p_counter)
            if var == 1:
                return 0
        elif b == 3:  #Si poseía la carta influencia, pasa a contra-ataque
            if a == 1:
                players[p_counter]._Players__influence1 = return_card(
                    players[p_counter]._Players__influence1)
            elif a == 2:
                players[p_counter]._Players__influence2 = return_card(
                    players[p_counter]._Players__influence2)
            action = Counter_attack(p_counter, players, 5)
            player_attack = action.attack()
            if player_attack == 0:  #Nadie quiso contra-atacar ni desafiar, entonces se ejecuta la acción
                action = Extortion(players, p_counter)
                action.extortion()
            else:  #Nadie quiso desafiar pero si contra-atacar, se pregunta si desafían al que contra-atacó (supuestamente tiene a la Condesa)
                action = Challenge(player_attack - 1, players, 2, 5)
                a, b, c = action.challenge_player(
                )  #c es el jugador que desafió
                if a == 0 and b == 0:  #Nadie desafía el contra-ataque, la acción no se cumple
                    var = change_player(p_counter)
                    if var == 1:
                        return 0
                elif a == 0 and b == 1:  #Pierde el desafío el que contra-atacó, se ejecuta la acción
                    action = Extortion(players, p_counter)
                    action.extortion()
                elif b == 3:  #El que contraatacó ganó el desafío.
                    if a == 1:
                        players[c]._Players__influence1 = return_card(
                            players[c]._Players__influence1)
                    else:
                        players[c]._Players__influence2 = return_card(
                            players[c]._Players__influence2)
    elif selection == 7:  #LISTA-------------
        action = Challenge(p_counter, players, 1, 7)
        a, b, c = action.challenge_player()
        if a == 0 and b == 0:  #Nadie quiso desafiar, entonces se hace la acción
            action = Change(players, p_counter, influences)
            action.change_cards()

        elif a == 0 and b == 1:  #el jugador pierde el desafío entonces no realiza la acción y cambia de turno
            var = change_player(p_counter)
            if var == 1:
                return 0
        elif b == 3:  #Si poseía la carta influencia, realiza la acción
            if a == 1:
                players[p_counter]._Players__influence1 = return_card(
                    players[p_counter]._Players__influence1)
            elif a == 2:
                players[p_counter]._Players__influence2 = return_card(
                    players[p_counter]._Players__influence2)
            action = Change(players, p_counter, influences)
            action.change_cards()
            var = change_player(p_counter)
            if var == 1:
                return 0
Example #15
0
 def dict_to_object(self, d):
     if Hit.__name__ == d.pop('__class__', None):
         return Hit(**d)
     return d
 def __init__(self,
              smiles: str,
              hits: List,
              name: str = 'ligand',
              refine: bool = True):
     # entry attributes
     self.smiles = smiles
     self.name = name
     path = os.path.join(self.work_path, self.name)
     if not os.path.exists(path):
         os.mkdir(path)
     if len(hits) == 0:
         warn('using regular CovDock as without hits.')
         super().__init__(smiles, name, refine=True)
     else:
         print(f'Analysing: {name}')
         self.hits = [Hit(hit) for hit in hits]
         # cached property
         self._index_map = None
         self._name_map = None
         self._best_hit = None
         self.notebook = {}
         # operations
         #self.best_hit.relax()
         self.ori_mol = Chem.MolFromSmiles(self.smiles)
         self.thio_mol = self.thiolate()
         # S has the highest index because of substitution, but prioritise the anteconnection atom that is a carbon
         x = []
         for element in ('C', 'N', 'O'):
             x.extend(
                 self.thio_mol.GetSubstructMatches(
                     Chem.MolFromSmiles(element + 'C[S-]')))
         self.CY_idx, self.CX_idx, self.SX_idx = sorted(
             x, key=lambda v: -v[2])[0]
         # if CY is not a C. does it matter if it is called CY?
         self.dethio_mol = self.dethiolate()
         ## align ligand
         cid = self.align_probe_to_target()
         aligned_file = self.write_probe(cid)
         self.save_confs(self.dethio_mol, aligned_file)
         print(f'SMILES converted: {name}')
         self.parameterise(aligned_file)  # self.pdb_mol gets assigned.
         print(f'Parameterised: {name}')
         #pdbblock = self.make_placed_pdb()
         self.fragmenstein = self.make_fragmenstein()
         pdbblock = self.place_fragmenstein()
         open(f'{self.work_path}/{self.name}/pre_{self.name}.pdb',
              'w').write(pdbblock)
         self.make_overlap_image()
         self.pose = self.make_pose(pdbblock)
         print(f'PyRosetta loaded: {name}')
         self.egor = self.call_egor()
         print(f'EM: {name}')
         # self.dock_pose()
         # print(f'Docked: {name}')
         # # if refine:
         # #     self.refine_pose()
         # self.pose.dump_pdb(f'{self.work_path}/{self.name}/docked_{self.name}.pdb')
         print(f'Docked saved: {name}')
         self.snap_shot()
         print(f'Snapped: {name}')
         self.score = self.calculate_score()
         json.dump(
             self.notebook,
             open(f'{self.work_path}/{self.name}/{self.name}.json', 'w'))
         print(f'Done: {name}')
Example #17
0
    def Calculate_elo(self, data, k, min_games, blue, m):

        Players = {}
        Teams = {}

        k = k
        min_games = min_games
        blue = blue
        kelly = 12
        max_betsize = 5
        date = 20150101
        aloituskassa = 1000
        tasapanos = 0  # Jos 1 niin pelataan tasapanoksella.

        bank = Bank(max_betsize, date, aloituskassa, kelly, tasapanos)
        hit = Hit()

        for series in data:
            i = 0
            home = series[5]  # Home team
            away = series[6]  # Away team
            game_scores = series[7].split(',')
            region = series[10]
            winning_sides = series[11].split(',')
            league = series[12]
            blue_side_team = series[13].split(',')

            players1 = series[8].split(':')
            players2 = series[9].split(':')

            for result in game_scores:
                winning_side = winning_sides[i]
                home_players = players1[i].split(',')
                away_players = players2[i].split(',')

                for player in (home_players + away_players):
                    if player not in Players:
                        Players[player] = Player(k, min_games, player)

                # Determine team regions
                for team in [home, away]:
                    if team not in Teams:
                        Teams[team] = Team(team)
                    if region != 'WR':
                        Teams[team].region = region

                avg = Function().avg(Players)
                home_elo = Function().team_avg(home_players, Players)
                away_elo = Function().team_avg(away_players, Players)
                '''
				if blue_side_team[i] == home:
					hit.game(home_elo+blue, away_elo, result)
				else:
					hit.game(home_elo, away_elo+blue, result)
				'''
                if (i == 0 and Function().Min_games(home_players, away_players,
                                                    0, Players) == True):
                    bank.match(series, home_elo, away_elo, blue, kelly, Teams,
                               m)

                if result == '1-0':
                    #Teams[home].win(away, away_elo)
                    #Teams[away].lose(home, home_elo)
                    n = 0
                    for player in home_players:
                        Players[player].win(away_elo, avg, n)
                        n += 1
                    n = 0
                    for player in away_players:
                        Players[player].lose(home_elo, avg, n)
                        n += 1

                elif result == '0-1':
                    #Teams[home].lose(away, away_elo)
                    #Teams[away].win(home, home_elo)
                    n = 0
                    for player in home_players:
                        Players[player].lose(away_elo, avg, n)
                        n += 1
                    n = 0
                    for player in away_players:
                        Players[player].win(away_elo, avg, n)
                        n += 1
                else:
                    print series
                    quit()

                i += 1

        return Players, Teams, bank, hit