Closed nkremerh closed 2 months ago
@colinhanrahan please double-check my work.
Nearly all changes (once bug fixes included are also applied) match exactly with the outcomes before this PR.
Adding a separate agent lookahead discount property causes a deviation. The way initial agents are provided endowments and how children are provided endowments is set up such that the random number generator is shielded from changes when we add new agent properties. I'm likely overlooking something small.
Please also feel free to suggest optimizations.
agentLookaheadDiscount
from agentLookaheadFactor
in the README by including something about how it only applies to ethical agents. They sound pretty similar as of now.futureIntensity
calculation works as intended when wraparound is turned off. Cells on the edges with, for example, 2 neighbors will be treated differently than other cells with 4 neighbors, which might not be what you want.Breaks determinism but outcomes are practically the same. The seed I was testing led to deviation at timestep 20, which is odd since that is after agents reproduce. So, the determinism change isn't caused by children being born. I'll take another dive into it.
Adding a note to the README.
Future intensity calculation verified.
For reference, my seed deviated from current determinism on timestep 93.
Fixed. I placed it in the paired endowments (could be temporary, but it makes sense to put it there permanently).
@nkremerh Alright, I found the issue by comparing the parentEndowments
and pairedEndowments
loops:
for endowment in parentEndowments:
- index = random.randrange(2)
random.seed(self.childEndowmentHashes[endowment] + self.timestep)
+ index = random.randrange(2)
endowmentValue = parentEndowments[endowment][index]
childEndowment[endowment] = endowmentValue
The random.randrange()
should be called after the seed is set, not before. Otherwise, for the config option directly after the new one, the random.randrange()
will be seeded with the hash from the previous option, which is now a different hash than it previously was. In practice, this caused the random index for agentLookaheadFactor
(the config option after agentLookaheadDiscount
) to change, which is what led to the deviation.
This fixes determinism on the seeds I tested. We should add this so we don't run into the same issue when adding new agent config options in the future.
Modifies hedonic calculus to use agent properties rather than magic numbers Adds agent finding their new cells in range when catching disease Adds agent lookahead discount when considering future rewards in hedonic calculus Fixes GUI getting proper vision, movement, and metabolism values for agent printouts