Game Development Community

Programming Response curves?

by Jarrod Roberson · in Technical Issues · 12/08/2002 (4:14 pm) · 5 replies

I am working on implementing Response Curves from an article in "AI Programming Wisdom". The article is 2.6 "The Beauty of Response Curves".

The problem is he lists how to calculate the relative distance across the bucket and how to calculate the return value are listed in math formulas.

I anyone has this book, could you explain in pseudo-code or something in more laymens terms the formulas?

#1
12/10/2002 (7:48 pm)
Ok I assume that no one has this book, here is the page in question, any help with converting these forumlas into code would be greatly appreciated. This is a really great book by the way.

this is a link to an image of the page by the way --> Response Curve Formulas

Thanks
#2
12/10/2002 (10:09 pm)
I think Phil Carlisle wrote chapters for that book...
#3
12/12/2002 (8:11 pm)
Yeah, he did.

The entire book is well written and full of practical articles, this one just does not have any code related and my math background is lacking on reading these formulas posted in the link above.

Just some simple ENGLISH explaination of the formulas would be nice.
#4
12/13/2002 (2:06 am)
I've read thru this chapter, don't understand the final equation as it's written - but think I know what it's doing.... Would also like to point out that I've not actually tried this so I might be wrong......

Take a look at the graph on page 78

Let's say that our input value for this graph is in the range of 0 - 100 (write the values on the page, x axis)

Equation 2.6.1
--------------

imax = 100
imin = 0 .......these are from our input range

there are 11 samples on the graph (count the dots)

so, db = (100-0)/(11-1) = 10

ie, the size of each bucket = 10 (now write 10, 20, 30... between the 0 and 100 from before)

Equation 2.6.2
--------------

v is our input value (in the range of 0-100) - lets say v=56

we already know imin = 0 amd that there are 11 buckets

so, ib = (56 - 0) / 11 = 5.09
it tells us to Floor the value, so round it down to 5
so... ib = 5

What this means is that our output value is somewhere between the 2 edge values for bucket 5 - look at the graph on page 78 again - bucket 5 is at the lowest point on the graph (i'm counting from 0 = bucket1 )- with my trusty ruler it looks like the value for the lower edge of bucket 5 is 0.4 (from the y axis) and the higher edge of bucket 5 is 0.5

The lower edge of bucket 5 equates to an input value of 50 in this example, the higher edge of bucket 5 equates to an input value of 60

What we need to do now is find out how far across bucket 5 we are, and so therefore where abouts between 0.4 and 0.5 our real output value should be.

Equation 2.6.3
--------------

v = 56 (our input value)
imin = 0
ib = 5 (worked out in 2.6.2)
db = 10 (worked out in 2.6.1)

so, t = ( (56-0) - (5*10) ) / 10
t = (56-50) / 10
t = 6 / 10
t = 0.6

This means that our output value is 0.6 of the way across bucket 5

Equation 2.6.4
--------------

Hmmmmmm I dont get maths notation in this one. But this equation gives us our final output value.

Our value of t= 0.6
t tells us how far we go from the lower bucket edge value to the higher bucket edge value.
if t=0 then we are 100% at the lower edge bucket value
if = 1 then we are 100% at the higher edge bucket value

So, this is the bit I'm not sure on - but it stands to reason that:

lower bucket value = 0.4
higher bucket value = 0.5

we are 0.6 (or 60%) of the "way" from 0.4 to 0.5

The way I've worked it out is to take the difference between the bucket edges (0.1 for this example) and multiple that by t, then add this to the lower edge value.

so, outputV = (difference * t) + bucketLow

in this case outputV = ((0.5-0.4)*0.6) + 0.4
outputV = (0.1*0.6) + 0.4
outputV = (0.06) + 0.4
outputV = 0.46

which looks about right using the ruler on the graph....

Slightly unscientific ending - if anyone can enlighten so to whats really supposed to happen at the end that would be great.

Anyhow... after having written this monster post I'll give it a go at getting this into Torque over the weekend, can't promise anything but I'll post again if I get it working in enqine.

Edit: fixed typo for value of t
#5
12/13/2002 (11:28 am)
Awesome explaination Chris, I wrote Bob Alexander ( the author of the article ) but have not heard anything back yet, I will post his response, if any on this thread.

It seems like a smoother solution than weighted calls to a random function or just a linear look up based list.


PS: that last formula is a bugger, I thought I had the basic idea of the first ones, but that last one stumped me completely. You assumption sounds pretty close.