Introduction
Introduction Statistics Contact Development Disclaimer Help
Use random.sample instead of random.choices. - annna - Annna the nice friendly …
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit e71c6746ae86f639be9e6a5d444e472ce4894ccb
parent e633438c4baa7d8cffee0038bc0062e8507171d6
Author: Annna Robert-Houdin <[email protected]>
Date: Wed, 30 Aug 2023 12:32:31 +0200
Use random.sample instead of random.choices.
Random.sample gives back unique entries.
Diffstat:
M modules/idlerpg/idlerpg-channel-se… | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/modules/idlerpg/idlerpg-channel-service.py b/modules/idlerpg/idler…
@@ -224,10 +224,10 @@ def main(args):
hackers[hacker][5] = newlevel
if random.randint(1, 65535) > 65500 and len(hackers) > 1:
- (attacker, defender) = random.choices(list(hackers.keys()), k=…
+ (attacker, defender) = random.sample(list(hackers.keys()), 2)
attack(hackers, attacker, defender)
- elif random.randint(1, 65535) < 10 and len(hackers) > 1:
- questhackers = random.choices(list(hackers.keys()), k=random.r…
+ elif random.randint(1, 65535) < 30 and len(hackers) > 1:
+ questhackers = random.sample(list(hackers.keys()), random.rand…
go_on_quest(hackers, questhackers)
writeout_dictfile("%s/hackers.txt" % (basepath), hackers)
@@ -266,7 +266,7 @@ def main(args):
if len(cmdargs) > 0 and cmdargs[0] in hackers:
attack(hackers, hacker, cmdargs[0])
else:
- (attacker, defender) = random.choices(list(hackers…
+ (attacker, defender) = random.sample(list(hackers.…
attack(hackers, attacker, defender)
elif cmd == "!quest":
if len (cmdargs) > 0 and cmdargs[0] in hackers:
@@ -276,7 +276,7 @@ def main(args):
argsinhackers.append(cmdarg)
go_on_quest(hackers, argsinhackers)
else:
- questhackers = random.choices(list(hackers.keys())…
+ questhackers = random.sample(list(hackers.keys()),…
go_on_quest(hackers, questhackers)
elif user == "-!-":
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.