• Advertisement
Sign in to follow this  

Simple Steering Behaviours in C++

This topic is 993 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello.

 

I'm trying to create an extremely simple steering library in C++ for 2D games:

 

https://github.com/mitchcurtis/SimpleSteer

 

My motivation is to get a basic, yet useful library out in the open, as there doesn't seem to be any simple steering library out there.

 

I've just started yesterday, and I don't have much yet, but I've got Box2D to handle physics and Qt Quick to get something on-screen for the one example that does exist. smile.png I'm trying to keep the library itself independent of any physics or graphics library.

 

I (and likely many others who find AI a bit daunting) would be extremely grateful to anyone who is interested in collaborating on this project, whether it's hundreds of lines or a one-liner. I don't know how else to get something like this started other than just creating it and seeing what happens...

 

Cheers.

Edited by Mybowlcut

Share this post


Link to post
Share on other sites
Advertisement

To recap the main points I mentioned earlier:

  • C++
  • 2D (I'm not sure if this is really a hard requirement, but I think it would simplify things)
  • Should be flexible enough to work with most physics and graphics libraries

In terms of what it should achieve, I was thinking just basically "move to this position, avoiding obstacles along the way". I think that that in itself is sufficient for most simple 2D games. From that, you can probably implement more complex behaviour - things like hiding behind cover and staying out of an enemy's line of sight can be achieved by combining that behaviour with some ray casts, right?

 

I have ideas about how the API should look, but nothing concrete. An example of usage as it stands at the moment is available in the examples/qml-box2d directory.

Share this post


Link to post
Share on other sites
There are many ways to implement steering. Depending on the features you want to provide and the level of integration you're willing to require on the part of the API user, building a truly separable library can range from a trivial weekend task to a monstrosity.

Just writing a chunk of code and throwing it on GitHub is a great way to garner zero interest from anyone. If you want people to benefit from your library, you need to do a lot of work. You need to plan ahead for what your library will actually provide - something you've been very unclear about thus far. You need to think about the API in excruciating detail. You need to define what you will and will not consider responsibilities of the library. You need to establish a metric for what is considered "too much work" for users to do, and you will need to do that work for them wherever possible.

Experimenting to solidify your plans is fine, but at some point you're going to have to rewrite this from the ground up with your final set of principles in mind.

Most importantly, though, you need to really understand your library's domain and subject material. Just tossing around some simple avoidance routines isn't going to motivate anyone to use your code. Steering is far more sophisticated than just summing a couple of forces when you do it in practice - and most of the complexity changes depending on the kind of application you're using it for. I think my biggest fear for this project is that it seems like you're a bit thin on applied steering experience, which means it's going to be hard for you to produce a solution to problems you don't even know need to be solved.


If I could make a recommendation, it would be to start with a sandbox instead of a library. Whip up some basic 2D environments and implement steering for them. Do side-scrolling as well as top-down. Experiment with gravity. Play with other physics systems besides just steering forces in your sandbox. Come up with as many AI behaviors as you can and try and implement them in a robust way using steering.

From that, you'll have the experience to distill your amassed body of steering knowledge into a library. More importantly, you'll be equipped to answer all the questions I raised above about what that library should be.

Share this post


Link to post
Share on other sites

Yeah, you're right in that I am thin on steering experience. I knew how it would come across just throwing up a skeleton project, but I was quite honest from the start with regards to that. I do not at all feel confident writing this from the ground up, so I'll try to get it working in my game first in whatever hacky way that ends up being, and if it seems like it works well enough to form it into a proper API, I'll do that. After all, my aim for the project was always just to get something that works. Even that is better than what I have now - something that barely functions at all. :p

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement