Points or Percentages?

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.
Post Reply
Message
Author
User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Points or Percentages?

#1 Post by Kinmoku »

Hi all,

Forgive me if this is a stupid question... I'm wondering if it's possible to use a percentage system in Ren'Py rather than points? I've only used points up until now, but I think I'd like to try percentages next time.

For example, I'm planning on having some character traits change throughout the game: Confidence VS Fear. Fear would be a low % and confidence would be a high %. Now, I could use points again, but there will be a lot of variables adjusting these traits throughout the game, and the outcomes/ endings will show this. I think I'll get the numbers wrong if I use points, and percentages feel a little more natural for me... I think these kind of traits are more on a spectrum than on/ off.

If this isn't possible, I'll just have to build the perfect set up for points :) But if percentages are a possibility, I'd much prefer to use them here.

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Points or Percentages?

#2 Post by philat »

Percentages is just a different way of calculating points. The basic set up would be:

Code: Select all

default confidence = 0
default fear = 0
default cf_result = 0

label start:

    menu:
        "Confident thing":
            $ confidence += 1.0
        "Fearful thing":
            $ fear += 1.0

    $ cf_result = confidence / (confidence + fear)
    $ pc = cf_result * 100
    $ pf = (1-cf_result) * 100
    "You are [pc] \% confident. You are [pf] \% fearful."
Massage the math as necessary, but the basic idea is the same.

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Points or Percentages?

#3 Post by Kinmoku »

philat wrote:Percentages is just a different way of calculating points. The basic set up would be:

Code: Select all

default confidence = 0
default fear = 0
default cf_result = 0

label start:

    menu:
        "Confident thing":
            $ confidence += 1.0
        "Fearful thing":
            $ fear += 1.0

    $ cf_result = confidence / (confidence + fear)
    $ pc = cf_result * 100
    $ pf = (1-cf_result) * 100
    "You are [pc] \% confident. You are [pf] \% fearful."
Massage the math as necessary, but the basic idea is the same.
Wow, awesome! Thank you :)

So, to refer to it, would I do something like this:

Code: Select all

if pf > 50: #50 percent
    e "Are you scared?"

elif pc > 50:
    e "You look confident!"
?

User avatar
KuroOneHalf
Regular
Posts: 129
Joined: Fri Apr 25, 2014 6:18 pm
Completed: Cuttlebone
Projects: Somewhere In The Shade
Deviantart: KuroOneHalf
itch: kuroonehalf
Contact:

Re: Points or Percentages?

#4 Post by KuroOneHalf »

Seems like that should work, yep. Give it a whirl and see.

ps: That if/else statement could just be:

Code: Select all

if pf > 50: #50 percent
    e "Are you scared?"

else:
    e "You look confident!"

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Points or Percentages?

#5 Post by wyverngem »

The only thing I would caution on is that you could accidentally divide by zero causing your game to crash.

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Points or Percentages?

#6 Post by Kinmoku »

wyverngem wrote:The only thing I would caution on is that you could accidentally divide by zero causing your game to crash.
Ah, good point. I guess there would need to be enough points scored before that code goes in? That should solve the issue, right?

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Points or Percentages?

#7 Post by wyverngem »

Just make the flag equal to 1. Then you'll always divide by 1 instead of zero.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1460
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Points or Percentages?

#8 Post by xavimat »

philat wrote:Percentages is just a different way of calculating points.
Another way of dealing with it:

Besides the math, the difference I see between points system and percentage system is the logic:
- with percentage there is a maximum
- with points there is no need of maximum

If your game has no maximum, the percentage system won't be so meaningfull. I'm using currently a simple combat system where the HP and skills have no maximum. There can be always increased, and new enemies can be always stronger than the older.

In your case, with two opposing stats, I'd use maximums. So the percentage is:

Code: Select all

 value_percent = value / 100 * MAX_VALUE
opposing_value_percent = (MAX_VALUE-value) / 100 * MAX_VALUE
But you can organize your game in a way that the maximum value is, indeed, 100. So the value itself is the percentage:

Code: Select all

"You have a value of [value]%"
$ opposing_value = 100 - value
"You have an opposing_value of [opposing_value]%"
And the player could start with 50 points.

EDIT to elaborate:
Xela's solution is interesting, it calculates the max_value using fear+confidence, a value that will change over the game.
The result of that is: the first decision in the game, that adds for the first time +1 to one of the values (fear or confidence) will be the equivalent to 100%. Later in the game, when the player has done 19 decisions, the next +1 will have an effect of 5%. If the game is long, after 199 decisions, the next decision will change the values in a 0.5%. So, your game should take this into account.
For example, later decisions could add more than +1 (+5, +20, +1000 points, for example).
Last edited by xavimat on Sun Dec 25, 2016 11:32 am, edited 2 times in total.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Points or Percentages?

#9 Post by Ocelot »

Besides the math, the difference I see between points system and percentage system is the logic:
- with percentage there is a maximum
- with points there is no need of maximum
I would call it a baseline, not maximum: some special value which has special meaning.
It might actually be maximum value, it might be softcap, after which you have diminishing returns or parameter decays over time, it might be normal value which is usually compared to other anyway (e.g. special attack deals 130% of normal damage)
< < insert Rick Cook quote here > >

User avatar
xavimat
Eileen-Class Veteran
Posts: 1460
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Points or Percentages?

#10 Post by xavimat »

Ocelot wrote:
Besides the math, the difference I see between points system and percentage system is the logic:
- with percentage there is a maximum
- with points there is no need of maximum
I would call it a baseline, not maximum: some special value which has special meaning.
It might actually be maximum value, it might be softcap, after which you have diminishing returns or parameter decays over time, it might be normal value which is usually compared to other anyway (e.g. special attack deals 130% of normal damage)
I understand 130% in an attack system, from a baseline (base damage points in an attack-skill), but OP talks about stats, and more specifically "opposing stats". More confidence is less fear (and the other way around). So 130% confidence would be -30% fear?, I think this beats the reason to have percentages.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]