currently you have 3 dimensions each of 65536 elements which I'm guessing you don't want.
The structure you have at the moment would be one used for volumetric data, like the data you get brain MRI scan, 65536 images, all of them 65536 by 65536 pixels. An absolutely *huge* amount of data!
Some algorithms for AI that you might of worked on store an image and the 'organisms' are only pixels in that image and data about them isn't stored anywhere else (such as the classic 'game of life')
However you will have far, far faaaar less organisms than you will have pixels, so it's more efficient to store data per organism :
Code:
type
TOrganism = record
PositionX : integer;
PositionY : integer;
PositionZ : integer;
ColourR : byte;
ColourG : byte;
ColourB : byte;
end;
Now lets say you have 1000 organisms in your world :
Code:
var
Organisms : array[0..999] of TOrganism;
you can access them like this :
Code:
Oganisms[22].PositionX := 10;
Now to render the organisms, rather than iterate (loop) over every pixel in your array and draw its colour, you iterate over your organisms and draw them at their stored position.
A rough example in 2d :
Code:
For I := 0 to high(organisms) do
begin
Image.Pixels[organisms[I].PositionX, organisms[I].PositionY].Red := organisms[I].ColourR;
Image.Pixels[organisms[I].PositionX, organisms[I].PositionY].Green := organisms[I].ColourG;
Image.Pixels[organisms[I].PositionX, organisms[I].PositionY].Blue := organisms[I].ColourB;
end;
Per pixel access will probably be more like : Image.Pixels[2,2] := RGB(RedValue,GreenValue,BlueValue) rather than a seperate byte for each colour but you get the idea.
Basically flip your logic on it's head, rather than storing all the data on every pixel which as a whole contain all your organisms, just store the data on your organisms and save yourself a ton of memory and speed (it's a lot quicker to draw 1000 pixels than it is 65536x65536 pixels)
You will probably have more questions so please feel free to ask
(long story short, you can use arrays like you're trying to use them but you're using such a huge, huge, huuuge number of entries that it's just going to crash and fall over. Whatever it is that you're trying to do, I can promise you that there are far easier ways to do it, just give us more info)
Bookmarks