Gamelogic
  • Home
  • Blog
  • Tools
    • Grids 2 (for Unity)
      • Features
      • Documentation
    • Grids 1 (Legacy, for Unity)
      • 30 games in 30 days
      • Features
      • Tutorials, Documentation, and FAQ
      • Games made with Grids for Unity
      • Examples
      • What is new?
      • Grid Prototypes and Previews
      • Buy
    • Extensions
    • Colors
      • Features
      • Documentation and tutorials
      • Buy
    • Words
      • Features
      • Documentation
      • Buy
    • Abstract Strategy
      • Features
      • Documentation and tutorials
      • Examples
      • Buy
    • Match
      • Features
    • Grids (for GameMaker)
      • 30 games in 30 days
      • Features
      • Documentation
      • Buy
  • Buy
  • Articles
  • Support
    • Knowledge Base
    • Email Support
  • About
    • Meet our team

Blog

Introducing Response Curves

A response curve is an easy-to-define piece-wise linear curve. They are described by Bob Alexander in AI Programming Wisdom in the article The Beauty of Response Curves. Below is an example:

response_curve

The curve above can be defined as follows:

C#
1
2
3
var inputs = new List<float> {0, 20, 40, 60, 100};
var outputs = new List<float> {10, 30, 110, 140, 100};
var curve = new ResponseCurveFloat(inputs, output);

You can then sample this curve at any point:

C#
1
float value = curve[30f]; //value is 70

Note that input samples need not be evenly spaced, and that you can sample the curve at any floating point value. The curve is clamped at the ends, so in the example above, curve[150f] would give the value 100.

The Extensions library provides response curves for several types:

  • ResponseCurveFloat
  • ResponseCurveVector2
  • ResponseCurveVector3
  • ResponseCurveVector4
  • ResponseCurveColor

(Our Colors library also contains a ResponseCurveHSLColor).

Response curves have many applications. They can be used for:

  • lookup tables for function approximations
  • approximating smooth curves
  • defining paths in 2D or 3D space
  • defining color gradients
  • implementing arbitrary probability distributions

It is also trivial to implement Response Curves for your own types, by following these steps:

  • Extend your class ResponseCurveMyType from ResponseCurveBase<MyType>.
  • Implement the abstract method Lerp to provide a linear interpolation of MyType.
    That is it!

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Related

  1. Gamelogic Extensions for Unity 1.2 is now available  The newest version of our free extensions library is now...
  2. Introducing Generators  We added generators to version 1.2 of Extensions. A generator, in...
  3. What’s new in Extensions 2.2.1  We recently updated all our libraries. We will publish posts...
  4. New generators: designed from scratch for use in procedural content  We introduced generators the first time in Extensions 1.2. Those...
  • Permalink
  • Posted: 20 February 2015
  • Tags: response curve
  • Author: Gamelogic
Recent Posts
  • Tool Documentation Overhaul
  • What is new in Grids Pro 2.3.5
  • What is new in Grids Pro 2.3.2
  • What is new in Abstract Strategy 2.1.1
  • What is new in Words 2.0.2
Categories
  • 30 Games in 30 Days
  • AbstractStrategy
  • Aside
  • Colors
  • Example
  • Extensions
  • General
  • Grids
  • Grids 2
  • Previews
  • Programming
  • Social Media
  • Uncategorized
  • Words
Follow us on Twitter
My Tweets
Meta
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
  • Home
  • Features
  • Blog
  • About
  • 14 Eglin Road, Sunninghill, Johannesburg, South Africa
  • support@gamelogic.co.za
Stay Connected
  • Facebook
  • Google
  • Linkedin
  • Rss
  • Twitter
  • Gamelogic © 2013