nov 20 2013 4:22p
The item that an enemy would go for was flip flopping. It would continually flip between chasing after the 2 nearest items. I detected this bug in 2 minutes on the 1st launch, because I had inserted printf statements.
– Detection: printf statements
Enemy squadron Fighter thinks item B1 is reachable in 2.703664 seconds
Enemy squadron Fighter thinks item Bandit is reachable in 2.884945 seconds
Enemy squadron Fighter thinks item B1 is reachable in 2.703305 seconds
Enemy squadron Fighter thinks item Bandit is reachable in 2.884617 seconds
Reason: units were programmed not to chase after items that units on their same team were chasing after. Unfortunately overlooked the fact that I would be seen on as on my same team.
– If I’m already gathering an itembox, stick with it until i get it OR
– If the person gathering the itembox is ME, keep going after it.
Using integer indices into arrays of objects (instead of iterators, or pointers to the objects themselves) has saved my ass many times.
Say you have a vector<Object>. Well, you wouldn’t store pointers of type Object* to an element of this array, ever, because if the vector gets resized, all objects get deallocated/reallocated and so all your previous references will be invalid. But if you store a vector<Object*> and save an external reference to an Object* within that vector, then that’s no problem.
But anyway, storing integer arrays is much better than storing copies of pointers. For one, if the pointer gets deleted, you’re not left with an invalid / dangling pointer somewhere. Checking if a reference into the array is valid because you just have to check the integer index is between 0 and (.size()-1).
f := (x) -> x^2
Is the function f(x)=x^2. You call it by writing
To animate the function, just add another parameter and give it a range in a plot command.
plot( a*f(x), x=-2..2, a=0.1..5 )