Presage / Presage2

PRESAGE is a simulation platform for rapid prototyping of Agent Societies. It enables designers to investigate the effect of agent design, network properties and the physical environment on individual agent behaviour and long-term collective global performance.
http://www.presage2.info
GNU Lesser General Public License v3.0
19 stars 6 forks source link

testDiscreteGetMoveToWithSpeed intermittent failure #49

Closed sammacbeth closed 12 years ago

sammacbeth commented 12 years ago

Every so often testDiscreteGetMoveToWithSpeed fails. Either there is an edge case which is failing or a bug in the test.

javajawa commented 12 years ago

Specifically, test throws error 'zero norm' for Location.angle(m1, m2), the last line of the test. This will be the case when both dx, dy are zero (thus, l1 = l2)

Possibly:

        final int dx = Random.randomInt(10) - 5;
        int dy = Random.randomInt(10) - 5;
        if (dx == dy && dy == 0) dy = 1;
        final Location l2 = new Location(x + dx, y + dy);

Edit: Remove final keyword on dy; split dx == dy == 0 into two expressions

sammacbeth commented 12 years ago

Thanks for the fix. I also found there was an occasional assertion error in the same line due to a rounding of the scaled down vector. Commit incoming.