'Thinking' AI

For questions about using Classic.

Post » Fri May 27, 2011 7:26 am

Hey, im making a kind of 'wildlife' game thats topdown and u watch the creatures do there thing. Im currently have them set to a bullet behaviour like in the ghost shooter tutorial. I wont them to have a kind of 'chance' code were they might keep going or they might decide to stop and sleep, so far ive got a eat thing going on with the Line of Sight behaviour but thats about as real as they get.

Any suggestions, thanks.
B
1
G
1
Posts: 2
Reputation: 429

Post » Fri May 27, 2011 7:46 am

i think you should use the RST behavior instead of the bullet one and for the chance code you can use the random command and you should also create function witch is going to tell the behavior of your A.I. and use random time interval to make them do something

like;

pick a random "creature"
if not "sleeping"
if not "eating"
every random(10000)+5000 set the private variable of it to random(3)
then
if 0 then call function "sleep"
if 1 then call function "go"
if 2 then call function "eat"

and create your function like

sleep;
wait 20 000 ms
then call the function "go"

eat;
move toward food.x.y
wait 5000 ms
than call "go"

go;
move toward random(640) random(480) "if your layer is 640,480)


something along those line ...
B
3
S
2
G
2
Posts: 136
Reputation: 1,347

Post » Fri May 27, 2011 11:56 am

[quote="thoughtzone":3k6zl90s]i think you should use the RST behavior instead of the bullet one and for the chance code you can use the random command and you should also create function witch is going to tell the behavior of your A.I. and use random time interval to make them do something

like;

pick a random "creature"
if not "sleeping"
if not "eating"
every random(10000)+5000 set the private variable of it to random(3)
then
if 0 then call function "sleep"
if 1 then call function "go"
if 2 then call function "eat"

and create your function like

sleep;
wait 20 000 ms
then call the function "go"

eat;
move toward food.x.y
wait 5000 ms
than call "go"

go;
move toward random(640) random(480) "if your layer is 640,480)


something along those line ...[/quote:3k6zl90s]


Thanks that worked fine, took awhile to adapt to my existing LoS detection and hunger variable but its worked out just fine,

Thanks a lot. :D
B
1
G
1
Posts: 2
Reputation: 429

Post » Fri May 27, 2011 7:13 pm

I have also been working on something very similar-- a sort of virtual terrarium-- yes? I personally have just been using custom movement behavior and creating boxes that I can set to invisible of varying sizes that are always set to the x and y of each creature to mimic line of sight-- I find it more useful for actually seeing at what point a creature will flea or attack--

To actually get it to seem like the creatures are "thinking" I recommend using private variables-- hundreds if you need to-- variables for how hungry they are, how much energy they have before they need to sleep, how safe they feel-- just for everything, and then make them behave based on what that variable is!
B
5
S
1
G
2
Posts: 99
Reputation: 1,575


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests