I have tried with code:
Code: Select all
local list=AITownList();
local count=list.Count();
local N=RandRange(count);
You can also valuate with RandItem and then pick first, but that is also ineffective.
Is there some better way for random access to list elements (aside from copying the entire list to some array, which may work, but may not be always appropriate, especially if you won't need the list after that) that won't require going over entire (or significant portion of) list?
Hmm .. maybe it would be nice idea to extend AIAbstractList with some GetRandomItem() function :)