- Seek
- Arrive
- Pursuit
- Wander
- Evade
- Flee
- Cohesion
- Separation
- Alignment
And the triangles(agents) can avoid walls (Wall Avoidance Behavior)!
Its been some intense debugging sessions to get couple of them to work especially the first one Seek! Guess what? It was a case of "For want of white space character"! Because there was one extra white space character in my plist file, I could not get the cumulative steering force to calculate. You really cannot see an extra white space when you are viewing through the Xcode plist editor! I had to open the plist file in a text editor and find it!
Once the first behavior fell in place, other easy ones fell in place faster.
One quirky issue with Wall Avoidance behavior was the fact that there was a need to do pointer passing into a function. With objective-C it becomes pointer to pointer!
Anyway, I guess when I post the code you will get to see. Maybe I will post a beta version once I get Obstacle Avoidance also to work.
Another point of note was as the number of agents increased on an iTouch (3rd generation) the frame rates dropped considerably. So I am not sure if its because of the device horse power, the rate of math calculations, or the fact that Core Graphics cannot keep up and you have to move to OpenGL. Maybe its just my code! We will just have to see I guess!
Really looking forward to seeing this code, I think this is the basic fundamentals of getting a great game happening. Tease us with some Beta code please :.)
ReplyDeleteOne thing I have noticed in my messing around with Cocos2d, and increasing the number of agents, is that any log messages I print to terminal for debugging, seem to really decrease the frame rate. As soon as I remove the log messages from the commonly hit methods, the frame rate shoots back up to 60. Not sure if this is the case for you but worth a try.
@Ross MillanHi Ross, I will post a beta version of the port once I get obstacle avoidance working. I think its possibly my implementation of the view redraw which is possibly slowing things down. Right now to get a smooth agent flow in the Big Shoal, 25-35 agents is the number. Well for now it works, improvements/tweaking can be worked out when I actually am making a game out of this code! Also remember Cocos2D is based on OpenGL and right now I am implementing all the drawing/rendering code in CoreGraphics not OpenGL. Maybe sometime later I can see if OpenGL makes a difference!
ReplyDelete