[=;204938]
I’d have used a single array encapsulating the data I need; I don’t see any advantage to maintaining two. Breaking a struct isn’t exactly an intensive operation, so I’d never worry about that.
[/]
For simple get-operations you’re probably right, though I wonder if breaking structs will have an impact if it is done multiple times within a loop. I believe it might become more of a problem when you want to change a single element in a struct. Then you would have to both break the struct, change the relevant variable and make a new struct before setting the new struct into the array array. How inefficient this would be is of course an empirical question, and I’ll try to simulate it before changing my blueprint. If it is at least equally fast as my old method I’ll probably og with your suggestion and change to having a single array, as it will probably be cleaner and simpler to work with.
[=;204938]
I can see some use there, but to be honest I’d still not do it; I’d work on the presumption that the AI can query tiles in range and dismiss / score them appropriately. Storing all tiles that are visible to given pawns could mean storing an increasingly large amount of data the more you increase the number of pawns you have!
[/]
That depends how you store it. I would use a single array the size of the map to store the visible tiles of all pawns instead of having a separate array for each pawn, if I understood you correctly in how you persumed I store my data.
[=;204983]
So instead of accessing 3-4 separate arrays, each of which could be thousands of members long, you would instead access 1 array and grab all the relevant data from the struct for whatever operation you are about to run. Makes sense When I go into cleanup phase on the generator I will test the gen time before and after switching everything to structs and see if there is any noticeable improvement.
[/]
Please let us know if you find it to be quicker. I’ll get around to checking it myself, but I probably won’t be able to for the next few days due to work.