Which data structure(s) to back a Final Fantasy ATB-style queue? (a delay queue)

Posted by ZoFreX on Stack Overflow See other posts from Stack Overflow or by ZoFreX
Published on 2010-03-13T04:02:14Z Indexed on 2010/03/13 4:07 UTC
Read the original article Hit count: 215

Situation: There are several entities in a simulated environment, which has an artificial notion of time called "ticks", which has no link to real time. Each entity takes it in turns to move, but some are faster than others. This is expressed by a delay, in ticks. So entity A might have a delay of 10, and B 25. In this case the turn order would go:

A A B A A

I'm wondering what data structure to use. At first I automatically thought "priority queue" but the delays are relative to "current time" which complicates matters. Also, there will be entities with larger delays and it's not unforseeable that the program will run through millions of ticks. It seems silly for an internal counter to be building higher and higher when the delays themselves stay relatively small and don't increase.

So how would you solve this?

© Stack Overflow or respective owner

Related posts about data-structures

Related posts about priority-queue