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:
JP Smith
2017-08-23 16:37:26 -05:00
committed by GitHub
parent 1b653be9b3
commit 60a99d2f81
2 changed files with 4 additions and 0 deletions

View File

@@ -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).

View File

@@ -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)