From 9354d7c22323edf085fe829a4e0c0115b8f992e7 Mon Sep 17 00:00:00 2001 From: Lucia Hughes <105667509+luxiextra@users.noreply.github.com> Date: Fri, 30 Aug 2024 14:57:02 -0400 Subject: [PATCH] Fixes flocking position calculation to work as expected by tests. Before this change, the expected results' positions occur one time-step later than they should, so tests do not pass. (When given a starting velocity of 0, the positions of the boids would always remain in that position after the first time-step, which is not expected by the tests.) --- docs/artificialintelligence/assignments/flocking/flocking.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/artificialintelligence/assignments/flocking/flocking.cpp b/docs/artificialintelligence/assignments/flocking/flocking.cpp index 4e0f283e..6c596715 100644 --- a/docs/artificialintelligence/assignments/flocking/flocking.cpp +++ b/docs/artificialintelligence/assignments/flocking/flocking.cpp @@ -181,7 +181,7 @@ int main() { for (int i = 0; i < numberOfBoids; i++) // for every boid { newState[i].velocity += allForces[i] * deltaT; - newState[i].position += currentState[i].velocity * deltaT; + newState[i].position += newState[i].velocity * deltaT; cout << newState[i].position.x << " " << newState[i].position.y << " " << newState[i].velocity.x << " " << newState[i].velocity.y << endl; }