Jump to content
  • Advertisement
Sign in to follow this  
clapton

AngelScript performance

This topic is 4736 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! Firstly, I'd like to say that I haven't used AngelScript before. Simply, after having a look at its syntax and features I really loved it. That's why I've decided to use it in a project I am currently working on. In theory, in the game a scripting system would be responsible for AI. For each unit on the map (it's an rts game, say 1000 objects on the map) a script would be executed to translate commands into some particular actions. The question arises - is the AngelScript fast enough to satisfy requirements of a such game? If not, what other scripting languages should I consider? :) Thanks in advance! :)

Share this post


Link to post
Share on other sites
Advertisement
Don't use a scripting language to execute logic every frame. At most I would only use a scripting language for the option to do script callbacks to game events. Doing logic every frame, especially for 1000 game objects would suck performance-wise.

Share this post


Link to post
Share on other sites
It's important to note that though, yes, it would probably be slow, AngelScript is most likely the fastest solution if you really insist on scripting.

Given your problem, though, it may be more appropriate to reserve the scripting language for more macro events, like missions goals and such. In most RTS games, the units don't really do much besides walk and attack. Unless you are really going to use the functionality, don't script the units. Aslo be very wary of doing complex calculations in scripts. Specifically, if you find yourself looking for the nearest enemy unit a lot, make that function native code!

Share this post


Link to post
Share on other sites
I cannot tell you if AngelScript will be fast enough for you to control 1000 units with calls to all the objects each frame, as I have nothing to base that fact on. Luckily, you really don't need that much scripted calls as most of the time the units won't need the scripts to know what to do.

The scripts should only be called to let the units react to events, for example what should the unit do if hit by a bullet? Should it attack the one who fired it, or should it run away? In either case the script simply sets the state of the unit.

Some units need more thinking power, in which case it is appropriate to send them timed events, for example an event every 200ms, but most units will probably receive at most one event per second, if that.

I believe that if you design your game engine with the above thoughts in mind you can definitely use scripting to do it. I also believe that AngelScript is fast enough to satisfy your requirements.

I won't tell you that AngelScript is the fastest scripting library around, as I don't think it is, however I doubt that AngelScript is much slower than any other that performance outweighs the ease of use.

I also intend to rewrite the AngelScript VM to a register based VM instead of a stack based one, and based on the experience the Lua team had with this change, there is potential for almost doubling the performance.

I look forward to hearing your experiences with AngelScript, and to see what you will do with it. Let me know if you find that there is anything that can be improved.

Regards,
Andreas

Share this post


Link to post
Share on other sites
It's about 2-3x slower over c++ code and gets slower the longer higher freq. code gets. Time it yourself to be sure.

Share this post


Link to post
Share on other sites
Hey guys! Great thanks for your help! :)

I'll keep in mind all you've said. Every hint is very important. To make things clear, I don't intend to execute scripts every frame for each unit. What I'd like to do, though, is to call the script when a player gives a command to an object. Then, a particular script translates it to a list of actions that need to be taken in order to do the command. And that's all. :)

Obviously, the most time-consuming algorithms will be natively coded. Good thought, Deyja!

All the units would probably need to react on what's going around. Sending an 'update event' to each unit after some specified time is definately a great idea, WitchLord!

Sure I'll let you know how does it work in practice. :)

See ya'

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!