|
Development Forum |
 |
| 
Geek2Nurse
 

|
5/24/2012 | |
How do you decide when to use INST? I'm sure it makes things more resource-intensive, but I don't have a clear sense of what sorts of events really need to be protected from potential interruptions and which ones don't matter.
---
Optimist: the glass is half full.
Pessimist: the glass is half empty.
Engineer: the glass is twice as big as it needs to be. |

Moe
  

|
5/24/2012 | |
I actually plan to make a detailed blog post about this at some point, but the general rule of thumb is: if it doesn't matter if it's interrupted, or it doesn't need to be done instantly, it doesn't need INST.
Agents that change their permeability, target and interact with other agents, or have long, complex functions that are imperative to it's successful functioning, shouldn't be interrupted, and therefore, should be INST'd.
If I have a fish that targets a nearby seed, gets it's position (in order to move closer to the seed) and eats it via mesg writ targ, I might need INST. If another fish eats it first, if I try to get it's posx or posy, it'll crash because the target is null, and also if I try to mesg writ targ I'll get an error because the targ is null. This would be a good place to use INST.
Get everything you need from the agent (positions, etc), check if it still exists and if it's close enough to eat, and eat it, all in one tick so the target can't vanish on you.
Now in actuality there's something called an Exception Script.
X X XXXX 255
This catches errors from null targs and allows the agent to take alternative action without throwing an error, so in reality, I don't really need to INST the example fish, because I can just stop the script with the Exception script if the target vanishes, but the example of the fish is a good one none-the less.
And the Exception script only works on stopping NULL targets. So if you need to have a script not divide two variables if the denominator variable equals 0 (and thus divide by 0 and kaboom the engine), the Exception Script won't save you if the variable suddenly becomes 0 between checking it's value and performing the division. You need INST.
Hope that helps. |

Geek2Nurse
 

|
5/24/2012 | |
Yes, that helps a lot. I'll look forward to your blog post, too. Thanks!
---
Optimist: the glass is half full.
Pessimist: the glass is half empty.
Engineer: the glass is twice as big as it needs to be. |
|