DnD_5e.simulation package

Module contents

class DnD_5e.simulation.Simulation(**kwargs)[source]

Bases: object

A class to run an Encounter multiple times and display the result

get_name() str[source]
Returns:

name

set_name(name: str)[source]
get_encounter()[source]
Returns:

stats

collect_stats()[source]

Collect the stats from one run of the Encounter and update self._stats accordingly :return:

update_stats(stats: dict)[source]

Collect stats from the given dictionary and update self._stats accordingly :param stats: results from one run of the Encounter :return:

calculate_aggregate_stats(n=10000)[source]

Calculate the final stats (i.e., take the average of all the runs by dividing by n. Also calculate some other aggregate statistics such as proportion_end_hp. Store the final stats in aggregate_stats.

Returns:

print_aggregate_stats()[source]

Print the aggregate stats calculated in :py:meth:calculate_aggregate_stats :return:

process_run(num)[source]

The method given to an individual process to do work

Parameters:

num – which iteration of the loop am I

Returns:

mp_run(n=1000, num_procs=None)[source]

Run the Encounter n times (using multiprocessing), then print the results :param n: number of times to run the encounter :param num_procs: number of processes to use. If None, use max number of processes :return: aggregate stats

run(n=1000)[source]

Run the Encounter n times, then print the results :param n: :return:

reset_encounter()[source]

Reset the Encounter to prepare for another run. :return:

reset_stats()[source]

Reset stats (or set them for the first time)

Returns:

reset_encounter_stats()[source]

Reset stats that belong to the Encounter (e.g., number of rounds)

Returns:

reset_combatant_stats()[source]

Reset stats to do with Combatants

Returns:

reset_team_stats()[source]

Reset stats to do with Teams

Returns: