[IronPython] Multiple engines keep barfing
Brandon Furtwangler
furtwan1 at msu.edu
Thu Jan 12 02:21:32 CET 2006
I'm making a simple AI game and I can load a ship up that runs a python
script to control its behavior.
My python script uses the random python library (ripped from CPython) and
works fine if I have one ship, but if I try to create another I get an
exception saying that 'None is not enumerable'.
It's in os.py on the line that says "if 'posix' in _names:". (and _names =
sys.builtin_module_names)
I don't see why it should act any different with the second engine because
they are both going through the exact same code path:
pe.AddToPath(System.Windows.Forms.Application.StartupPath + @"\Lib");
pe.LoadAssembly(System.Reflection.Assembly.GetAssembly(typeof(Ship)));
pe.SetVariable("ship", this);
pe.ExecuteFile(aiscript); <-- {"None is not enumerable"} from os.py
The script:
from IPExample import Action
import random
def GetAction():
p = random.uniform(0.0,1.0)
d = 0.0
for i in range(0,6):
d += actionProps[i]
if p <= d:
return allActions[i]
return allActions[6]
allActions = [Action.RotateClockwise, Action.RotateCounterClockwise,
Action.RotateGunClockwise, Action.RotateGunCounterClockwise,
Action.Fire, Action.MoveForward, Action.ActivateShield]
actionProps = [0.1,0.1,0.05,0.05,0.2,0.4,0.1]
Any ideas on what I'm doing wrong? Have others run into this? Known bug?
Obviously sys.builtin_module_names is 'None' for some reason only on the
second engine...but why?
-Brandon
More information about the Ironpython-users
mailing list