Refactor random names

This commit is contained in:
oldnapalm
2024-03-02 10:40:15 -03:00
parent 10ac49b47c
commit 87936aa8f4
5 changed files with 267 additions and 30 deletions

File diff suppressed because one or more lines are too long

View File

@@ -2217,5 +2217,256 @@
3169994930,
4131541011,
4216468066
],
"country_codes": [
4,
8,
10,
12,
16,
20,
24,
28,
31,
32,
36,
40,
44,
48,
50,
51,
52,
56,
60,
64,
68,
70,
72,
74,
76,
84,
86,
90,
92,
96,
100,
104,
108,
112,
116,
120,
124,
132,
136,
140,
144,
148,
152,
156,
158,
162,
166,
170,
174,
175,
178,
180,
184,
188,
191,
192,
196,
203,
204,
208,
212,
214,
218,
222,
226,
231,
232,
233,
234,
238,
239,
242,
246,
248,
250,
254,
258,
260,
262,
266,
268,
270,
275,
276,
288,
292,
296,
300,
304,
308,
312,
316,
320,
324,
328,
332,
334,
336,
340,
344,
348,
352,
356,
360,
364,
368,
372,
376,
380,
384,
388,
392,
398,
400,
404,
408,
410,
414,
417,
418,
422,
426,
428,
430,
434,
438,
440,
442,
446,
450,
454,
458,
462,
466,
470,
474,
478,
480,
484,
492,
496,
498,
499,
500,
504,
508,
512,
516,
520,
524,
528,
531,
533,
534,
535,
540,
548,
554,
558,
562,
566,
570,
574,
578,
580,
581,
583,
584,
585,
586,
591,
598,
600,
604,
608,
612,
616,
620,
624,
626,
630,
634,
638,
642,
643,
646,
652,
654,
659,
660,
662,
663,
666,
670,
674,
678,
682,
686,
688,
690,
694,
702,
703,
704,
705,
706,
710,
716,
724,
728,
729,
732,
740,
744,
748,
752,
756,
760,
762,
764,
768,
772,
776,
780,
784,
788,
792,
795,
796,
798,
800,
804,
807,
818,
826,
831,
832,
833,
834,
840,
850,
854,
858,
860,
862,
876,
882,
887,
894
]
}

1
data/names.txt Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -510,6 +510,20 @@ def play_pace_partners():
pause = pacer_update_freq - (time.perf_counter() - start)
if pause > 0: time.sleep(pause)
def get_names():
bots_file = '%s/bot.txt' % STORAGE_DIR
if os.path.isfile(bots_file):
with open(bots_file) as f:
return json.load(f)['riders']
with open('%s/data/names.txt' % SCRIPT_DIR) as f:
data = json.load(f)
riders = []
for _ in range(1000):
is_male = bool(random.getrandbits(1))
riders.append({'first_name': random.choice(data['male_first_names']) if is_male else random.choice(data['female_first_names']),
'last_name': random.choice(data['last_names']), 'is_male': is_male, 'country_code': random.choice(zo.GD['country_codes'])})
return riders
def load_bots():
multiplier = 1
with open(ENABLE_BOTS_FILE) as f:
@@ -517,11 +531,6 @@ def load_bots():
multiplier = int(f.readline().rstrip('\r\n'))
except ValueError:
pass
bots_file = '%s/bot.txt' % STORAGE_DIR
if not os.path.isfile(bots_file):
bots_file = '%s/data/bot.txt' % SCRIPT_DIR
with open(bots_file) as f:
data = json.load(f)
i = 1
loop_riders = []
for name in os.listdir(STORAGE_DIR):
@@ -547,7 +556,7 @@ def load_bots():
bot.route = global_bots[i + 1000000].route
bot.position = positions.pop()
if not loop_riders:
loop_riders = data['riders'].copy()
loop_riders = get_names()
random.shuffle(loop_riders)
rider = loop_riders.pop()
for item in ['first_name', 'last_name', 'is_male', 'country_code', 'ride_jersey', 'bike_frame', 'bike_wheel_front', 'bike_wheel_rear', 'ride_helmet_type', 'glasses_type', 'ride_shoes_type', 'ride_socks_type']: