in reply to Array Reference Issue
If you store nothing else the "sheep" and "nosheep" state in your array, a sheep:nosheep ratio of 1:250 is rather small.
Maybe you could just store a list of sheeps and their respective coordinates, and if you are looking for sheep you don't look in the positional table as you do it now, but in the list of sheep.
Or you could use the techniques that are commonly used for sparse matrices, that is you have two arrays, @x and @y, and in each you store a doubly linked list of sheeps and their coordinates. If you want to know if there is a sheep at (4, 123) you walk the list $y[123] to see if there is a sheep at column index 4.
|
|---|