Seed random on policy init to make results deterministic (#466)
* seed random on policy init to make results deterministic * document new random behavior
This commit is contained in:
@@ -30,4 +30,7 @@ Client code should use the :meth:`~manticore.Manticore.locked_context` API::
|
||||
global_context['flag1'] += ['a']
|
||||
global_context['flag2'] += ['b']
|
||||
|
||||
"Random" Policy
|
||||
---------------
|
||||
|
||||
The `random` policy, which is the manticore default, is not actually random and is instead deterministically seeded. This means that running the same analysis twice should return the same results (and get stuck in the same places).
|
||||
|
||||
@@ -77,6 +77,7 @@ class Policy(object):
|
||||
class Random(Policy):
|
||||
def __init__(self, executor, *args, **kwargs):
|
||||
super(Random, self).__init__(executor, *args, **kwargs)
|
||||
random.seed(1337) # For repeatable results
|
||||
|
||||
def choice(self, state_ids):
|
||||
return random.choice(state_ids)
|
||||
|
||||
Reference in New Issue
Block a user