Ejemplo n.º 1
0
def main():

    from differential import Differential
    from render import Render
    from time import time
    from helpers import print_stats

    # from helpers import print_debug

    DL = Differential(NMAX, 8, NZ, ZMAX, RAD, NEARL, FARL)

    render = Render(SIZE, BACK, FRONT)

    render.ctx.set_source_rgba(*FRONT)
    render.ctx.set_line_width(LINEWIDTH)

    angles = sorted(random(100))

    DL.init_circle(MID, MID, RAD * 50.0, angles)

    for i in count():

        t_start = time()

        steps(DL, STEPS_ITT)

        t_stop = time()

        print_stats(i * STEPS_ITT, t_stop - t_start, DL)

        fn = "./img/print10k_5px_{:010d}.png".format(i * STEPS_ITT)
        show(render, DL, fn)
Ejemplo n.º 2
0
    def wrap(steps_itt, render):

        t1 = time()

        steps(DL, steps_itt)
        edges_coordinates = DL.get_edges_coordinates()
        show(render, edges_coordinates)

        t2 = time()
        print_stats(render.steps, t2 - t1, DL)

        return True
def initiate_game(num_of_matches_to_play):
    matches_played = 0
    player_roaster = OrderedDict([
        (1, BruceLeeds),
        (2, SerenaWilliamson),
        (3, JCVanDime),
    ])
    unavil_choices = []

    describe_stage("Let's play a simple game of ping pong..")
    player_one_choice = pick_player(player_roaster, unavil_choices, "FIRST")
    unavil_choices.append(player_one_choice)
    player_two_choice = pick_player(player_roaster, unavil_choices, "SECOND")
    player_one        = player_roaster[player_one_choice]()
    player_two        = player_roaster[player_two_choice]()
    match_pair        = [player_one, player_two]

    describe_stage("Preparing a match between: '{}' vs '{}'"\
                   .format(player_one.pretty_name, player_two.pretty_name))

    while True:
        if num_of_matches_to_play and (num_of_matches_to_play == matches_played):
            break
        serve_index    = do_coin_toss() # Return 0 or 1
        first_to_serve = match_pair[serve_index]
        print ""
        print "Player '{}' will be serving first.".format(first_to_serve.pretty_name)

        describe_stage("Match begins..")
        start_match(match_pair, serve_index)
        matches_played += 1

        player_one_result = match_pair[0].check_if_stats_stablized()
        player_two_result = match_pair[1].check_if_stats_stablized()
        if player_one_result and player_two_result:
            break

        print "Current stats..."
        print_stats(match_pair[0], match_pair[0].return_shots_history())
        print_stats(match_pair[1], match_pair[1].return_shots_history())
        print "Preparing a rematch..."

    describe_stage("Showing match stats.. ")
    print "Total number of matches played: {}".format(matches_played)
    print "{} wins {} ({:.0f}%)".format(match_pair[0].pretty_name, match_pair[0].matches_won,
                                        match_pair[0].matches_won / float(matches_played) * 100)
    print "{} wins {} ({:.0f}%)".format(match_pair[1].pretty_name, match_pair[1].matches_won,
                                        match_pair[1].matches_won / float(matches_played) * 100)
    print_stats(match_pair[0], match_pair[0].return_shots_history())
    print_stats(match_pair[1], match_pair[1].return_shots_history())
Ejemplo n.º 4
0
            'number': 0,
            'total_payment': 0
        },
        'C#': {
            'number': 0,
            'total_payment': 0
        },
        'Java': {
            'number': 0,
            'total_payment': 0
        },
        'PHP': {
            'number': 0,
            'total_payment': 0
        },
        'Other': {
            'number': 0,
            'total_payment': 0
        }
    }

    vacancies = work_with_file.read_from_file(
        input('Please input path to a source file: '))

    helpers.add_lang_to_vacancies(vacancies, languages)
    helpers.count_vacancies_per_lang(vacancies, languages)
    helpers.add_total_payment_per_lang(vacancies, languages)
    helpers.avg_payment_per_lang(languages)
    helpers.print_stats(languages)
    helpers.show_plot(languages)