Arne Babenhauserheide  committed 3fb6e30

complete as_completed run. Inefficient.

  • Participants
  • Parent commits 36bf17f
  • Branches py3.2-futures

Comments (0)

Files changed (1)


         enemy.new_experience += 1
-def preparemovement(me):
+def preparemovement(me, battlefield):
     """Gather the data needed for movement."""
     if me.wounds[1]:
-        return me
+        return
     if me.enemy is None or not me.enemy.pos in battlefield:
     if me.enemy is None:
-        return me
+        return
     me.forwards = stepforward(me, me.enemy)
     me.sidewards = stepsideward(me, me.enemy)
     me.odd = oddstep(me)
     """a single round of battle"""
     # concurrent preparation
     # step-by-step action
-    for me in, fighters):
-        if me.wounds[1]:
-            continue
-        if me.enemy is None:
+    for me in (f.result() for f in as_completed([et.submit(preparemovement, me, battlefield) for me in fighters])):
+        if not me:
         for step in (me.forwards, me.sidewards, me.odd):
             if step in battlefield: