CityScope / CS_Cooper-Hewitt

meta repo/sandbox repo for keeping everything related to the Cooper Hewitt exhibition
5 stars 2 forks source link

agents are instantiated from simPop.csv with their data including res… #54

Closed aberke closed 5 years ago

aberke commented 5 years ago

…idential and office blocks

agrignard commented 5 years ago

See Issue #51 https://github.com/CityScope/CS_Cooper-Hewitt/commit/65cbf1fffd182e519a56b5ff6ef74bd55eb00765

we should now be able to write

if (residentialBlockId > 17 || officeBlockId > 17) { srcNode = getNodeInZombieLand().get(0); destNode = map.getNodeInsideROI().get(0);

}
aberke commented 5 years ago

@agrignard thanks for the review and the additions of the zombie land functions.

  1. I pushed a new commit to this branch that adds an option to initialize agents from random data instead of from the datafile.

  2. About not passing the grid to the agents: I think you're right that it is better to keep the universe.grid as a publicly accessible object and not passing it to each agent! The problem is that at the time of initializing the agent, the universe is not yet done being initialized (because the agents are initialized in the same call stack that initializes the universe). This means that the first time the Agent tries to call universe.grid to get the srcNode and destNode from its building ids, the universe is null and there is a NullPointerException. One way to deal with this is to instantiate the Agent's without srcNode or destNode 's set, and then set them on the first call to the Agent's update() function.
    What do you think?

I think the way to move forward with respect to incremental changes is:

aberke commented 5 years ago

I pushed another commit to this branch as a possible way to address (2): https://github.com/CityScope/CS_Cooper-Hewitt/pull/54/commits/62f49d3cbbaeb17ae4e4c19f0485fa86f1acca7a

This lazily calls the Agent's init function. It works, but please let me know what you think about this choice.

aberke commented 5 years ago

Sorry for the noise.

I fixed this to remove the lazy call to initAgent and instead call initAgent from the initWorld function.

agrignard commented 5 years ago

Yep this is why InitAgent function exists (btw it was already questioned here here https://github.com/CityScope/CS_Cooper-Hewitt/issues/9#issuecomment-431776231)

Overall I think it's getting there. We are close to merge this one.

I let you do the final little modif for this one and I'll merge it.

Goog job!