-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Add layout database #852
base: main
Are you sure you want to change the base?
Conversation
I refined the existing |
Oh, sorry, I didn't see that. I also reworked the code in |
do you have a profiling for this? How much faster is it to start with a fully connected graph and remove the nodes? |
I just profiled it. @jbdyn’s new variant is twice as fast as ours on the normal mazes. Interestingly, |
def find_chambers(G: nx.Graph, shape):
w, h = shape
main_chamber = set()
chamber_tiles = set()
for chamber in nx.biconnected_components(G):
max_x = max(chamber, key=lambda n: n[0])[0]
min_x = min(chamber, key=lambda n: n[0])[0]
if min_x < w // 2 <= max_x:
# only the main chamber covers both sides
# our own mazes should only have one central chamber
# but other configurations could have more than one
main_chamber.update(chamber)
continue
else:
chamber_tiles.update(set(chamber))
# remove shared articulation points with the main chamber
chamber_tiles -= main_chamber
# combine connected subgraphs
subgraphs = G.subgraph(chamber_tiles)
chambers = list(nx.connected_components(subgraphs))
return chambers, chamber_tiles Using this instead of |
@jbdyn : is it OK if we push to this branch to move it forward? |
Sure! |
This PR adds a Python script for generating the database for Pelita mazes.