Need help with a 'scan' pathfinding algorithm
Hi there,
the first thing I should say; I'm not creating this project in Flash, but in Java. (This also explains my absence lately ;)). I had tried to code it in Flash, but it simply couldn't handle it because of speed-issues. However, I do like all the feedback most people give me here, so that why I'd rather post here.
I'll first explain a bit about the project:
I'm re-creating a game called Kurve. Me and my mates have been playing quite some times lately, and realy enjoyed it. However, the game doesn't have much variety nor doesn't it allow any custom settings. Therefor I decided to remake the game with some nice addons.
The game itself is an offline multiplayer game. Up to 6 people on one keyboard can play the game and each get 2 keys. One to steer left, and one to steer right. Each player controll's a snake (which grows in size each step). The objective is to survive as long as possible. You'll die when you either hit a wall, or another snake.
One of the things I wanted to add, is AI. A computer controlled snake, which won't be very smart, but still tries to avoid wall's or snakes. This is where I need help right away :)
I reckon that this AI would mostly concist of a pathfinding algorithm, which will scan the road ahead, and then pick a new direction. But I'd have no clue on how to this, decently. I was hoping someone could give me any tips on how to achieve this, or other idea's to solve this.
What should not be forgotten, is that each snake has a 'rotation' speed, so it can't just change direction whenever it wants to. It take some time to rotate to a desired direction.
Also, something that would be realy great; in the original game (and in mine) every x-steps a hole is created in the snake, where other snakes can pass through (this is to prevent the screen from filling up too soon). It would be neat if the AI would also use these holes, but not neccesary. The AI can be as dumb as it has to be, as long you can still see it atleast tries to do something.
This is the important data or fields I'm using:
- Passable pixels (either a hole in a snake or just normal ground) are stored in a 800x600 boolean array. This should also be used for pathfinding.
- Each snake has a movement speed, thickness and rotation speed.
I hope I've been clear enough and that someone can help me.
Best regards,
~Sph