Skip to content

Commit b9c5d17

Browse files
committed
reduce collision
1 parent c0c7c8e commit b9c5d17

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

eval_protocol/human_id/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ def generate_id(
3939
adjectives = dictionary.adjectives
4040
nouns = dictionary.nouns
4141

42-
# Calculate total combinations: adjectives * nouns * 100 (for 00-99)
43-
total = len(adjectives) * len(nouns) * 100
42+
# Calculate total combinations: adjectives * nouns * 1000000 (for 000000-999999)
43+
total = len(adjectives) * len(nouns) * 1000000
4444

4545
if index >= total:
4646
raise ValueError(f"index out of range. Received {index}, max allowed is {total - 1}")
4747

4848
# Decompose index into adjective, noun, and number
49-
number = index % 100
50-
remaining = index // 100
49+
number = index % 1000000
50+
remaining = index // 1000000
5151
noun_idx = remaining % len(nouns)
5252
adj_idx = remaining // len(nouns)
5353

5454
adjective = adjectives[adj_idx]
5555
noun = nouns[noun_idx]
5656

57-
return f"{adjective}{separator}{noun}{separator}{number:02d}"
57+
return f"{adjective}{separator}{noun}{separator}{number:06d}"
5858

5959
# Random generation
6060
random_obj = system_random
@@ -63,15 +63,15 @@ def generate_id(
6363

6464
adjective = random_obj.choice(dictionary.adjectives)
6565
noun = random_obj.choice(dictionary.nouns)
66-
number = random_obj.randint(0, 99)
66+
number = random_obj.randint(0, 999999)
6767

68-
return f"{adjective}{separator}{noun}{separator}{number:02d}"
68+
return f"{adjective}{separator}{noun}{separator}{number:06d}"
6969

7070

7171
def num_combinations() -> int:
7272
"""
7373
Return the total number of unique IDs possible.
7474
75-
Format uses adjective-noun-NN, so total = adjectives * nouns * 100.
75+
Format uses adjective-noun-NNNNNN, so total = adjectives * nouns * 1000000.
7676
"""
77-
return len(dictionary.adjectives) * len(dictionary.nouns) * 100
77+
return len(dictionary.adjectives) * len(dictionary.nouns) * 1000000

0 commit comments

Comments
 (0)