Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → SendMessage(), SendTrigger(): Best way to send the array from one cog to another cog?
SendMessage(), SendTrigger(): Best way to send the array from one cog to another cog?
2005-01-13, 6:56 AM #1
This is for synced AI. One cog that handles pathfinding for all AIs needs to be able to communicate its results to the AI's capture cog.

I need to send an entire array of things from one cog to another. The communication need only take place on the server so syncing/network usage is not an issue here. The array is of an undetermined size. In fact, it will probably need to be contained in a heap because it could very easily grow past a hundred.

All I can think of, is breaking it up into chunks and sending it 3 or 4 pieces at a time using SendMessageEx or SendTrigger. I guess I could just have a for loop run sendmessage however many times is needed to get it all over there and have the second cog dump it into its own heap.

Would there be any advantage to not sending the chunks all at the same time? The other cog will not need all of the information immediately. I could stagger them with timers. (Is there a limit on the number of active timers that a cog can have? If there is that would definately cause problems.)
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2005-01-13, 6:59 PM #2
Send it through a pulse instead. Or maybe a loop with sleeps.

Of course, I don't know a lot of the specifics of what you're doing, so those might not be options.
May the mass times acceleration be with you.
2005-01-14, 6:45 AM #3
I'm not really sure those are options. Its entirely possible that 10 AIs, or 100 AIs may all sequester this cog for the path all at once. The pulse would only allow me to convey a limited number of paths at a time. And sleeps...well you know what happens when you have a message with sleeps in it that gets called over and over again...

Absolute max nodes that would probably ever get sent would be 500 (very unlikely occurance) which would work out to like 150-160 sendmessages.

Its more likely use would be sending several blocks of 10-30 nodes (10 messages or so) often at the same time to different AIs.

The only way I can think of doing this is either just brute force running a loop that sends them all at once. Or using timers to stagger it, since you can pass params into the timer and in the mean time just dump the total results in anticpation of the next request.

But again, if there's a max number of timers that I've never encountered, this cog will probably find that max. :D
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2005-01-14, 10:18 AM #4
Just have a user message in the cog with your array, then when you want to grab something from that array, send the message, and ReturnEx(Array0[GetParam(0)]);, param 0 being the index you want.

Make sense?

Oh, and I think the thread limit in a cog (5?) would apply for your timer message question. :)
-Hell Raiser

↑ Up to the top!