manishravula/irlfortypes

state_update not succeeding in every step.

Closed this issue · 1 comments

In file src/update_state.py, the update_state fails in comparing the state of arena from history and the state of arena in the update procedure when running on test1().

The assertion fails only when an item or two were consumed in the update-loop in the last iteration. Further, the assertion fails only due to the difference in item_count, rest remains the same. The agents' states also remain the same, except for the modified config of the agent's state we are trying to update.

This is unexpected as the agents execute the exact same actions.

Commit a8f4457 fixes this issue.

The reason for this issue is two fold.

  1. In src/update_state.py: We can't perform update_foodconsumption(), because different parameters will lead to different consumptions and then the arena state won't be as expected from the history. Mimicking actions is the only true thing we need to do. Rest all should remain the same.

  2. In src/arena.py: In the __setstate()__, we only copy the grid matrix. But when the agents check for visible items, through the self.arena.items in their self.behave() method, they are borrowing off a wrong list of items, because the arena's item list is only built at __init__ and modified through consumption. The fix is to re-init the item list everytime __setstate__()is run.