Friday, October 06, 2017

Project 16: Covert Action in Space: Update 2

I've been working on my Covert Action in Space project and reached the point where I wanted to be able to see a graph of the spaces I'm generating. Particularly, when I was working on my first system, it was difficult to get a feeling for how the spaces work (or if they worked). At first I had been thinking that I’d look and find a simple algorithm to draw a graph and then implement that in something simple like Processing. Fortunately, poor google-fu prevented me from finding a good algorithm and instead I found GraphViz.


I'm not sure I want to work here, but I'd look for their industrial secrets.



Despite that tweet, I managed to keep my wits about me and realize that I don’t need to create my own graphing system, I just want to see a graph of the space layout. So instead of spending time learning a graphing algorithm and dealing with all of the problems that’s likely to create, now I just need to output a simple text file and let the magic happen.


GraphViz is great. It’s capable of doing a lot of stuff of which I only need it to do a little bit. To output, I need to make a list of all room connections and put it in GraphViz’s dot format. Internally I’m keeping this information in a map so that each entry has all of the rooms that a room connects to. This produces duplicates in the list, but using the strict keyword GraphViz automatically ignores those.
The code to generate the dot file works out to be quite simple.

And the dot file for the graph up top. Again I'm not particularly stressing GraphViz.



As I said, this makes it really easy to look at how spaces are connected and how those spaces work. I’m really glad I was able to get this working without needing to spend too much time on it.

The next job from here is to start laying out an actual floor plan based on the given space. I have a rough plan, basically starting with a default shape for each room and then expanding them to fit together. I can probably come up with something more complex, but as with the space generation, I’d like to start simple.

No comments:

Post a Comment

Giant Bugs and Staying on Top of Things

Into the Breach, Subset Games, 2018   This is a mix of obvious video game tactics and their obvious implications for getting things done. I&...