예제 #1
0
파일: sim.py 프로젝트: Bamberger/dicesim
def simroll(attacks, at, pow, defense, arm, dice_hit, dice_dmg):
    landing_results = []  # Create an array for results to land in before sorting
    roll_counter = 0  # Run a roll set for each attack
    while roll_counter < attacks:
        roll_counter += 1
        result = rolls.roll_full(at, pow, defense, arm, dice_hit, dice_dmg)  # Calls rolls.roll_full
        if attacks > 1:
            if result == -1:
                result = 0
        landing_results.append(result)

#     landing_results.sort()  # Order the landing_results for later use
    
    damage_total = sum(landing_results)  # Calculate total damage
    return(damage_total)


#     for i in landing_results:
#         results[i] += 1  # Populate the results array
#     
#     result_counter = 0
#     average = 0
#     while result_counter < max_result:
#         if results[result_counter] != 0:
#             print(result_counter, "damage: ", round(results[result_counter] / attacks * 100, 2), "%")
#         result_counter += 1
#     
#     print("Total Damage:", damage_total)
#     print("Average Damage:", round(damage_total / attacks, 2))
#     
#     print("25th Percentile:", percentile.percentile(landing_results, 0.25))
#     print("50th Percentile:", percentile.percentile(landing_results, 0.50))
#     print("75th Percentile:", percentile.percentile(landing_results, 0.75))
#     print("90th Percentile:", percentile.percentile(landing_results, 0.90))
예제 #2
0
파일: main.py 프로젝트: Bamberger/dicesim
def calculate(cycles, attacks, at, pow, defense, arm, dice_hit, dice_dmg, foc, boostflag):
    results = [0] * max_result  # Create an array to handle up to 'max_result' dmg
    ordered_results = []  # Create an array for results to land in before sorting
    input_foc = foc  # Grab the foc now before we manipulate it
    out = 0 
    counter_cycle = 0
    
    while counter_cycle < cycles:
        result = 0
        counter_cycle += 1
#         if full == 1:
#             process = counter_cycle / cycles * 10
#             if process == int(process):
#                 print(int(process * 10), "% Complete",round(time.time() - start_time,2), "seconds")           
        if input_foc == 0:  # If we are not in focus mode...
            cycle_attacks = attacks
            while cycle_attacks > 0:          
                out = rolls.roll_full(at, pow, defense, arm, dice_hit, dice_dmg)  # Do initial attacks
                if out == -1:
                    out = 0
                result = result + out
                cycle_attacks -= 1
        elif boostflag == 0:
            cycle_attacks = attacks + foc
            while cycle_attacks > 0:          
                out = rolls.roll_full(at, pow, defense, arm, dice_hit, dice_dmg)  # Do initial attacks
                if out == -1:
                    out = 0
                result = result + out
                cycle_attacks -= 1
        elif boostflag == 1:
            cycle_attacks = attacks + foc
            while cycle_attacks > 0:
                if cycle_attacks >= 2:    
                    out = rolls.roll_full(at, pow, defense, arm, dice_hit + 1, dice_dmg)  # Do initial attacks
                    if out == -1:
                        out = 0
                    cycle_attacks -= 2
                else:
                    out = rolls.roll_full(at, pow, defense, arm, dice_hit, dice_dmg)
                    if out == -1:
                        out = 0
                    cycle_attacks -= 1
                result = result + out
        elif boostflag == 2:
            cycle_attacks = attacks + foc
            while cycle_attacks > 0:
                if cycle_attacks >= 2:    
                    out = rolls.roll_full(at, pow, defense, arm, dice_hit, dice_dmg + 1)  # Do initial attacks
                    if out == -1:
                        out = 0
                        cycle_attacks += 1
                    cycle_attacks -= 2
                else:
                    out = rolls.roll_full(at, pow, defense, arm, dice_hit, dice_dmg)
                    if out == -1:
                        out = 0
                    cycle_attacks -= 1
                result = result + out
        elif boostflag == 3:
            cycle_attacks = attacks + foc
            while cycle_attacks > 0:
                if cycle_attacks >= 3:    
                    out = rolls.roll_full(at, pow, defense, arm, dice_hit + 1, dice_dmg + 1)  # Do initial attacks
                    if out == -1:
                        out = 0
                        cycle_attacks += 1
                    cycle_attacks -= 3                 
                elif cycle_attacks == 2:    
                    out = rolls.roll_full(at, pow, defense, arm, dice_hit, dice_dmg + 1)  # Do initial attacks
                    if out == -1:
                        out = 0
                        cycle_attacks += 1
                    cycle_attacks -= 2                  
                else:
                    out = rolls.roll_full(at, pow, defense, arm, dice_hit, dice_dmg)
                    if out == -1:
                        out = 0
                    cycle_attacks -= 1
                result = result + out
        
#         if input_foc == 1:  # If one foc is left, buy an attack
#             out = sim.simroll(1, at, pow, defense, arm, dice_hit, dice_dmg)
#             if out == -1:
#                 out = 0
#             result = result + out
        ordered_results.append(result)
        
    ordered_results.sort()  # Order the ordered_results for later use
    
    for index, i in enumerate(ordered_results):
        results[i] += 1  # Populate the results array
        
    damage_total = sum(ordered_results)
    # print("Total Damage:", damage_total)
    if full == 1:
        print("*** Full results for", attacks, "attacks ***")
    
    print("Average Damage:", "\t", round(damage_total / cycles, 2))
     
    print("25th Percentile:", "\t", percentile.percentile(ordered_results, 0.25))
    print("50th Percentile:", "\t", percentile.percentile(ordered_results, 0.50))
    print("75th Percentile:", "\t", percentile.percentile(ordered_results, 0.75))
    print("90th Percentile:", "\t", percentile.percentile(ordered_results, 0.90))
    
    if full == 1:
        print("DAMAGE\t", "CONFIDENCE\t", "SPECIFIC")
        result_counter = 0
        while result_counter < max_result:
            if results[result_counter] != 0:
                ordered_index = ordered_results.index(result_counter)
                confidence = cycles - ordered_index
                print(result_counter, "\t", round(confidence / cycles * 100, 2), "%", "\t", round(results[result_counter] / cycles * 100, 2), "%")
            result_counter += 1