time-based point system

J

Jay

I'm writing a game script and the point system will be based upon time.
The less time there is between event one and event two, the higher
score you'll get for event two. However, I've got a problem figuring
how to do this. Here's why. I don't want the score system to just be
a straight charted system. Y'know, like if the time is between x and y
then the points you get are z. I want to mathematically figure out the
pointage. That's what I can't figure out how to do. If it were such
that the more time there is, the more points there are, that would be
easy. I could just multiply the time by something or other. Or, if
there was a time limit between the two events, that, too, would be easy
because I could subtract the amount of time spent from the possible
amount of time and multiply by something for points. Neither of these
are the case. Any suggestions?
 
E

Erik Max Francis

Jay said:
I'm writing a game script and the point system will be based upon time.
The less time there is between event one and event two, the higher
score you'll get for event two. However, I've got a problem figuring
how to do this. Here's why. I don't want the score system to just be
a straight charted system. Y'know, like if the time is between x and y
then the points you get are z. I want to mathematically figure out the
pointage. That's what I can't figure out how to do. If it were such
that the more time there is, the more points there are, that would be
easy. I could just multiply the time by something or other. Or, if
there was a time limit between the two events, that, too, would be easy
because I could subtract the amount of time spent from the possible
amount of time and multiply by something for points. Neither of these
are the case. Any suggestions?

You haven't indicated what _is_ the case, so this question cannot yet be
answered. You have to specify what the points measure, how they measure
it, and how they change over time. Once you do that, you can define (or
get help defining) how to calculate them. As it is you've not given
nearly enough information to answer your question.
 
J

Jay

Okay, this is a game. So the points are abstract. It's like an arcade
game in respect to the points. They don't actually mean or represent
anything. The only point is to get a high score. The idea is that the
faster the user acts (or reacts) the greater amount of points they'll
receive. Simplified, I need a fuction or statement that takes in a
small number and spits out a big number. The smaller the input, the
larger the output.
 
E

Erik Max Francis

Jay said:
Okay, this is a game. So the points are abstract. It's like an arcade
game in respect to the points. They don't actually mean or represent
anything. The only point is to get a high score. The idea is that the
faster the user acts (or reacts) the greater amount of points they'll
receive. Simplified, I need a fuction or statement that takes in a
small number and spits out a big number. The smaller the input, the
larger the output.

There are any number of functions which fit this property, like f(x) =
1/x. You'll have to define more clearly what properties of this
negative function you want to narrow it down beyond that.
 
J

Jay

That function is absolutely no good for this situation.

1. Take a small number.
5.4348809719085693

2. Put it in the function.
f(5.4348809719085693) = 1/5.4348809719085693

3. Get a large number???
0.18399666987533483

That number is even smaller. I want a large one coming out.
 
E

Erik Max Francis

Jay said:
That function is absolutely no good for this situation.

1. Take a small number.
5.4348809719085693

2. Put it in the function.
f(5.4348809719085693) = 1/5.4348809719085693

3. Get a large number???
0.18399666987533483

That number is even smaller. I want a large one coming out.

f(x) = 1/x is just one example of a function that has the property of
being a "negative function" -- the smaller number you put in, the larger
number you get out, and vice versa. Your statement didn't clearly
indicate that the outputs need to be bigger than the inputs, just that
they need to be bigger the smaller the outputs are. The more general
function would be f(x) = A/(x - B). Choose A and B as desired so that
f(x) > x for all x you care about. Or choose another function, like
f(x) = A - B x or any number of other functions. There literally are an
infinite number of possibilities.

The point is, as I've already said, you haven't given nearly enough
information to give you a useful answer. You haven't indicated, for
instance, anything at all about the domain or range of the function that
you want: What values do you need to plug in? What range of values do
you need to get out? Once you have clarified to yourself what
properties you want, that will help you define the function.

At this point you're the only one who knows what properties you want,
and unless you define them up front, it results in a very unsatisfactory
guessing game of proposing a function, you telling me what's wrong with
it, and repeat until either or both of us get bored.

And, by the way, this is a question about mathematics, and so has
nothing to do specifically with Python.
 
G

Gabriel Genellina

Okay, this is a game. So the points are abstract. It's like an arcade
game in respect to the points. They don't actually mean or represent
anything. The only point is to get a high score. The idea is that the
faster the user acts (or reacts) the greater amount of points they'll
receive. Simplified, I need a fuction or statement that takes in a
small number and spits out a big number. The smaller the input, the
larger the output.

1/x, or 1000/x, or 1000-x, or 1000*exp(-x) or ...
All decline differently, play drawing them and choose whatever tastes you more.



Gabriel Genellina
Softlab SRL





__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
 
J

Jay

I'm sorry. I never considered what you said about the relationship
about the input and output. I'll take my thread elsewhere to a math
board.
 
D

Dennis Lee Bieber

That function is absolutely no good for this situation.

1. Take a small number.
5.4348809719085693

2. Put it in the function.
f(5.4348809719085693) = 1/5.4348809719085693

3. Get a large number???
0.18399666987533483

That number is even smaller. I want a large one coming out.

Basically, you are going to have to define the condition that
produces the maximum points, such that anything /beyond/ that reduces
the maximum.

Say the maximum points for step X are "10"... Say you allow
0.1seconds before points are lost. Then, how rapidly are points lost?

def points(pmax, time, t0, t1):
#pmax = maximum points
#time = time duration taken
#t0 = time allowed for maximum points
#t1 = time at which zero points available
slope = pmax / (t1 - t0)
return max(0.0, pmax - (slope * max(0.0, (time - t0))))

Then get fancy... Maybe put in an exponential fall off, or
logarithmic...
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
P

Peter Otten

Jay said:
That function is absolutely no good for this situation.

1. Take a small number.
5.4348809719085693

2. Put it in the function.
f(5.4348809719085693) = 1/5.4348809719085693

3. Get a large number???
0.18399666987533483

That number is even smaller.  I want a large one coming out.

Not satisfied with with the shrink-wrapped functions available at your local
math-mart? Make your own from only a few data points:

from __future__ import division
import bisect

def make_function(*points):
"""Finest built-to-order maths since Archimedes"""
points = sorted(points)
xvalues = [p[0] for p in points]

def f(x):
i = bisect.bisect(xvalues, x)
if i == 0:
i = 1
if i >= len(xvalues):
i = len(xvalues) - 1
x0, y0 = points[i-1]
x1, y1 = points
return (y1-y0)/(x1-x0)*(x-x0) + y0
return f

if __name__ == "__main__":
f = make_function((0, 100000), (1, 100), (2, 10), (3, 1))
for i in range(-1, 21):
x = i / 10
print x, "-->", f(x)

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top