Null events are useful when we're using patterns that always generate events, but we don't want one in a particular case. For example, I might have it so that every time a unit is damaged it calls a function damaged() that generates and returns an event. Typically this would be the UNIT_DAMAGED_EVENT, but if say, our unit was on a kamikaze attack, it might make sense to return a NULL_EVENT that didn't do anything. This is just an example, but the point is that we don't need to change the underlying mechanisms by which events are handled -- we have a defined way of producing and handling null events.hoijui wrote: i don't understand what you want with the NULL_EVENT. when would the engine send one of these?
Because if there is AI/AI communication, then I'm assuming it will have to be via the engine, using some sort of Command. The engine would then produce an Event that would be parametrised with the fromID as necessary. In most cases we won't need a fromID, since it's just from the engine, so having this field seems like a useless waste -- of course having AI/AI communication would be great, but I think it won't happen for a long time, and the right way of doing it is through particular Events, not inherently in the handleEvent().hoijui wrote: why do you want to remove the fromId? we said this could be used for AI->AI communication in the future.
Oops, my mistake, I meant it to be:hoijui wrote: why do you want to remove the eventId? we said this could be used for asynchronous communication in the future.
Code: Select all
int handleSEvent(int teamID, int eventID, void* event)
I'm afraid I disagree with AF here : the old C++ interface should be built on top of the new C++ interface. The reason (I think), is that there's a natural transition from the handleSEvent() C struct passing way of doing things to real Event handling C++ mechanisms that handle the cases as appropriate. One way of handling these cases is to provide the old AI interface. It also gives a good case example of how to use the new interface.hoijui wrote: will the old C++ interface be built up directly on the C interface, or use your new C++ interface underneath?
If we were to build the old C++ interface directly, we would be reproducing much of the new interface code, but specialising it. This is more efficient, but we lose a massive advantage of the handleEvent() way of doing things: exception handling and logging.
That's the point: if a new AI uses functions on an old engine, the engine will crash because the function doesn't exist in callback.hoijui wrote: I am still pro functions (things like making a struct for an int ... :/ ).
...
if i understand it right, an new AI will always crash with an old engine, and vise versa not, wether we use functions or events, no?
adding an event(= future extension) is more trivial with functions.
However, if a new AI uses State callbacks (in the style of handleEvent), the old engine won't understand and can send back a NullState. Then the AI can decide if it can carry on without the data it has requested. If it can't it can fail gracefully, otherwise, it might be able to go on but not take into account certain information that's unavailable in the old engine.
The question is whether or not this level of safety is worth the hassle of horrible IntState type structs (yuk, they do look horrible).
The engine is subject to all kinds of change : one day we might decide to make higher dimensional 4d spring. Of course that's a silly example, but what I'm saying is that the engine could change in ways we don't expect, even at a fundamental level. Maybe in future versions we won't be using UnitDef anymore is a more realistic example.hoijui wrote: i dont understand the last point, about internal representation of the engine. as we pass only primitives through the functions, this applies to functions aswell
Will it? I thought it would be passed as a float3 struct.hoijui wrote: (a float3 will be passed as float[3] through the C interface eg, wether we use functions or events).
I like this idea, I thought that's what we were going for from the beginning? We've been talking about how handleSEvent() as a C function feeds almost directly into a framework for the parent CAIObject to use (using handleEvent in the real OOP sense).AF wrote: The CAIObject layer is to be as small as possible and should only concern itself with taking the C API and presenting a simple C++ OO interface which we can build an AI framework with.