Liste des Groupes | Revenir à cl c |
fir pisze:now its an error becouse when gorups 1 2 3 could run in parralel group 4 can not (but someteimes when i post something i see an error but not bother to correct as its seen)Lawrence D'Oliveiro pisze:i once said probably call queues should be a god way to do multithreading becouse say you got a routine that calculates and draw a vertical line of mandelbrotOn Wed, 20 Nov 2024 17:34:34 +0100, Janis Papanagnou wrote:i dont know to much on coroutines (what i knew i forgot as even my memory this year is terribly bad) or simule bot from some other
>[*] A friend of mine just recently implemented the code frame for a>
roguelike and followed the suggestion of an event based object-oriented
implementation; it worked well, he told me.
The next step would be to use coroutines so the logic of a longer-running
task, which has to wait for other events at multiple points, can be
written in a single linear stream without having to be fragmented into
multiple callbacks.
>
reasoning i know thet "call queue" is veru good thing
>
possibly it may be better or at least equal in thiat coroutines or
what was in simula
>
in basic call queue it gioes klike this afai
>
for(int i=0; i<all; i++)
add_queue foo(i);
>
foo() are storred in queue so then can be run i pseudo parralel
mode at some point
>
add_queue stores function adress and argument on stack like queue
>
here in rogualike it would use this time variable also
>
DoAction(int i)
{
if(character[i].action_end > current_time) return;
// do nothing until time comes
>
// time has come do something
character[i],action_end += 300;
add_queue DoAction(i); //put yourself on queue
>
>
}
>
StartUp()
{
for(int i=0; i<all; i++) add_queue DoAction(i);
>
}
>
// in some code
run_queue // queue may add soem alelemnts but also executed things are taken out of queue
>
i guess it should be something like that
>
for(int i=0; i<1000; i++)
add_queue1 draw_mandelbrot(i);
run_queue1;
as thoise calculations are independant the run_queue may execute queue
(which is table of 1000 pointers and 1000 ints)
pararelly in 1000 threads and its very easy
when items may be dependant soem could add them to queue but also
store some tag (like group number) when eech group is independant versus other groups so each group could be run separatelly on threads with knowledge there is no conflict
int group ;
for(int i=0; i<1000; i++)
{
if(bot[i].x<300) group = 1;
else if(bot[i].x>700) group = 2;
else if(bot[i].x>400 && bot[i].x<600) group = 3;
else group = 4;
add_queue1[group] run_bot(i);
}
something like that but with better syntax.. it asumes bots act locally on map and if are distant 100 distance they will not interract..than those 4 groups can be run on 4 threads assumning nio collision is possible
something like that
Les messages affichés proviennent d'usenet.