Advertisement

how do you setup your ai functions to objects?

Started by March 02, 2004 08:40 PM
3 comments, last by keethrus 20 years, 11 months ago
im currently developing a game, and ive gotten to a point where i have to make some decisions on the a.i. part. right now how i have it is a list of objects each with variables like position, bounding circle (for collision testing), velocity, etc. and also a pointer to an avatar (basically polygons representing the object) and i was thinking of having a pointer to a function that handled that objects ai. but i was wondering how everybody else did it. this way i could just have a large list of objects to use for anything in the game, a list of possible usuable avatars for the objects, and a list of functions that handled individual character ai. the physics code and the ai code and the drawing code would just have to go through the list of objects. so if in my game i needed to create another object called "killer frog monster", i would find a object in the list of objects i could use; set its initial position, velocity, etc; point its avatar pointer to the "killer frog monster" image; and point its ai pointer to the "killer frog monster FSM" function; any ideas? how does everybody else do it? - Jeremiah inlovewithGod.com
That works if your AI is stateless -- what if your frog AI has a jump frequency it needs to store?

I would consider having your AI ''manage'' the model (visual representation, sound, etc). This way, your AI can do whatever it wants with the interface the model provides. One way to do this would be to make your AI classes a separate class hierarchy.

(Now, this does not mean that everything should be in the hierarchy. Keep using those data driven methodologies, even if you go with this system.)
Advertisement
could you elaborate more on how the ai manages the model? im not sure i fully understand.

- Jeremiah

inlovewithGod.com

[edited by - keethrus on March 2, 2004 9:52:55 PM]
Consider that your AI says that your killer frog should hop across the room and beat up the wimpy worm. How do you change the state of the avatar animation to reflect the change from ''perched'' to ''hopping'' and from ''hopping'' to ''hitting''? By providing an interface to the model of the frog (and it''s visual representation) you permit your AI to determine how the frog is seen by the player. If you don''t do this, then you need to find a way of synchronising state changes in animation of an avatar with internal state changes in the avatars agent... and that''s not trivial.

Timkin
great idea. now anybody have any low-level examples of how they set all this up?

im imagining an avatar that lists the complex-object and its sublist of objects (like complex-object = person, sublist = head, body, armL, armR, legL, legR). and you''d only need one of these in memory for each human.

then you''d have another list that held all the information for specific instances of the object (held angles and positions, etc) you would need one of these per object in your game.

then you would have some sort of functions per type-of-object that would do things like animate it running, animate it dying, etc. they would also create new objects (in the case of "shoot rocket") and apply forces (so when it''s "walking" its not only animating the walk, but applying a constant force forward)

your ai would then do its ai thing, and call the appropriate functions depending on which state it was in and what it wanted to do.

is this ok? anybody do it better? how does everybody else do it?

- jeremiah

inlovewithGod.com

This topic is closed to new replies.

Advertisement