Page 1 of 2

I made a routes analyser - visualise your project with a graph!

Posted: Fri Mar 05, 2021 1:55 pm
by Amethysts
Hello, this post isn't a question nor a VN but a tool I made that I want to present you.

The tool

Image

It takes your VN and makes a graph of the routes available.

DOWNLOAD IT HERE : https://github.com/EwenQuim/renpy-graphviz#how-to-use

or TEST IT ONLINE : https://ewenquim.github.io/renpy-graphviz

Image
The Question analyzed and a little bit customized (only 2 comments added in the script.rpy file).

----------

Going deeper in the project - for advanced coders

So the tool I made isn't perfect. There is plenty of room for improvement.

1. For now, the tool is only available on some all platforms
- Linux : ✅ works
- mac : ✅ works but unsigned -you have to manually say you trust this app and it's boring
- windows : ✅ works but triggers antivirus
- web : ✅ EDIT may 2021 : done maybe in the future, but this would be a very heavy project. Anyone interested ?

2. The Parser doesn't use an AST. It's a really simple one, so (very) advanced features aren't possible to implement without it. I tried to make one but o boi Ren'Py is hard to parse, especially about the label intenting problem.

3. I made a tag system https://github.com/EwenQuim/renpy-graphviz#tags

Code: Select all

label chapter_1: #renpy-graphviz: TITLE
Any label with this tag will be highlighted. Any ideas for new tags that would help customize your graph ?

4. I made it in Go for speed (I have considered Python but too slow to parse huge VNs), go the Go-Python link have some drawbacks. I have a lot of trouble implementing my "renpy-analytics" project - imagine seeing your user's route on this kind of graph..

EDIT june 2021 : done 5. It doesn't support screens :(

----------

My questions :

- does it work for you ?
- what should I do next ?
- if you worked with renpy for several years, have you considered helping PyTom on his patreon ?

Re: I made a routes analyser - visualise your project!

Posted: Fri Mar 05, 2021 2:18 pm
by zmook
Cool!

Does it distinguish 'call' from 'jump'?

I assume it can't handle `call expression scene_name`?

Re: I made a routes analyser - visualise your project!

Posted: Fri Mar 05, 2021 2:23 pm
by Amethysts
Not for the moment, it is used along with `return` and that's a bit complicated to analyze (especially if you have several levels of `call`), but I'll work on it, it's my next goal for this tool !
If you know Go don't hesitate to help me with the project ;)

Re: I made a routes analyser - visualise your project with a graph!

Posted: Fri Mar 05, 2021 2:45 pm
by hell_oh_world
Wrong section though. Even if you have those questions still the thread shouldn't be placed here.
Thanks for sharing anyways.

Re: I made a routes analyser - visualise your project with a graph!

Posted: Sun Mar 07, 2021 12:32 pm
by Triority
Worked on most of mine, except for the largest and then it just shuts down.

Re: I made a routes analyser - visualise your project with a graph!

Posted: Sun Mar 07, 2021 2:02 pm
by m_from_space
That's fantastic @Amethysts, thank you very much!

It works fine on my project so far and gives me good clues about stuff I may forget, especially if the game gets more complex. Great! :D

And it is kind of what I needed right now too.

The only strange thing is one label in the graph that is by itself and is called ": message", don't know why, no label is called like that.

Re: I made a routes analyser - visualise your project with a graph!

Posted: Mon Mar 08, 2021 12:43 pm
by Amethysts
Don't hesitate to show your graphs ! (or send me a private message) @m_from_space @hell_oh_world

Re: I made a routes analyser - visualise your project with a graph!

Posted: Tue Mar 09, 2021 9:37 am
by Triority
This is one of mine

Re: I made a routes analyser - visualise your project with a graph!

Posted: Tue Mar 09, 2021 9:43 am
by Triority
One more. This show that there is a lot to be removed and by the looks of things various infinite loops, which will be dealt with next year after my others have been released :)

It's a shame it doesn't work on my biggest ones though.

Re: I made a routes analyser - visualise your project with a graph!

Posted: Tue Mar 09, 2021 9:59 am
by Amethysts
These are beautiful graphs :D
The second one really is interesting, and the first one is quite linear!

Are you sure that your biggest games are correctly linted?
Normally, the algorithm works if the linter passes...
If so, could I see the code, if you don't mind of course ?

Re: I made a routes analyser - visualise your project with a graph!

Posted: Tue Mar 09, 2021 10:02 am
by Triority
Yes, I can certainly make the code available. Won't be a moment.

One (WTC 2/2) I can see failing due to using expression. But the other (WTC 2/3), I must admit is a bit odd.

Message sent, by the way !

Re: I made a routes analyser - visualise your project with a graph!

Posted: Tue May 04, 2021 10:19 am
by Amethysts
Sorry for the up, but I have done a few improvements, and the projets seems to evolve in a good way.
There is now:
- a live demo https://renpy.amethysts.studio/ so you can try to draw the graph of your VN from a public github repo
- `call` and `break` keyword detection
- choices detection (little text on edges between nodes of the graph)

I'm sure you'll find this tool interesting, don't hesitate to tell me what you think about this, and if there is a bug, you can tell me here : https://github.com/EwenQuim/renpy-graphviz/issues

Re: I made a routes analyser - visualise your project with a graph!

Posted: Tue May 04, 2021 10:45 am
by Ocelot
As expected, it does not like data-driven logic:
Image
Image

However, I am surprised how well it actually worked. I expected it to show a bunch of disjoined labels, or even crash due to half of the game written in Python and existence of creator defined statements, but it did get basic structure of the game:
Image

One problem I found: it appears that it does not work with sublabels:

Code: Select all

label global_return:
    call main_cleanup
    call room_scene
    if time_slice == 1:
        jump main_day.do
    else:
        jump main_night.do
There are no indications of global_return label links to main_day and main_night

Re: I made a routes analyser - visualise your project with a graph!

Posted: Tue May 04, 2021 4:00 pm
by Amethysts
- @Ocelot:
It is actually made for Story-Driven games haha.
As long as it is a story, the events will be correctly chained together. But when you add systems, it is more complicated... Parsing become awful so I try to do it a simple way -even if it is not 100% accurate.

I wasn't satisfied enough with this auto-generated graph, so I thought that a human hand can help guide the tool.

And success !!! You can check amethysts-studio/coalescence on the website: with the TAGS SYSTEM https://github.com/EwenQuim/renpy-graphviz#tags, everything is more clear and easy. The story is the main tree and the graphs on the side shows a map system I made and that I have separated with some tags: the IGNORE, BREAK and SKIPLINK were really helpful !

Thank you very much for testing it out ;)

I know it is not perfect, but this is a rather simple way to guide the algorithm doing its job.

- Also, I'm really interested in your project: it is possible to know the title and username ? It'll help me improve my tool

- I'll take care of sub-labels later, I didn't handled them because I thought they were rarely used.

- I would appreciate very much if you would leave a star to the project on Github, it encourages me to continue working to offer the best possible tool

Re: I made a routes analyser - visualise your project with a graph!

Posted: Tue May 04, 2021 4:36 pm
by Ocelot
Amethysts wrote: Tue May 04, 2021 4:00 pm - Also, I'm really interested in your project: it is possible to know the title and username ? It'll help me improve my tool
Sadly it is not my project and it is not public (yet). This is why I didn't post complete graph. The ussue is that the game is a date-sim with support of adding files with new events/characters/etc. later, so there is a lot of registering events/labels and python code to make it work. Generally most events are a single label with a return in the end which gets called from event engine depending on a lot of conditions. Not very good for automatic parsing.

Example of code reponsible for talking to character:

Code: Select all

label .talk:
    python:
        called_char_trivia = True
        rand_num = renpy.random.randint(1, char_num_phrases[called_character]['trivia'])
        label_string = called_character + '_trivia_' + str(rand_num)
    call expression label_string
    jump .c_menu
As you can see, it does not work well unless you basically run the game. For even more fun, part of the data is loaded from JSON files in the game folder.

It did work for prologue and first chapter (which are mostly static). However, one non intuitive part I saw arises from code like that:

Code: Select all

label one:
    menu:
        "choice 1":
            jump two
        "choice 2":
            pass
    "some text"
    "basically alternative to label two"
    jump three
    
label two:
   "some text"
   
label three:
    "text"
    jump four
    
label four:
    return
From generated graph you could think, that game jumps to the label three immideately after choosing choice 2 and choosing choice 1 will give you more story.