|
22 | 22 |
|
23 | 23 | import utils |
24 | 24 |
|
25 | | -# if os.environ['PYTHONHASHSEED'] != '0': |
26 | | -# utils.warn("Environment variable PYTHONHASHSEED should be set to 0 to make executions deterministic") |
| 25 | + |
| 26 | +# The seed used for randomness is important because if a solver has access to this seed it can cheat and |
| 27 | +# reverse-engineer the solutions to some puzzles. Don't share the seed with AI puzzle solvers :-) |
| 28 | +_AI_SEED = 12389484322359235125123212243523534510980967133563 |
27 | 29 |
|
28 | 30 |
|
29 | 31 | problem_registry = {} |
@@ -124,8 +126,7 @@ def register(problem_class): |
124 | 126 |
|
125 | 127 | PATH = os.path.join(utils.my_path, "problems/") |
126 | 128 |
|
127 | | -_secret_seed = None # Don't share the seed with the AI problem solver or it can cheat on several puzzles by |
128 | | -# re-generating the puzzles together with the solution :-) |
| 129 | + |
129 | 130 |
|
130 | 131 |
|
131 | 132 | class InterpreterError(Exception): pass |
@@ -342,19 +343,6 @@ def char(self, chars="0123456789abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTU |
342 | 343 | return self.choice(chars) |
343 | 344 |
|
344 | 345 |
|
345 | | -def get_seed_str(filename, summary): |
346 | | - global _secret_seed |
347 | | - if _secret_seed is None: |
348 | | - secret_seed_path = os.path.join(utils.my_path, "_secret_seed.txt") |
349 | | - try: |
350 | | - with open(secret_seed_path, "r") as f: |
351 | | - _secret_seed = f.read() |
352 | | - except FileNotFoundError: |
353 | | - utils.warning(f"Couldn't find `{secret_seed_path}`") |
354 | | - _secret_seed = "92354683922359" |
355 | | - return f"{filename} | {_secret_seed} | {summary}" |
356 | | - |
357 | | - |
358 | 346 | class ProblemSet: |
359 | 347 | def __init__(self, name, summary=None): |
360 | 348 | self.problems = [] # Problem's |
@@ -587,13 +575,13 @@ def get_example(cls): |
587 | 575 |
|
588 | 576 | timeout = None # how much longer than usual can sat run? |
589 | 577 |
|
590 | | - def __init__(self, seed=None): |
| 578 | + def __init__(self, seed=_AI_SEED): |
591 | 579 | self.name = self.__class__.__name__ |
592 | 580 | if not self.__doc__ or self.__doc__ == Problem.__doc__: |
593 | 581 | self.desc = "<No description/docstring>" |
594 | 582 | else: |
595 | 583 | self.desc = unindent(self.__doc__) |
596 | | - self.random = BuilderRandom(f"{seed} | {self.name} | {self.desc}") |
| 584 | + self.random = BuilderRandom(f"{seed} | {self.name}") |
597 | 585 | self.instances = [] |
598 | 586 | self._seen_problems = set() |
599 | 587 | self._built_target = 0 |
@@ -778,7 +766,7 @@ def save_readme(problem_sets, filename=os.path.join(PATH, "README.md")): |
778 | 766 | tot_instances += n_instances |
779 | 767 | table += f"- [{sec_name} ({len(ps.problems):,} problems, {n_instances:,} instances)](#{sec_name.lower().replace(' ', '-')})\n" |
780 | 768 | for i, problem in enumerate(ps.problems): |
781 | | - section += f"### {problem.name} ({link} {i + 1:,}/{n:,})\n\n" |
| 769 | + section += f"### {problem.name}\n({link} {i + 1:,}/{n:,})\n\n" |
782 | 770 | section += f"**Description:**\n{problem.desc}\n\n" |
783 | 771 | section += f"**Problem:**\n\n```python\n{problem.instances[0].src}\n```\n" |
784 | 772 | if len(problem.instances[0].sol_srcs) > 0: |
|
0 commit comments