the_dude_abides
Member
Hi.
I am using as ds_list to store instance ID's as part of my AI. The list is created at the 'create' event, cleared then repopulated during normal steps, and then destroyed in the 'Destroy' event.
THE SHORT VERSION OF MY QUESTION WOULD BE:
depending on the size of this structure which is most beneficial for just storing id's? a ds_list, array or a buffer? (could a buffer hold such data?)
THE LONG VERSION OF MY QUESTION WOULD BE:
An alternative of doing this with an array seemed slightly slower - but I would I be right in thinking it's better memory management specifying the exact length of the array, than having a permanently open ds_list that expands as necessary?
Then I read about buffers...and that confused things for me (I'm easily confused...) as it's yet another data structure. What are the benefits over using an array - speed? memory size?
If anyone has the time to give me a basic explanation it would be appreciated.
EDIT:
I thought I'd include the code to show what I'm doing. The number of entries into a buffer would be known, as it would be the size of the ds_priority after it has been filled. If an id can be stored in a buffer, would it be faster and more efficient than a ds_list?
(sorry if this looks messy - I don't usually do my code like this, and have tried to make it how people prefer to read it)
I am using as ds_list to store instance ID's as part of my AI. The list is created at the 'create' event, cleared then repopulated during normal steps, and then destroyed in the 'Destroy' event.
THE SHORT VERSION OF MY QUESTION WOULD BE:
depending on the size of this structure which is most beneficial for just storing id's? a ds_list, array or a buffer? (could a buffer hold such data?)
THE LONG VERSION OF MY QUESTION WOULD BE:
An alternative of doing this with an array seemed slightly slower - but I would I be right in thinking it's better memory management specifying the exact length of the array, than having a permanently open ds_list that expands as necessary?
Then I read about buffers...and that confused things for me (I'm easily confused...) as it's yet another data structure. What are the benefits over using an array - speed? memory size?
If anyone has the time to give me a basic explanation it would be appreciated.
EDIT:
I thought I'd include the code to show what I'm doing. The number of entries into a buffer would be known, as it would be the size of the ds_priority after it has been filled. If an id can be stored in a buffer, would it be faster and more efficient than a ds_list?
(sorry if this looks messy - I don't usually do my code like this, and have tried to make it how people prefer to read it)
Code:
if (current_state==states.object_test)
{
state_is="object test";
if path_position==1
{
if path_exists(get_path)
{
path_delete(get_path);
}
path_position=0;
}
var num,bbox,cur_x,cur_y;
num=instance_number(object12);
ds_list_clear(object_list);
bbox=bbox_top;
cur_x=x;
cur_y=y;
if num > 1
{
var b,hit2,dist2;
for (b=0;b < num;b+=1)
{
hit2=instance_find(object12,b);
if hit2!=id
{
dist2=point_distance(cur_x,cur_y,hit2.x,hit2.y);
if (dist2 < 200)
{
if ((hit2.bbox_bottom) >= (bbox))
{
ds_priority_add(dist_list,hit2,dist2);
}
}
}
}
var size,index,dist;
size=ds_priority_size(dist_list);
if size > 0
{
for (index=0; index < size; index+=1;)
{
dist=ds_priority_delete_min(dist_list);
object_list[| index]=dist;
}
}
size2=ds_list_size(object_list);
current_state=states.path_test;
}
else
{
current_state=states.set_alarm;
}
}
Last edited: