Legacy GM Drawing Priority Queues and other data structures

Jam373

Member
So I started prototyping a turn based shooter and needed a way to store actions that take mutiple turns to complete. I thought Priority Queues would work for this, but am now running into trouble using them.

My question is, how would I easily draw to the screen every entry of my priority queue without changing the queue at all? If this isn't easy, what alternative data structure would you recommend for this? ds_grid?
 
My understanding of Queues and Stacks is somewhat limited, but I believe these are not ideal for such situations because there is no good way to loop through all the elements. Their use case is more limited, and I am thinking they are more for one time reads than preserved data. For your situation lists are probably more appropriate.
 

Jam373

Member
My understanding of Queues and Stacks is somewhat limited, but I believe these are not ideal for such situations because there is no good way to loop through all the elements. Their use case is more limited, and I am thinking they are more for one time reads than preserved data. For your situation lists are probably more appropriate.
Yep, that's what I'm realising. Though I think I need to use a grid instead as each entry is gunna require 2 data points not 1?
 

TheouAegis

Member
If you're using queues and stacks, then you are already using only one data point. The position of an element in the list is its priority.

You could still have a priority queue, but you would need to pop each element off and put it back into a different queue. That's just some unnecessary overhead every step.
 

Jam373

Member
If you're using queues and stacks, then you are already using only one data point. The position of an element in the list is its priority.

You could still have a priority queue, but you would need to pop each element off and put it back into a different queue. That's just some unnecessary overhead every step.
True but at least priority allows for two entry's to have the same priority value. Using an entry's position doesn't allow for that.

Yep I've already played with moving everything into a new queue every turn. Ideally not what I want.
So just to be clear though, what would people recommend instead? ds_grids? I don't think maps and lists will work for me as I need to be able to have repeat entries.
 

TheouAegis

Member
*brainstorms code* ...Oh yeah, list won't work. lol

A 2d array. A ds_grid will be easier to work with, but since both structures require the same shortcomings be accounted for, the array is much, much faster.
 
Top