Game Development Community

Is lots of schedules running at once a problem?

by Philip Mansfield · in Torque Game Builder · 01/08/2006 (2:05 pm) · 5 replies

In my game I have 40 enemies on screen at the start. I want them all to fire at the player using a schedule to control the timing. A counter will be used to limit the number of bullets on screen at once.

At the moment I'm just using a single schedule so it looks the enemies are all taking turns at shooting rather than just deciding to do it on their own.

My thoughts are to use a schedule for each enemy, and then if the number of enemy bullets on screen is less than the max number allowed, the enemy can fire.

A quick search for running multiple schedules turned up an AI bot resource for TGE in which it was mentioned that schedule is lightweight, and running a couple of hundred at them at once wouldn't really impact performance. Although I don't want to run that many, being able to run upto 100 (2 per enemy, plus a few for other game related things) would make my game much more interesting.

I don't want to go through the pain of coding in a load of schedule events and then have to rip them out if my system falls on its knees. If anyone has tinkered with running loads of schedules at once, I'd be interested to hear about the results.

#1
01/08/2006 (2:09 pm)
It's not the schedules that would hurt performance so much as happens in the callback/script that gets actioned when the schedule is triggered.

The best way to test the performance characteristics is to simply get the stock T2D SDK and setup a simple test-script that creates hundreds of them all staggered in time. Try to keep a specific number running at all times but make the function they call bare apart from a reschedule.

This would be a good prototype to run on the lower-end spec you expect to run at.

- Melv.
#2
01/08/2006 (2:36 pm)
Quote:It's not the schedules that would hurt performance
That sounds promising, so on the face of it, the idea is a goer.
Quote:so much as happens in the callback/script that gets actioned when the schedule is triggered.
Yeah, I figured that. When each one triggers it will check to see if the max number of enemy bullets are already on screen, and if not, call the function to fire one. It will then reschedule itself. So it's only going to be doing a relatively small amount of work.

Looks like I'm really going to have to get hold of a low spec machine for testing. What's the wife going to say when I turn with yet *another* PC?? :)
#3
01/09/2006 (12:14 am)
Wives pretend they don't like miscellaneous electronic junk and computers around the house but they secretly do really. In-fact, the more the better. Or at least, that's what the devil on my shoulder keeps telling me. ;)

- Melv.
#4
01/10/2006 (11:06 am)
Little theory behind schedules:

All a schedule does is to post an Event to occur at a future simulation time...there is no per tick/frame overhead or anything for each of the scheduled events, other than checking the event queue itself to see if any have matured.
#5
01/10/2006 (12:18 pm)
That's good to hear :) I shall have a bash at adding schedules to each of my enemies and see how I get on.