Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Programming Algorithms  (Read 2050 times)

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Algorithms
« Reply #15 on: April 15, 2011, 02:14:56 am »

I had a bit of trouble earlier in my programming ventures with trying to have a method that calls other methods to do work by running into the C# garbage collect *shudders*

I've found a balance now, where I can have that easier to manage and modify controller class and not run into the garbage collect. It makes for a much easier to read, organize, and add to a program. Also then I can use virtual methods for different AI for different enemies :D

Although I've never gotten to that point, so the concept remains a concept as of right now.
Running into problems with the garbage collector? As far as I know, C#'s garbage collector should not interfere with something as simple as function calling?
Logged

metime00

  • Bay Watcher
  • Adequate Dwarf Fortresser
    • View Profile
Re: Programming Algorithms
« Reply #16 on: April 15, 2011, 02:00:38 pm »

More that the objects were being garbage collected and so did not exist. I don't remember the specifics, but I am pretty sure that it was my sloppy coding which prompted the destruction of my objects. Perhaps I didn't have the whole "controller class" concept and the constant back and forth caused problems.
Logged
Live long if you can, and prosper by any means necessary.  Any means, Urist.  So pull that lever, or by Armok, I'll lock you outside come next siege.
He who plays with dwarves must take care that he does not become a dwarf.  And when you stare into DwarfFort, Dwarffort stares back into you.

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Algorithms
« Reply #17 on: April 15, 2011, 04:05:41 pm »

Well, the only way to get the GC to collect your objects is to cut all ties with the rest of the program, so you were probably forgetting to assing them to a variable.
Logged

metime00

  • Bay Watcher
  • Adequate Dwarf Fortresser
    • View Profile
Re: Programming Algorithms
« Reply #18 on: April 15, 2011, 04:22:24 pm »

yes, I had the program jump between classes without any main class to go back to afterward so when I needed a certain one again it was already gone.
Logged
Live long if you can, and prosper by any means necessary.  Any means, Urist.  So pull that lever, or by Armok, I'll lock you outside come next siege.
He who plays with dwarves must take care that he does not become a dwarf.  And when you stare into DwarfFort, Dwarffort stares back into you.
Pages: 1 [2]