Author Topic: Usefulness of general math parser in your roguelike.  (Read 9516 times)

sokol815

  • Rogueliker
  • ***
  • Posts: 85
  • Karma: +0/-0
  • Web Developer by Day, still Web Developer by night
    • View Profile
    • Email
Usefulness of general math parser in your roguelike.
« on: March 23, 2014, 10:44:09 PM »
In my current roguelike project, I built a math parser which can take a string of operations and return an output.
operations: + - %(modulus) / * ^(power)  and of course ndm (e.g. 2d3)
There are a couple of use-cases that use these advanced operations to make interesting game-play.
Say I have the hammer of thor, but it's power wanes quite a bit we can say it deals "2d3^2" damage to get values of [4,9,16,25,36].  or perhaps even "2d2^1d2" for [2,3,4,9,16] damage. In the latter case, the ending portion may symbolize a critical strike or so.

%(modulus) could be useful too. Perhaps you have been cursed by a god to no longer have great power, so a %4d4 is added to all your rolls which can result in your damage getting capped. Perhaps the game will tell you "The heaven's rumble" or something like that when the modification reduces the damage you should have dealt.

Are there any other ways you guys have found of making damage more interesting?

Hi

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 154
  • Karma: +0/-0
    • View Profile
    • Email
Re: Usefulness of general math parser in your roguelike.
« Reply #1 on: March 24, 2014, 12:18:59 AM »
There is the Cauchy and related probability distributions, that have a mean of infinity.  (flip a coin until you get heads, damage is 2^number of tails) but if you play around with them you'll see that for any finite sample the mean is much lower.

How about a weapon that does damage as 2d(your max health - current health). 
Or one that is best for the final blow because it does damage (opponents max health - current health)d2
« Last Edit: March 24, 2014, 02:36:58 AM by Hi »

koiwai

  • Rogueliker
  • ***
  • Posts: 99
  • Karma: +0/-0
    • View Profile
Re: Usefulness of general math parser in your roguelike.
« Reply #2 on: March 24, 2014, 01:35:53 AM »
When using formulas like this, you should really tell the player what the damage is going to be. The dice roll expressions (NdM), although, imho, unnatural for computer games, are still pretty good at conveying this information to the players.

Not sure is it a problem for you or not, but if I had such complex airthmetic expressions for damage, I would do the following: for each weapon, show the histogram (the distribution) of the damage, something like this:
Code: [Select]
    # #
  # # # # # 
# # # # # # # # #
1 2 3 4 5 6 7 8 9
Then, no matter how complex the computed expression is, the player can visually see the odds.
And the histogram can be sampled once from ~100-1000 trials, you don't really need to derive the formula for it. (Unless you do some wierd distributions like the one suggested by Hi, but you can really stick to the good-behaving ones)

Hi: Do you mean the Cauchy distribution?

Hi

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 154
  • Karma: +0/-0
    • View Profile
    • Email
Re: Usefulness of general math parser in your roguelike.
« Reply #3 on: March 24, 2014, 02:43:32 AM »
Hi: Do you mean the Cauchy distribution?
Thanks, Yes I did.
« Last Edit: March 24, 2014, 03:58:12 PM by Hi »

sokol815

  • Rogueliker
  • ***
  • Posts: 85
  • Karma: +0/-0
  • Web Developer by Day, still Web Developer by night
    • View Profile
    • Email
Re: Usefulness of general math parser in your roguelike.
« Reply #4 on: March 24, 2014, 04:24:06 AM »
When using formulas like this, you should really tell the player what the damage is going to be. The dice roll expressions (NdM), although, imho, unnatural for computer games, are still pretty good at conveying this information to the players.

Not sure is it a problem for you or not, but if I had such complex airthmetic expressions for damage, I would do the following: for each weapon, show the histogram (the distribution) of the damage, something like this:
Code: [Select]
    # #
  # # # # # 
# # # # # # # # #
1 2 3 4 5 6 7 8 9
Then, no matter how complex the computed expression is, the player can visually see the odds.
And the histogram can be sampled once from ~100-1000 trials, you don't really need to derive the formula for it. (Unless you do some wierd distributions like the one suggested by Hi, but you can really stick to the good-behaving ones)

Hi: Do you mean the Cauchy distribution?

I like that idea a lot. Battle for wesnoth does exactly what you suggested with the damage diagrams. I shall have to add those to my game. I am currently lacking a decent Item-stats display screen. That would fit perfectly on there.

koiwai

  • Rogueliker
  • ***
  • Posts: 99
  • Karma: +0/-0
    • View Profile
Re: Usefulness of general math parser in your roguelike.
« Reply #5 on: March 24, 2014, 05:28:20 AM »
Awesome. Did not know that Wesnoth does something like that, but I played it ~ 3-5 years ago, and they could change the game quite a lot since then. Maybe, I should give it a try again.