views:

293

answers:

6

So lets say there's a game that has a 'life bar' that consists of theoretical levels. As the user performs specific actions, depending on accuracy of their actions, the life bar grows at a corresponding speed. As it grows and goes into next levels, the criteria for desirable actions change and so the user now has to figure out what those new actions are, to keep the bar growing instead of shrinking. And while the user tries to learn which actions/patterns result in growth, things like 'time' along with undesirable actions slowly bring them back down.

I'm wondering if anyone knows of any open-source games that may have similar logic.

Or perhaps if there's a name for this type of logic so I can try and find some algorithms that may help me set something like this up.

TIA

-added
As it seems there's probably no technical term for something like this, perhaps someone can suggest some pseudo top level logic. I've never built a game before and would like to raise my chances of heading in the optimum direction.

+5  A: 

That sounds suspiciously like my Stack Overflow reputation score.

Bill the Lizard
lol, someone voted you down!
Mitch Wheat
Apparently they thought I was joking. They should take a close look at how reputation and "karma" are calculated on some sites that have such concepts.
Bill the Lizard
Some people have no sense of humor. I felt obligated to negate that -1 (even though your answer is wiki). =)
gnovice
+2  A: 

That sounds a lot like an experience bar.

Robert S.
+1  A: 

To be honest, the best way to really do this might just be trial and error. Invent a formula, not too complicated. Play with it in game. If it feels a bit chunky or stiff or floppy or whatever, adjust it, add terms, just experiment.

eventually, it will feel aesthetically pleasing. Thats what you want. It should feel like the response of the health bar follows the effort you're putting in.

Also, just by writing the game, you'll know it pretty well. Be sure and give your friends/coworkers/any random victim, a chance to try it too and determine if they feel it is aesthetically right as you do.

TokenMacGuy
+3  A: 

It sounds like you're trying to model karma... I think there's a few web sites that have karma-like systems (SO's rep system is arguably something like that).

I'd start with something simple... If the user does "good" things, it goes up. If they do bad things it goes down. If they do nothing (sloth?), it goes down slowly.

gnovice
+3  A: 

For the purpose of this code, let's pretend that the bar holds the score for the player.

Score = Max score that can be received from the action without modifier
Accuracy = [0..1] Where 0 is total miss on the action and 1 is a perfect hit.
           Example: The score for a headshot
LevelModifier = [0..1] Where 0 means that in this level, it doesn't give any 
                scores and 1 means that the player receives the max bonus. 

                You can also refer to this as a difficulty modifier. 
                The higher the level, the more bonus you get.

ScoreDelta = (Score * Accuracy) * LevelModifier

ScoreBar += ScoreDelta

For the timer, you can lower their ScoreBar every second.

ScoreBar -= TimePenalty

For gameplay reasons, you can reset the timer whenever the player does an action. This would reward players who kept moving.

MrValdez
+2  A: 

It sounds like you would be best-served by using a state machine.

State A:
* Walk Forward : ++Points
* Jump         : Points += 100
* Points < 100 : Go to State A
* Points > 100 : Points = 0; Go to State B
* Points > 150 : Points = 0; Go to State C

State B:
* Kill Bad Guy : ++Points
* Get Hurt     : --Points
* Points < -50 : Points = 0; Go to State A
* Points < 100 : Go to State C
* Points > 100 : Points = 0; Go to State D
...etc...

That 'Points == 150' condition is just something I made up to demonstrate the power of the state machine. If the player does something especially good to jump from less than 100 to above 150, then he gets to skip a level. You could even have bonus levels that are only accessible in this way.

Edit: Wow, I got so engrossed in my typing, that I kinda forgot what the initial problem was. Hopefully my answer makes more sense now.

(I think most of the other answerers are interpreting your description as logarithmic growth.)

Ryan Fox