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

she/her

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.
[2026-6-04. : 3:42 am]
RIVE -- Hellooooo, Nurse
[2026-6-03. : 4:19 pm]
NudeRaider -- Hello World!
[2026-6-01. : 4:03 pm]
IskatuMesk -- no Hello World? No Hello . jpeg? Not even ddosing some government website? smh my head
[2026-5-31. : 10:02 pm]
Symmetry -- I was really just figuring out how to compile
[2026-5-31. : 10:02 pm]
Symmetry -- I didn't make it do anything
[2026-5-31. : 9:17 pm]
Ultraviolet -- hell yeah. did you have trouble making the button functional, or just haven't gotten there yet?
[2026-5-31. : 8:29 pm]
Symmetry -- I made the marine shoot lasers and gave the medic a nonfunctional button
[2026-5-31. : 8:07 pm]
Ultraviolet -- Symmetry
Symmetry shouted: I did my first EUD thing today. Feels like me finding arsenal at age 8 again
haha for sure. in some ways it's even more exciting because you can play EUD maps on regular battle.net, don't need to convince someone to download your mod to play with you. what did you do?
[2026-5-31. : 6:47 pm]
Symmetry -- I did my first EUD thing today. Feels like me finding arsenal at age 8 again
[2026-5-31. : 3:20 pm]
l)ark_ssj9kevin -- le reddit
Please log in to shout.


Members Online: Zycorax