I can’t figure out why this section of code is not removing “tactic” (tuples) from a List[of tuples()]
def _cleanup(self):
for tactic in self._currentTactics:
if tactic[0] == "Scouting":
if tactic[1] in self._estimate.currently_visible:
self._currentTactics.remove(tactic)
elif tactic[0] == "Blank":
self._currentTactics.remove(tactic)
elif tactic[0] == "Scout":
self._currentTactics.remove(tactic)
Screenshots of my IDE (pydev) with further debugging info is available at:
https://i.stack.imgur.com/VP0Fw.jpg
EDIT: A bug fix I noticed and an improvement.
To clarify, “Blank” is getting removed, “Scouting” is getting removed when necessary, and “Scout” tactics are NOT getting removed afaik.
You are removing members from the list while you are iterating over it. By doing this you will miss certain elements in the list. You need to iterate over a copy of the list instead.
Change:
to: