#1859 - Started giving the red agent some 'intelligence' and a sense of a state. Changed Application.run to .execute.
This commit is contained in:
16
src/primaite/game/science.py
Normal file
16
src/primaite/game/science.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from random import random
|
||||
|
||||
|
||||
def simulate_trial(p_of_success: float):
|
||||
"""
|
||||
Simulates the outcome of a single trial in a Bernoulli process.
|
||||
|
||||
This function returns True with a probability 'p_of_success', simulating a success outcome in a single
|
||||
trial of a Bernoulli process. When this function is executed multiple times, the set of outcomes follows
|
||||
a binomial distribution. This is useful in scenarios where one needs to model or simulate events that
|
||||
have two possible outcomes (success or failure) with a fixed probability of success.
|
||||
|
||||
:param p_of_success: The probability of success in a single trial, ranging from 0 to 1.
|
||||
:returns: True if the trial is successful (with probability 'p_of_success'); otherwise, False.
|
||||
"""
|
||||
return random() < p_of_success
|
||||
Reference in New Issue
Block a user