03-05-2013, 03:18 PM
(03-04-2013, 10:32 PM)xoft Wrote: When I was considering this, I came to the conslusion that the "state" would be best described at two levels of granularity. On the higher level, the mob would know "I'm chasing this player". On the lower level, the mob would remember "I'm running to XYZ". So that the lower level would be implemented in the cMonster class, it would be the "executive". Then, each time the lower level was finished (or even a few times while it's executing) or something unexpected has happenned, the particular mob class would react in the higher level logic.
That's a great idea. The lower level would be the action that the mob is executing while the higher level is the state of the AI. Looking at the code, it seems that the higher level (let's call it the state) is somewhat implemented. I'll look into adding the lower level (the action) added.
(03-04-2013, 10:32 PM)xoft Wrote: But what you'll probably need to start with is a decent pathfinding algorithm. I don't think there's any currently implemented, and it will be needed very much. It would need to be able to accomodate different mob sizes and different mob capabilities (spiders climbing walls, villagers opening doors). I'd suggest implementing this class to use the cBlockArea class, that way it will be easy enough to use and will be even exportable to Lua.
Yeah, we need a pathfinding algorithm. I am looking at implementing the A* algorithm.
(03-04-2013, 10:32 PM)xoft Wrote: As for implementing the mob AI in Lua, I'd strongly advise against it, at least in the early stage. To implement a reasonable AI, you need access to a lot of stuff, quite a lot of which is not yet exported into the Lua interface. Usually that is because exporting it is non-trivial. You'll also be facing a lot of threading issues that are really difficult to solve for Lua interface.
I'd suggest implementing the base AI in C++, but keeping extensibility in mind, so that later we can export a few hooks at key points so that Lua plugins can tweak the AI, maybe even replace it altogether (if anyone's brave enough )
That makes sense. At least for now, we can have everything in C++, and then we can look into migrating the state portion of the AI to lua