In a ToW game where you have an AI controlling each unit, is it more efficient to have a sperate thread running on each unit to check for variaous things, or to have a periodic function that will pick each unit in a unit group? (The unit group being the entire map)
In other words, is picking a large amount of units and having 153 threads created at once more efficient than having 153 idle threads on the wait action? The timing would be the same for both of them.
Picking each unit in a unit group does not start a new thread for each unit, if you don't specifically set it up that way.
The most efficient way, however, depends on the actual application. What exactly needs to be done for the units? Maybe there are even other alternatives?
Well the AI is fairly complex. There are a couple of generic AI features, such as the shuffle move. (Attack, move back, attack, move back) There are also specific AI features, such as healing (applies to medic, medivac, queen, etc). There are also unit specific AI features, such as Blink and Siege.
But that doesn't really matter. Unless there is a huge, huge performance cost of having a thread running on each unit, that is much preferred. (There would need to be TONS more triggers if not, and threads would be executed constantly. (Probably every .001 or so, depending)
As long as you make sure, that your algorithm for the next order to issue is efficient, issuing the actual order shouldn't be a problem. Running a huge amount of threads shouldn't be a problem, I think, but iirc there was a hardcoded thread limit; you might want to explore that or look it up to avoid surprises. However, looping through the units should not make much of a difference.
BTW the lowest interval SC2 can handle is 0.0625 (technically 0.03125, but I wasn't able to find any practical difference, because most relevant stuff is updated only every 2 ticks anyway).
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey guys, just I quick performance question.
In a ToW game where you have an AI controlling each unit, is it more efficient to have a sperate thread running on each unit to check for variaous things, or to have a periodic function that will pick each unit in a unit group? (The unit group being the entire map)
In other words, is picking a large amount of units and having 153 threads created at once more efficient than having 153 idle threads on the wait action? The timing would be the same for both of them.
Great to be back and part of the community again!
Picking each unit in a unit group does not start a new thread for each unit, if you don't specifically set it up that way.
The most efficient way, however, depends on the actual application. What exactly needs to be done for the units? Maybe there are even other alternatives?
@Kueken531: Go
Well the AI is fairly complex. There are a couple of generic AI features, such as the shuffle move. (Attack, move back, attack, move back) There are also specific AI features, such as healing (applies to medic, medivac, queen, etc). There are also unit specific AI features, such as Blink and Siege.
But that doesn't really matter. Unless there is a huge, huge performance cost of having a thread running on each unit, that is much preferred. (There would need to be TONS more triggers if not, and threads would be executed constantly. (Probably every .001 or so, depending)
Great to be back and part of the community again!
As long as you make sure, that your algorithm for the next order to issue is efficient, issuing the actual order shouldn't be a problem. Running a huge amount of threads shouldn't be a problem, I think, but iirc there was a hardcoded thread limit; you might want to explore that or look it up to avoid surprises. However, looping through the units should not make much of a difference.
BTW the lowest interval SC2 can handle is 0.0625 (technically 0.03125, but I wasn't able to find any practical difference, because most relevant stuff is updated only every 2 ticks anyway).