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

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
Amethysts
Regular
Posts: 40
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

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

#1 Post by Amethysts » Fri Mar 05, 2021 1:55 pm

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://renpy.amethysts.studio/

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 ?
Last edited by Amethysts on Sun Jun 06, 2021 5:18 pm, edited 10 times in total.

User avatar
zmook
Regular
Posts: 170
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

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

#2 Post by zmook » Fri Mar 05, 2021 2:18 pm

Cool!

Does it distinguish 'call' from 'jump'?

I assume it can't handle `call expression scene_name`?
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
Amethysts
Regular
Posts: 40
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

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

#3 Post by Amethysts » Fri Mar 05, 2021 2:23 pm

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 ;)

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 703
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Github: hell-oh-world
Location: Philippines
Contact:

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

#4 Post by hell_oh_world » Fri Mar 05, 2021 2:45 pm

Wrong section though. Even if you have those questions still the thread shouldn't be placed here.
Thanks for sharing anyways.

User avatar
Triority
Regular
Posts: 87
Joined: Fri Jul 20, 2018 1:28 pm
Completed: Welcome To... Chichester 0, 1,2 OVN 1, OVN 2, OVN 3, No Regrets For The Future
Projects: Welcome To... Chichester series
Organization: Triority
itch: triority
Location: England
Contact:

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

#5 Post by Triority » Sun Mar 07, 2021 12:32 pm

Worked on most of mine, except for the largest and then it just shuts down.

m_from_space
Regular
Posts: 26
Joined: Sun Feb 21, 2021 3:36 am
Contact:

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

#6 Post by m_from_space » Sun Mar 07, 2021 2:02 pm

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.

User avatar
Amethysts
Regular
Posts: 40
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

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

#7 Post by Amethysts » Mon Mar 08, 2021 12:43 pm

Don't hesitate to show your graphs ! (or send me a private message) @m_from_space @hell_oh_world

User avatar
Triority
Regular
Posts: 87
Joined: Fri Jul 20, 2018 1:28 pm
Completed: Welcome To... Chichester 0, 1,2 OVN 1, OVN 2, OVN 3, No Regrets For The Future
Projects: Welcome To... Chichester series
Organization: Triority
itch: triority
Location: England
Contact:

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

#8 Post by Triority » Tue Mar 09, 2021 9:37 am

This is one of mine
Attachments
renpy-graphviz.png

User avatar
Triority
Regular
Posts: 87
Joined: Fri Jul 20, 2018 1:28 pm
Completed: Welcome To... Chichester 0, 1,2 OVN 1, OVN 2, OVN 3, No Regrets For The Future
Projects: Welcome To... Chichester series
Organization: Triority
itch: triority
Location: England
Contact:

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

#9 Post by Triority » Tue Mar 09, 2021 9:43 am

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.
Attachments
renpy-graphviz.png

User avatar
Amethysts
Regular
Posts: 40
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

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

#10 Post by Amethysts » Tue Mar 09, 2021 9:59 am

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 ?

User avatar
Triority
Regular
Posts: 87
Joined: Fri Jul 20, 2018 1:28 pm
Completed: Welcome To... Chichester 0, 1,2 OVN 1, OVN 2, OVN 3, No Regrets For The Future
Projects: Welcome To... Chichester series
Organization: Triority
itch: triority
Location: England
Contact:

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

#11 Post by Triority » Tue Mar 09, 2021 10:02 am

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 !

User avatar
Amethysts
Regular
Posts: 40
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

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

#12 Post by Amethysts » Tue May 04, 2021 10:19 am

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

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1146
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

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

#13 Post by Ocelot » Tue May 04, 2021 10:45 am

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
< < insert Rick Cook quote here > >

User avatar
Amethysts
Regular
Posts: 40
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

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

#14 Post by Amethysts » Tue May 04, 2021 4:00 pm

- @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

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1146
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

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

#15 Post by Ocelot » Tue May 04, 2021 4:36 pm

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.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Google [Bot]