Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 387 388 [389] 390 391 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 886546 times)

Jiub

  • Escaped Lunatic
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5820 on: May 05, 2014, 01:50:54 am »

I stared at the code for a few minutes and tinkered with it a couple more, so here's some conclusions I came to. Firstly, there's a little problem with naming. At the begin you create the two lists, "curGen" & "nexGen", which is ok, no problem. But then you also use these names as arguments for all the methods. I haven't experimented with/am not experienced enough to say for sure which one the method uses. An example of what I mean, you can do this:

value = 10
def add_value(number):
    return number + value

And it does it fine. What your code is doing, is using the same name twice (in the example, replace "number" with "value"), which obviously does something unwanted/unexpected.

So what I ended up doing to make the code run fine was:

1. Change all the argument names to something a little different.
2. Create the empty list "nexGen" inside, at the beginning of step() (no need for it to be global)
3. Change line 64 to "curGen = step(curGen)"

And that should pretty much do it.
Logged

da_nang

  • Bay Watcher
  • Argonian Overlord
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5821 on: May 05, 2014, 02:01:19 am »

Python doesn't distinguish between formal and actual parameters?
Logged
"Deliver yesterday, code today, think tomorrow."
Ceterum censeo Unionem Europaeam esse delendam.
Future supplanter of humanity.

Vattic

  • Bay Watcher
  • bibo ergo sum
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5822 on: May 05, 2014, 02:26:06 am »

Hurrah it works! Thank you Jiub.

I still wonder why it was working fine with the list swapping line, and I thought it could handle the way I named things.

Thanks again.
Logged
6 out of 7 dwarves aren't Happy.
How To Generate Small Islands

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #5823 on: May 05, 2014, 03:48:18 am »

Python doesn't distinguish between formal and actual parameters?
Python doesn't distinguish between a lot of things, like constants and... not constants. It makes it very easy to learn, but a nightmare to use anything someone else has written.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #5824 on: May 06, 2014, 01:48:28 am »

Profiling for C# is so painful.

Reason: all the profilers seem to be like 500$ for a license. ._.

Also, while I'm sure MSVS also has a profiler, you need a 600$ copy (the Ultimate version, I think) of it to actually use it.

edit:
Thanks, ANTS, you've been very helpful. Thanks for telling me things I already knew, then not provide extra information.

 Also, your MSVS plugin didn't actually install correctly. You're supposed to put it in 2013's folder, but you put it in 2010 and have no option for changing it. Sigh. ;_; Someone help me figure out how to convince ants to give me more info?

edit2: Ok, revealing hidden methods at least gives me the name of the methods. woot!
« Last Edit: May 06, 2014, 02:22:34 am by Skyrunner »
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5825 on: May 06, 2014, 02:24:43 am »

If you compile your own copy of substrate, and use that, rather than the included dll, then it will show you that most of the time is spent on recalculating the light.

This is also confirmed by the fact that adding caves resulted in a significant speed decrease in generation.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #5826 on: May 06, 2014, 02:36:16 am »

Interestingly, disabling fluid checking makes it slower. Kinda counter-intuitive.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5827 on: May 06, 2014, 01:20:33 pm »

Ah, SS13 code.


That's a function that returns and calls the parent function. And then returns again. At the end of said function.
Because why not.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #5828 on: May 07, 2014, 03:23:37 am »

Ah, SS13 code.
<image snipped>

That's a function that returns and calls the parent function. And then returns again. At the end of said function.
Because why not.
Ew.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #5829 on: May 07, 2014, 08:19:44 am »

So... is there a way to force C# to release memory? And by force, I don't mean by calling Collect() and WaitForPendingFinalizers() and hoping that the GC attempts to clean it up :(
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5830 on: May 07, 2014, 09:28:56 am »

So... is there a way to force C# to release memory? And by force, I don't mean by calling Collect() and WaitForPendingFinalizers() and hoping that the GC attempts to clean it up :(
I don't think so. But if you feel like you're burning through memory too fast for the GC to clean up behind you, you could try reusing your data structures instead of de- and reallocating them.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #5831 on: May 07, 2014, 10:11:20 am »

I have a temporary Bitmap that takes up 1.2GB of space. I kinda need the GC to remove that 1.2 GB immediately after I'm done with processing it into a very much smaller HashSet, or I kinda run out of memory :/

Times like this are when I slightly miss C++... though I have a mild suspicion that the GC actually does free RAM but the Task Manager doesn't reflect it. Perhaps the CLI VM (I think?) Holds onto the 1.2 GB of memory in case I need it later.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5832 on: May 07, 2014, 10:17:05 am »

Yeah, you really can't trust Task Manager for that.  What it reports for memory usage includes a lot more than what your program may be actively allocated and using.

When you say you run out of memory, is that actually happening, as in you get exceptions when trying to allocate something new (I think C# does that)?  I'd be really surprised if the runtime environment wouldn't collect memory you're no longer using when it came time to allocate something new, if it didn't have enough free memory in the first place.
Logged
Through pain, I find wisdom.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5833 on: May 07, 2014, 05:58:42 pm »

I have a temporary Bitmap that takes up 1.2GB of space. I kinda need the GC to remove that 1.2 GB immediately after I'm done with processing it into a very much smaller HashSet, or I kinda run out of memory :/

Times like this are when I slightly miss C++... though I have a mild suspicion that the GC actually does free RAM but the Task Manager doesn't reflect it. Perhaps the CLI VM (I think?) Holds onto the 1.2 GB of memory in case I need it later.

Theoretically, that *should* get paged out to the disk whenever you're not using it, considering its size. If it's really a problem, you could use a random-access file instead of an in-memory data structure, and force it to be on disk. But, it sounds like it's not a huge (huehuehue) problem, especially considering Task Manager lies, as Telgin noted.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #5834 on: May 07, 2014, 09:55:12 pm »

Yep, I get exceptions when trying to make another Bitmap of the same size :P

More research tells me that it has to do with allocating large bitmaps more than running out of memory--continuous, large memory structures are problematic.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward
Pages: 1 ... 387 388 [389] 390 391 ... 796