snake seek & avoidance try
I've been working on a very basic snake ai (seek & avoid) and I'd like to hear what you think. It's intentional limitations are a fixed movement and rotation speed. You can place obstacles by clicking and holding. It's 3point vision is visualised, but note that each circle only checks the center pixel and not it's entire radius.
Try it here. You can use the browser window to scale.
The most obvious problems,
It's got a jitter in it's avoidance steering and it's got a little unintentional bug that makes him slither up and down (I left it for now, because snakes slither afterall). It's because I'm comparing rotation angles instead of vectors because I'm having problems with the vector math. Also it's front probe is entirely dumb (always steers in same direction) it doesn't steer to shortest distance because for the snakes body that wouldn't work and otherwise it seems to avoid the circles well enough (without the xtra code/cost).
Beside those, I'd really like some suggestions on how to improve it's overall performance.
Could you give more details?
All that I am about to say is just speculations, more details could be useful to try and help.
"It's because I'm comparing rotation angles instead of vectors because I'm having problems with the vector math."
This might be the key.
Also I am not completely sure that having it turning in the same direction (perhaps you mean always clockwise or anticlockwise?) is good for avoiding its body.
So, about avoid the snake's body, you could let the sensors detect the snake body and have the snake being pushed a little away from it.
Also do you steer the agent by assigning it a velocity or do you use force and acceleration?
All that I am about to say is just speculations, more details could be useful to try and help.
"It's because I'm comparing rotation angles instead of vectors because I'm having problems with the vector math."
This might be the key.
Also I am not completely sure that having it turning in the same direction (perhaps you mean always clockwise or anticlockwise?) is good for avoiding its body.
So, about avoid the snake's body, you could let the sensors detect the snake body and have the snake being pushed a little away from it.
Also do you steer the agent by assigning it a velocity or do you use force and acceleration?
Quote: Original post by Thunder0ne
"It's because I'm comparing rotation angles instead of vectors because I'm having problems with the vector math."
This might be the key.
Yes, I ran into the problem of comparing rotation angles before (with the wrapping point) and I know formulating the problem in terms of vectors is the solution, however I didn't manage to get my head around it. I had a previous thread with a similar problem which I gave up on for a while and it was locked unfortunatly. I dropped out around the 'perp dot' operation as I wasn't really sure what I was doing anymore.
A problem I frequently run into when looking for math formulas on the web is I don't know how to read many formal notations (symbolic notation). It appears I never had any adequate math classes.
Quote: Original post by Thunder0ne
So, about avoid the snake's body, you could let the sensors detect the snake body and have the snake being pushed a little away from it.
Also do you steer the agent by assigning it a velocity or do you use force and acceleration?
I'm not sure I understand the technical defenitions that well, doesn't force change acceleration and acceleration in turn changes velocity? That is my limmited understanding. I think I'm using force and velocity, details below.
My snake is an array of points (to draw the line for it's body), I remove the last (point) element and place it as the front (point) element at every frame based on the snake.angle to make it move. The speed (velocity?) is determined by a step value (the distance between the points), but I have it as a constant for now to keep collision accuracy reliable.
If the left sensor collides I steer right, vice versa for the right sensor, and if the front probe collides I always steer left (for now). Rotation speed (force?) is a constant set at 15.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement