Skip to content

Instantly share code, notes, and snippets.

@joaofig
Created July 13, 2023 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaofig/1f57faf87c286f1cf884c7410b72007c to your computer and use it in GitHub Desktop.
Save joaofig/1f57faf87c286f1cf884c7410b72007c to your computer and use it in GitHub Desktop.
def expand_path(path: PredictedPath,
max_branch: int = 3) -> list[PredictedPath]:
successors = get_successors(path.array[path.step-2], path.array[path.step-1])
best_expansions = []
total = successors.total()
for p in successors.most_common(max_branch):
new_probability = p[1] / total
new_path = evolve_path(path, p[0], new_probability)
best_expansions.append(new_path)
return best_expansions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment