Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSignalDensityAlongAxis and getPopulationDensityAlongAxis assertions #90

Open
MrSlinkyman opened this issue Apr 1, 2023 · 1 comment

Comments

@MrSlinkyman
Copy link

MrSlinkyman commented Apr 1, 2023

I saw in a previous issue where these two assertions were added. I'm curious, however, if the program asserts that the direction is not CENTER, how do you prevent creatures from actually using that direction when these sensors are called?

assert(dir != Compass::CENTER); // require a defined axis

assert(dir != Compass::CENTER); // require a defined axis

In the getSensor() call I would imagine that the creatures would have a last move direction as CENTER just by chance.

sensorVal = getPopulationDensityAlongAxis(loc, lastMoveDir);

In my implementation in Java, these assertions are preventing the program from moving forward so I changed them to early returns where the method just returns 0.5 if the direction supplied is CENTER. But I am not sure if that is the right interpretation.

Would love some insight.

@davidrmiller
Copy link
Owner

davidrmiller commented Apr 2, 2023

From a quick look, I think that the lastMoveDir member variable will not be CENTER because it is initialized to Dir::random8() (which can't be CENTER) and modified only in one place in Peeps::drainMoveQueue(). The lastMoveDir member is only modified there if the individual is alive and if the newLoc grid location is empty, which prevents it from being set on the CENTER location which is where the individual resides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants