Monday, September 5, 2011

AI hitch?

Alright so splitting up all the AI/COM common code into its own class was successful. Very much so. However I have been spending a little bit of time on a little problem. "Reaction time". It is a harder problem than it first seems. I tried twice, and ended up with two side-effects (which I kept there in case we do find a use for them): observation latency emulation, and controller latency simulation. Neither of which is functionally equivalent to reaction time. Why? Reaction time is non-symmetric. Let me illustrate...

Imagine you are a racing car waiting for the green light. Reaction time affects how long after the green light you actually start moving. However, it does not affect how long after the finish line you hit the brakes! It only affects the initial event. Now the reason this is tricky is movement events are generated once per frame. If I just keep them in a buffer (queue) with an x second delay, we get the effect of the guy walking and continuing to walk even past his goal (controller latency.) If instead I keep the world states in a buffer (queue) with an x second delay, we end up with a similar situation, except that he doesn't "see" anything that happens until x seconds later, and he doesn't realise he has gotten to his destination, so he again, overshoots.

Now what is the solution? Buffering events for a certain amount of time would most definitely be the way to delay things. But what do we buffer? That is the question I am trying to answer now. One potential solution is to buffer the worldstate for everything except myself (i.e. my fighter's state.) That has the effect of creating a worldstate which has me in the present, and everything else x seconds (or frames, which may work better for practical purposes) in the past. That is an inconsistent worldview, but is that a problem? I mean we are trying to introduce imperfection!

The question remains whether such a worldview is logically equivalent to reaction time. After writing up all this, which has made me think about it more (different cases and what side-effects this kind of buffer would cause for the AI,) it seems like what we want.

Maybe I'm thinking too much into the reaction time parameter. Perhaps for more human-like AI behaviour I should start coding in some of the subtleties in a fighting strategy algorithm such as standing ground, etc.

More from me later!

No comments:

Post a Comment