def generate_player(): r = random(); name = '' if r < 0.5: name = rand_male_name() + ' ' + rand_surname() else: name = rand_female_name() + ' ' + rand_surname() pos = Pos.rand_position() weight, height = 0, 0 if pos == Pos.CATCHER: weight, height = catcher_height_weight() elif Pos.is_infield(pos): weight, height = infield_height_weight() elif Pos.is_outfield(pos): weight, height = outfield_height_weight() else: weight, height = pitcher_height_weight() birthdate = generate_birthdate(start_date.year) bats, throws = generate_bats_throws() years_in_majors = int( gauss(years_old(birthdate, start_date) - 23, 2) ) if years_in_majors < 0: years_in_majors = 0 caps = Capabilities.generate_all_caps(height, weight, birthdate, start_date, years_in_majors, pos) pos_caps = PositionCapabilities.generate_pos_caps(pos) contract = Contract(get_FA(), 0, 0) personality = Personality.rand_personality() return Player(name, pos, height, weight, birthdate, bats, throws, caps, pos_caps, contract, personality)
def generate_training_stats(years_in_majors, position): exp_term = 0 if years_in_majors == 0: pass else: exp_term = 16.0 / (1 + 60.0 / (years_in_majors * years_in_majors)) params1 = parameters() params2 = parameters() stat1 = redistribute(int(rand_skill_seed(params1[0], params1[1]))) stat2 = redistribute(int(rand_skill_seed(params2[0], params2[1]))) total = stat1 + stat2 hitting, fielding, pitching = 0, 0, 0 if Pos.is_infield(position): hitting = int(round(total * 1.0 / 2.0)) fielding = int(round(total * 1.0 / 2.0)) pitching = MIN_VALUE elif Pos.is_outfield(position): hitting = int(round(total * 3.0 / 5.0)) fielding = int(round(total * 2.0 / 5.0)) pitching = MIN_VALUE elif Pos.is_pitcher(position): index = int(total * 0.02999) params = distro_set[index] pitching = redistribute(int(rand_skill_seed(params[0], params[1]))) fielding = redistribute( int(rand_skill_seed(distro_set[3][0], distro_set[3][1]))) hitting = redistribute( int(rand_skill_seed(distro_set[1][0], distro_set[1][1]))) else: hitting = int(round(total * 4.0 / 5.0)) fielding = int(round(total * 1.0 / 5.0)) pitching = MIN_VALUE return redistribute(hitting), redistribute(fielding), redistribute( pitching)