The cat is trying to touch the grasshopper. The point of this project is to make an algorithm for a computer controlled sprite to make its way through a landscape with barriers. It's not very smart. Scratch moves toward the grasshopper. If he touches a barrier he bounces off at a semi-random angle. To keep him from walking right back into the barrier, he runs away from the grasshopper for a certain amount of time. The amount of time he's in "avoid" mode depends on how many times he bounces off a wall while in avoid mode. This way he doesn't waste a lot of time if he keeps bouncing around between barriers. It's very heuristic. I couldn't think of a reasonable way to try to walk around barriers, since you can't find out the angle of the barrier. Well, you could make the barrier from a bunch of segment sprites and have each one know its angle, but that's not very flexible. I'm interested in your comments and any other algorithms to do this same thing.
Comments
You need to be logged in to post comments
Add a Comment