I came across a great resource for AI programming today.
aigamedev.com
It's got some pretty good articles. Particularly one that caught my eye was this one that was posted a couple weeks ago, in a similar vein to an A* algorithm, called theta*. It's about line of sight pathfinding, and looks very cool! Worth checking out.
Also, last night I was talking with some friends about my next project that's been tossing around in my head for a couple of years. I'm reminded of this today because I found that article while looking at behavior trees. For my next game, I'm considering using state machines instead of behavoir trees. But state machines laid out likebehavior trees. I think, if I understand both kinds of things. Let me see if I can describe what I'm thinking for my next project.
Generally for people how they make decisions is that they have desires. Desires lead to thoughts, and then thoughts lead to action. So I'd like to try an AI system that will work this way. It will be a fun experiment!
With my experiment, an AI NPC will have desires or motivations. I'm thinking to start physical, emotional, social, profession, and hobby. These would be prioritized based on their overall values. i.e. if the NPC is in love they may have emotional at the top of their list, causing them to skip a meal to be with the object of their desire. (you can love things or actions as well as people!) Emotional is greater than physical in this case. I have this system pictured in my head like a 5 pointed star, each point on the edges of a circle, and the middle representing primary motivation of the NPC. Depending on the "weight" of the different points, the NPC's behavior would reflect their motivations accordingly.
I am also planning on giving the AI goals to represent actions -- different behavior patterns that can be displayed. Likely the goals would also have a weight to them. i.e. sleep would be low on the motivation list, but after 2 days of no sleep it would jump up to the highest priority goal of the NPC. Having weights for goals, as well as short or long term goals, will help give the AI lifelike abilities.
So motivations help the AI pick goals, and goals help decide action, which leads us to overall behaviors.
The player would totally be in the dark even if this were a perfect system though. So we will need a feedback system. Probably some graph bars or maybe a mood ring kind of system (I'm somewhat against hard numbers in cases like this, always have been, not sure why...). In addition to that, it would be good to have primary and secondary motivations that have a thought bubble (i.e. "I'm sooo hungry!") or possibly an icon/image representing what their current goal is, and possibly a secondary or sub-goal that they might be thinking about.
So sounds great in theory, much harder to code for. And of course there are always complexities when simulating life. i.e. I'm kind of grumpy when I am hungry. Should I take things like comfort/discomfort and overall happiness into account? Lots of other things could also factor into this like "gut feeling" AI types vs "rational" ones, extrovert vs introverts, pessimistic vs optimistic, etc. I probably won't do all of that the first go around. =) Not to mention scalability of this kind of system.
If I can get this right, then the initial decisions can stay relatively static, while actions (or rather goals) can be added dynamically to the game easily and allow for more and more flexibility, and build a game around it. I have a slushy goal of getting something going by the end of the year, after JSTileMap is out and being used. Wish me luck!