Wednesday, April 1, 2009

FRP Design Challenge

To start off with, the purpose of this post is to find out what ideas are out there and maybe start some new ones. I'm not looking to get people to work on things that I've thought up, more interested to see what they think about them.

I think programmers need to start using the word design more than art. This really captures the balance between usefulness of a piece of software and how nice it is to work with and even just look at. Haskell and other functional languages seem to have a huge potential for software design. So that should be the key, abstractions that combine mathematical beauty, with practical purpose and are just nice to work with. Abstractions that are only about mathematical beauty are more art than design.

I've been quite interested in the functional reactive programming since these projects seem to be working towards a nice solution for programming both user interfaces and games. One thing I've noticed is that the emphasis is on local definition of what components do, which seemed to be hinted at in this lambda the ultimate post.

This probably works well for user interfaces, but for games, it would be really nice to be able to mix: 1. global rules, such as physics, that are best computed by considering the whole world at once, and 2. local rules, specially defining actions for certain types of objects in the world. The challenge is to find a way to mix these two ways of defining how objects act, in a way that is nice to work with in a functional language.

The challenge proceeds in stages:

1. First implement a global rule for objects, let's say circles, in the world, using the Barnes-Hut gravity simulation algorithm. The only purpose in this stage is to get some objects orbiting around each other.

2. Now get individual objects to react to the global algorithm. Have each circle change color based on the acceleration/velocity/change in either.

3. Allow this reaction to be customized, some circles turn blue, some circles turn red ...etc.

4. Get individual objects to react to each other. Add a simple collision response, it could also just be a color change, does not need to consider physics.

5. Allow this collision response reaction to be customized.

6. Add flocking behavior to objects, now objects are aware of their environment.

7. Allow the flocking behavior to be customized.

This is a design challenge rather than a strict programming challenge, I know that this can be done, but what are some nice abstractions that would suit this problem? Would they generalize to other situations, if I changed out the physics engine for a user interface layout algorithm?

I would like to know where the likely problems would be in implementing these challenge stages in various frameworks, what things I could read that would help me solve it myself, or suggestions in changing the challenge itself.

No comments:

Post a Comment