I need some help with Python (3.x; 3.1.2 specifically) - using Windows 7 (and, thanks to the modules I'm using, it's only compatible with Windows).
Between style, syntax, and algorithms, my code is usually pretty horrendous. These factors do not help at all, especially for my current program.
ATM, I'm trying to program a simulator (for a zombie apocalypse? I dunno). All I've got are a map, some functions for running each turn, some functions for adding shit, terrain, and units.
My biggest problem right now is memory handling and efficiency. My units are implemented as such: their is a base unit class, and I have several (hundreds, sometimes) objects of the unit class. The class has functions for moving the units, which follow a convoluted and ridiculous pathing algorithm to determine where to move next.
I have a feeling that somewhere along the way of all of this, I'm leaking a massive fuckton of memory. My reasoning? I'm running a Windows 7 64-bit, i7-720 Quad Core, 9GB DDR3 machine and after just a few thousand turns (or something) with a few hundred people walking around, my computer gets whacked. I only noticed this just now: while I was running a test (probably a hundredth test or so), reaching into some 3000 turns with a few hundred persons on the field, my entire desktop flickered and changed to the default Windows 7 style. It only changed back after I went into the task manager and stopped multiple (several tens, at least) instances of "python.exe", each one taking some 17,000K of memory (or something).
In any case, I'd like to get some help with cleaning up my code, since, frankly, I'm too inexperienced to cut down on memory costs and leaks and shit.
The *.py files should be in the same folder. Use Python 3.x (I dunno if the specific version number will matter much; I'm using 3.1.2). Use Windows to test.
I've been testing for syntax/run-time errors using IDLE in interactive mode, writing the actual code in IDLE script mode, and also quick-testing by running the script by double-clicking "i dunno 2.py" (hurrdurr).
I've also had the "iD_mapLegend.py" file open simultanesouly.
Hope the info helps. I hope you can help (although my code is pretty terrible; I don't blame you if you tell me to clean up my style and such
).http://pastebin.com/kqdVmTSY - main, "i dunno 2.py"
http://pastebin.com/dcJWUH4p - module, "iD_mapLegend.py"
Post has been edited 1 time(s), last time on Dec 12 2010, 7:49 pm by Sand Wraith.






