Help with snake

Get help using Construct 2

Post » Thu May 29, 2014 7:57 am

Hey guys,

Iv'e been trying to make a snake ai with C2. I saw that gif where the snake ate all the food and ended up filling the whole screen with itself and thought of replicating it.

I'm having trouble trying to make the snake avoid running into it's own tail.
I can avoid this if the snake is directly facing a tail segment with the help of line of sight behavior but not when the snake is right next to its own tail not facing it's tail segment.

I have conditions where 'if food.X greater than snake.X => move right' and so on for all directions for the snake to move automatically. The tail is a square segment which is spawned when 1 food is eaten

(Take example where the snake is moving up/down and has to move right to get it's food)
The problem is avoiding the snake from moving right if it has a part of it's tail to it's immediate right, and only move if it's clear.

If i put a condition 'check if tail is snake.X+10' , the system checks for all the tail parts and even if one tail part is not snake.X+10 the condition lets the snake move even if another tail is snake.X+10.

Using picked instances makes the snake not move at all for some reason, i think it's cause if no tail meets the picked condition the condition to make the snake move is not met.

Can anyone help?

Thanks
B
17
S
5
Posts: 144
Reputation: 1,591

Post » Thu May 29, 2014 9:29 am

here is demo made by mlb
You do not have the required permissions to view the files attached to this post.
B
257
S
42
G
15
Posts: 1,992
Reputation: 41,435

Post » Thu May 29, 2014 10:47 am

@Lordshiva1948

Thanks , but i can't open it as i've got r168 stable . is there a way to open it in older versions of C2?
B
17
S
5
Posts: 144
Reputation: 1,591

Post » Thu May 29, 2014 2:19 pm

@Lordshiva1948

That demo is just a button that directs you to the newyorktimes website when clicked. I'm not sure if your trolling or uploaded the wrong capx
B
17
S
5
Posts: 144
Reputation: 1,591

Post » Thu May 29, 2014 2:31 pm

If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,554
Reputation: 60,452

Post » Thu May 29, 2014 2:49 pm

@zenox98

Thanks , i have come across your tutorial before and used similar techniques to save the positions of the snake. But i'm trying to make a snake artificial intelligence rather than a user controlled one. Thanks anyways.
B
17
S
5
Posts: 144
Reputation: 1,591


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests