Staredit Network > Forums > Technology & Computers > Topic: Help me program
Help me program
Dec 12 2010, 6:29 am
By: Sand Wraith  

Dec 12 2010, 6:29 am Sand Wraith Post #1



If ever I said I was any good at programming, consider the statement null and void.

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 :P ).

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.




Dec 12 2010, 7:35 pm CecilSunkure Post #2



Python should have a built in garbage collection system to prevent memory leaks. Since Python is a high level programming language, you don't get to mess with anything low-level and don't need to worry about cleaning up your memory allocation. I haven't looked at your code, but it's something else that is causing problems.



None.

Dec 13 2010, 7:52 am ShadowFlare Post #3



It is probably whatever is causing it to run more python processes. Are you running any external scripts in your code? Not just including them, but actually running it as a separate process.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[08:09 am]
Zycorax -- Greed
[03:25 am]
Symmetry -- why do the oligarchs want our mapping strategies???
[03:24 am]
Symmetry -- the question is why though
[01:10 am]
Butch -- made me feel really sad and stupid and fat
[01:10 am]
Butch -- I got duped by one and replied and then realized after
[11:26 pm]
Sie_Sayoka -- the turings have tested
[03:07 pm]
UndeadStar -- https://staredit.net/topic/18961/ <= wow, if there wasn't a capital letter on almost every word in the title, and a link in the signature, I may not have guesses it's an AI bot. I don't know much about map editing, but the content may even be relevant enough to be kept.
[2026-11-10. : 4:16 am]
lil-Inferno -- fart screen
[2026-11-09. : 3:49 pm]
NudeRaider -- Ultraviolet
Ultraviolet shouted: :wob: maybe not replaced, just add a discord applet below the shoutbox imo
split screen. Left side shoutbox, right side discord meme channel
[2026-11-08. : 10:23 pm]
Ultraviolet -- :wob: maybe not replaced, just add a discord applet below the shoutbox imo
Please log in to shout.


Members Online: MetalGear, RussellWalker106, Oh_Man, GerdinaMeer303