Tutorial Doctor wrote:zester wrote:Look into "Decision Trees" and "Finite State Machines" both easily done in Lua, and if you havent already done so study up on Coroutine's in lua.
A coroutine is similar to a thread (in the sense of multithreading): a line of execution, with its own stack, its own local variables, and its own instruction pointer; but sharing global variables and mostly anything else with other coroutines. The main difference between threads and coroutines is that, conceptually (or literally, in a multiprocessor machine), a program with threads runs several threads concurrently. Coroutines, on the other hand, are collaborative: A program with coroutines is, at any given time, running only one of its coroutines and this running coroutine only suspends its execution when it explicitly requests to be suspended.
If you need any help let me know.
Whew! ya lost me with that one zester! haha. I am actually a novice programmer, but I love problem solving, and that is why I was even able to make such a large script (for my experience level, I think it is large). I am going to look up what you suggested to see how it works, and to see whether or not I can implement it into my AI system.
Thanks! And I will ask if I need help!
Well a "Decision Trees" is just a tree like so ...
emotion = {["happy"]=happy, [mad]=mad}
function mad(value)
if value == 1 then
--npc is mad and might do something about it
end
if value == 10 then
-- npc is #%^ livid and will try to murder everything in its path
end
end
that makes random choices, you might trigger it by way of a collision even say if another npc collides with this one.
A "Finite State Machines" keeps track of what "State" your npc is in at the moment as an example our above NPC might be in a murderous rage until he kills so many other npcs then its state might change to "Hunger" and the npc goes to the nearest pizza place mind you he is still covered in virtual blood, and has a couple of slices of pizza.
"Coroutines" are like threads what they do is allows multiple action to happen at the same time without the game having to stop and wait for an action to finish. You can just say do this and report back to me when your done. Or in otherword's as an example with the above npc "Kill all of the npc's around you and let me know when your done" - "ok now go eat pizza" - "Now sit outside and wait for the police". But while your geiving instruction to tho one particular npc you can do the same for 500 other npc's, all at the sametime.
And you could possible have some invisible particles that represent sound waves, until there is a collision event with those particles that npc police officer might not know your npc is butchering the local church group.
Last edited by zester (2013-10-02 21:05:16)