Need some simple coding help

Terry Reedy tjreedy at udel.edu
Wed Mar 2 12:38:00 EST 2005


"mx2k" <mx at mx2k.net> wrote in message 
news:1109762091.780210.245430 at f14g2000cwb.googlegroups.com...
>  Now you enter a value by which the initiative should be increased,
> then adding reaction time to that value and then adding the result to
> reaction time. Now soring again by lowest,next,'n'th, etc. and then
> again showing the output, asking for another number etc.

If I correct understand your goal, you might use a priority queue (heap) 
(there is one in the standard library).  You insert all chars with the 
initial response time as the 'key'.  You remove the one who is going to 
respond first and perform his actions.  If he is to get another turn, add 
his next reaction time to the current value and insert him back into the 
queue.  The next character to act will then be at the front of the queue. 
Repeat.

Terry J. Reedy






More information about the Python-list mailing list