Skip to content
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

core: utility method for visualizing worlds as PlantUML #1935

Merged
merged 4 commits into from
Oct 1, 2023

Conversation

el-u
Copy link
Collaborator

@el-u el-u commented Jul 4, 2023

What is this fixing or adding?

This adds a utility method that allows world developers to debug their world visually by generating a PlantUML diagram representing the Regions and their connections via Entrances. This can be used, e.g., to quickly identify unconncted Entrances or orphaned Regions.

Locations and the filled Items can be show in the diagram as well, so one can also use this to illustrate the fill state.

How was this tested?

See screenshots.

If this makes graphical changes, please attach screenshots.

  • ALttP, with locations hidden:
    alttp_locations_hidden

  • I don't know what world this is Adventure, after create_regions:
    idk_after_create_regions

  • ALttP again, but after pre_fill:
    alttp_after_pre_fill

  • KH2, fill completed (right before generate_output):
    kh2_after_fill

  • No comment:
    no_comment

  • No comment either:
    no_comment_2

@Silvris
Copy link
Collaborator

Silvris commented Jul 4, 2023

2nd image is of Adventure.

Utils.py Outdated Show resolved Hide resolved
@ThePhar ThePhar added the is: documentation Improvements or additions to documentation. label Jul 4, 2023
@kindasneaki
Copy link
Collaborator

It might be a good idea to have something in the docs to explain what each thing does

@el-u
Copy link
Collaborator Author

el-u commented Jul 8, 2023

It might be a good idea to have something in the docs to explain what each thing does

I added a bit to the world docs that explains that this feature exists. Since the default arguments are sane enough so that the average developer wouldn't need to change them, I don't explain that there. Advanced users will look at the function docstring, which explains what each of the arguments does.

@BootsinSoots
Copy link
Contributor

I would like this very much. I am actually stuck at a point when generating where something like this would be very useful - I'm having problems locating exactly where my generation is getting extra locations from.

Copy link
Collaborator

@kindasneaki kindasneaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've ran this a couple times to test my world. It took me a bit to figure out how to open the .puml file but after doing so it was very helpful to see how all my regions connect together.

@Zunawe
Copy link
Collaborator

Zunawe commented Sep 28, 2023

An additional thing that I would find helpful is being able to pass in a subset of regions or region names to highlight in a certain color or put in a bounding box or something. That way you could pass in reachable_regions from a CollectionState to visually see which regions are in sphere 1, or double check which regions open up when certain items are collected, or show the current state of your world when stepping through fill_restrictive, etc...

state = CollectionState(self.multiworld)
state.collect(important_items[0])
state.collect(important_items[1])
...
visualize_regions(self.multiworld.get_region("Menu", self.player), "reachable_regions.puml",
                  highlight_regions=state.reachable_regions[self.player])

@el-u
Copy link
Collaborator Author

el-u commented Sep 28, 2023

Not planning to add any more features at this time.

@Zunawe
Copy link
Collaborator

Zunawe commented Sep 29, 2023

Fair enough. It's still very useful as-is.

@black-sliver black-sliver merged commit 485aa23 into ArchipelagoMW:main Oct 1, 2023
12 checks passed
@el-u el-u deleted the visualize_regions branch October 2, 2023 00:15
FlySniper pushed a commit to FlySniper/Archipelago that referenced this pull request Nov 14, 2023
…W#1935)

* core: typing for MultiWorld.get_regions

* core: utility method for visualizing worlds as PlantUML

* core: utility method for visualizing worlds as PlantUML: update docs
Jouramie pushed a commit to Jouramie/Archipelago that referenced this pull request Feb 28, 2024
…W#1935)

* core: typing for MultiWorld.get_regions

* core: utility method for visualizing worlds as PlantUML

* core: utility method for visualizing worlds as PlantUML: update docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is: documentation Improvements or additions to documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants