Topic: Artificial Intelligence(In Progress)

PunBB bbcode test

Now that I have finished the basics of my Customizable Game Script:

http://forum.maratis3d.com/viewtopic.php?id=744 (See the last post)



I am going to start on an artificial intelligence system:

http://forum.maratis3d.com/viewtopic.php?pid=4521#p4521

I will post the progress here.

A post on gamedev.net

http://www.gamedev.net/topic/651885-pro … -5-senses/

Senses System First Person

Download:
https://sites.google.com/site/maratisfi … System.zip

Senses System 3rd Person:

https://sites.google.com/site/maratisfiles/files/Screenshot%20%28952%29.png

Download:
https://app.box.com/s/b2etg5w53twc4lv4cnmp

Last edited by Tutorial Doctor (2014-04-08 01:06:32)

Re: Artificial Intelligence(In Progress)

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.

Last edited by zester (2013-10-02 18:19:47)

Re: Artificial Intelligence(In Progress)

BTW the image on the first post is so funny.
It's not the "right" way to do it though XD

Last edited by 255 (2013-10-02 18:36:33)

Re: Artificial Intelligence(In Progress)

255 wrote:

BTW the image on the first post is so funny.
It's not the "right" way to do it though XD

hehe.

The cone thing is actually part of a larger physics based AI system (as far as the senses go) that I have thought up.

The cone represents the SIGHT of the object. Anything that collides with the cone is SEEN. Anything that isn't is NOT SEEN. So basically it is a Boolean affair. haha. ON, OFF.

Of course in Maratis it would be invisible and a ghost.

Re: Artificial Intelligence(In Progress)

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!

Re: Artificial Intelligence(In Progress)

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)

Re: Artificial Intelligence(In Progress)

AHHH! Okay! Thanks Zester! That is actually a GREAT idea (Decision trees & coroutines). These are VERY useful!

No wonder people have been missing you here! I am sorta new here, but you have helped me squash some speed bumps I have been trying to figure out! haha.

I move fast, so expect to see a game level in a few days implementing what I have learned from you (perhaps tonight).

Thanks!

Re: Artificial Intelligence(In Progress)

Tutorial Doctor wrote:

AHHH! Okay! Thanks Zester! That is actually a GREAT idea (Decision trees & coroutines). These are VERY useful!

No wonder people have been missing you here! I am sorta new here, but you have helped me squash some speed bumps I have been trying to figure out! haha.

I move fast, so expect to see a game level in a few days implementing what I have learned from you (perhaps tonight).

Thanks!

No problem, that's kinda what I like to do. I spend most of my day figuring out how to do something and then try to stream line it so others can pickup on it easily.

Re: Artificial Intelligence(In Progress)

Okay. I recently posted this idea on gamedev.net, and it seems a few people are interested in seeing how it works. I am going to use Maratis to demonstrate it, so I might need a little help along the way.

I want to give it a little polish though.

Now it's time to work on the senses system...

Re: Artificial Intelligence(In Progress)

This is how my code looks so far:


Player = getObject("Player")
Head = getObject("Head")
eyes = getObject("Eyes")
text = getObject("Text")
text2 = getObject("Text2")
box = getObject("Box")
monkey = getObject("Monkey")
building = getObject("Building")

--SENSES
function See(object)
    if isCollisionBetween(eyes,object) then
        seenObject = getName(object)
        setText(text, "I see a ".. seenObject)
        seeing = true
   -- else setText(text,"I see nothing")
        --seeing = false
    end    
end

function Touch(object)
    if isCollisionBetween(Player,object) then
        touchedObject = getName(object)
        setText(text2, "I feel a ".. touchedObject)
        touching = true
    else setText(text2,"I feel nothing")
        touching = false
    end
end


--ACTIONS
function Jump(object)
    if seeing then
        setGravity({0,0,-4})
        addCentralForce(object,{0,0,9},"local")
    end
end
function onSceneUpdate
    See(box)
    Jump(Player)
    Touch(building)
    See(monkey)
end

Last edited by Tutorial Doctor (2014-03-02 01:57:11)

Re: Artificial Intelligence(In Progress)

I dont know if this could help, but heres: http://www.jblearning.com/Catalog/97815 … 4/student/ the example files from the book Programming Game AI by Example

Re: Artificial Intelligence(In Progress)

Thanks for the link, it my be of use if I decide to expand this out into a full AI system.

We had a big discussion on Gamedev.net about AI, and it seems a lot of people have definitions of AI. The definition I am sticking with is that intelligence is the ability to gather information, or it can be gathered information.

Most of what we know we use our senses to gather. Now, the extra part of intelligence is being able to use that information in meaningful ways. I just came upon a term called

Re: Artificial Intelligence(In Progress)

Okay, I am running into an issue. I am checking a collision between two objects, using the isCollisionBetween() function.

if there is a collision between the two objects, I trigger a sound. I call this under the onSceneUpdate() function and it is trying the sound tries to trigger 60 times per second as long as the collision is happening.

I just want the sound to finish playing first and then stop. I guess I would need a function similar to isAnimationOver() but called isSoundOver().

When I call the it outside of the update function, it doesn't work at all. Any tips? I am using this to let the character speak upon seeing an object.

Re: Artificial Intelligence(In Progress)

I'm currently reading the second edition of "Artificial Intelligence for Games" by Ian Millington and John Funge which I must say is probably one of the best books on the topic of game AI. The authors have a solid background in and understanding of academic AI as well as game and simulation AI and discuss the differences between them.

The book is more or less a catalog of probably every AI technique employed today but also contain a discussion on how and why to choose specific techniques, advice on how not to overcomplicate things (simple AIs can behave remarkably intelligent compared to some more complex ones) with lots of examples from different games. It also discuss all the techniques and their applications in the context of a larger AI framework, basically how they can be combined and communicate in the AI subsystem of a game.

Last edited by Dahnielson (2014-03-02 18:33:14)

Re: Artificial Intelligence(In Progress)

Thanks for the link Dahnielson. I think I can agree with simple AI being more intelligent. This senses system is feeling rather good. It gets the job done, and it can be implemented very easily. It sorta behaves like AI since I am detecting something with a sensor, and having a reaction follow it. From a lecture I saw, that is how she described basic AI.

I can't figure out how to solve this sound issue though. I would like to share the project if I can get a few basic things down.

Last edited by Tutorial Doctor (2014-03-02 18:50:05)

Re: Artificial Intelligence(In Progress)

How about using a bool for the sound.

Re: Artificial Intelligence(In Progress)

Hehe. Right on Akira_san, I thought of the boolean thing, but my first attempt didn't work. I am going to try again. thanks.

Edit: I just can't get it. I even tried the example from this post:
http://forum.maratis3d.com/viewtopic.php?id=61

I will post the code.

Player = getObject("Player")--object
Head = getObject("Head")--object
eyes = getObject("Eyes")--object
box = getObject("Box")--object
monkey = getObject("Monkey")--object
building = getObject("Building")--object

seeBox = getObject("SeeBox")--sound
seeMonkey = getObject("SeeMonkey")--sound
seeBuilding = getObject("SeeBuilding")--sound

collision = 0

--SENSES
function See(object)
    if isCollisionBetween(eyes,object) then
        seenObject = getName(object)
        setText(text, "I see a ".. seenObject)
        seeing = true
    else --setText(text,"I see nothing")
        seeing = false
    end    
end

function Touch(object)
    if isCollisionBetween(Player,object) then
        touchedObject = getName(object)
        setText(text2, "I feel a ".. touchedObject)
        touching = true
    else setText(text2,"I feel nothing")
        touching = false
    end
end

function Speak()
    if isCollisionBetween(eyes,monkey) then
        if collision == 0 then
            playSound(seeMonkey)
        end
        collision = 1
    else 
        collision = 0
    end
    
    if isCollisionBetween(eyes,box) then
        if collision == 0 then
            playSound(seeBox)
        end
        collision = 1
    else 
        collision = 0
    end
    
    if  isCollisionBetween(eyes,building) then
        if collision == 0 then
            playSound(seeBuilding)
        end
        collision = 1
    else 
        collision = 0
    end
end

function onSceneUpdate()
    Touch(building)
    See(box)
    See(monkey)
    See(building)
    Speak()
end

Last edited by Tutorial Doctor (2014-03-03 00:05:21)

Re: Artificial Intelligence(In Progress)

Maybe its a bug.

Re: Artificial Intelligence(In Progress)

Going to try com3D's suggestion from this post:
http://forum.maratis3d.com/viewtopic.php?id=742

Edit: Well, that didn't work, so I scratched all the complexity and made it simple again. I will start from here:

function Speak()
    if isCollisionBetween(eyes,monkey) then
        playSound(seeMonkey)
    end
    
    if isCollisionBetween(eyes,box) then
        playSound(seeBox)
    end
    
    if  isCollisionBetween(eyes,building) then
        playSound(seeBuilding)
    end
end
function onSceneUpdate()
       Speak()

end

Last edited by Tutorial Doctor (2014-03-03 00:41:09)

Re: Artificial Intelligence(In Progress)

Just look where you end your if statement? You close the if statement End, then you add a variable, then an Else statement. and that the wrong part. I hope so.
Heres from the wiki:

Sound0 = getObject("Sound0")
soundplay = 0
function onSceneUpdate()
    if isKeyPressed("SPACE") then
        if soundplay == 0 then playSound(Sound0) end
        soundplay = 1
    else
        soundplay = 0   
    end
end

Re: Artificial Intelligence(In Progress)

function Speak()
    if isCollisionBetween(eyes,box) then
        if soundplay == 0 then
            playSound(seeBox)
        soundplay = 1
        end
    else 
        soundplay = 0
    end
    
    if isCollisionBetween(eyes,monkey) then
        if soundplay == 0 then
            playSound(seeMonkey)
        end
        soundplay = 1
    else
        soundplay = 0
    end

    if  isCollisionBetween(eyes,building) then
        if soundplay == 0 then
            playSound(seeBuilding)
        end
        soundplay = 1
    else
        soundplay = 0
    end
end

That is how I have it set up now, but it is still doing the skipping.
I think the issue might be how I set up the scene. I am going to package the project and post it here.

Re: Artificial Intelligence(In Progress)

Here is the project file:

https://sites.google.com/site/maratisfi … System.zip

Re: Artificial Intelligence(In Progress)

I couldn't fix it.

Re: Artificial Intelligence(In Progress)

Well, thanks anyway Akira_san, very much. I will just continue without the sound. Thanks again.

Re: Artificial Intelligence(In Progress)

Maybe its really a bug?