Skip to content

Commit e5f7117

Browse files
committed
[random] change seeding behavior so it doesn't affect global random behavior
1 parent 942bc24 commit e5f7117

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

TagScriptEngine/block/randomblock.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import random
1+
from random import Random
22
from typing import Optional
33

44
from ..interface import verb_required_block
55
from ..interpreter import Context
66

7+
random = Random()
78

89
class RandomBlock(verb_required_block(True, payload=True)):
910
"""
@@ -43,4 +44,6 @@ def process(self, ctx: Context) -> Optional[str]:
4344
spl = ctx.verb.payload.split(",")
4445
random.seed(ctx.verb.parameter)
4546

46-
return random.choice(spl)
47+
choice = random.choice(spl)
48+
random.seed()
49+
return choice

0 commit comments

Comments
 (0)