Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 35 36 [37] 38 39 ... 796

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

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #540 on: January 13, 2012, 11:05:34 pm »

Programmers get death threats for using GOTO statements to control their flow. (not really, but you would think that from the amount of hate for it...)

... I tend to use GOTO statements, but then again no one usually gets to see my code. I use them sparingly, and only when using them will help me understand a section of code better than I would otherwise. When I use them I always pay a lot more attention to how my code is flowing because it's easy enough to use them wrongly. WRONGLY.

Note, I can only speak for C# which I've read in multiple places is safe for the computer's memory so long as you don't fuck up.
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #541 on: January 13, 2012, 11:06:26 pm »

I don't even know which languages, other than Basic, even support goto :V
Logged

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #542 on: January 13, 2012, 11:13:16 pm »

I don't even know which languages, other than Basic, even support goto :V
All of them? Actually, I'm not sure if MATLAB has them, but I know C, C++, D and Pascal have them.
Logged

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #543 on: January 13, 2012, 11:14:13 pm »

GOTO is supported in a lot of languages.  It's usually considered a bad idea to use it.  I mostly end up using it while programming for something unusual...like when I'm programming in Assembly, where j (jump) is the equivalent of GOTO.

@Stargrasper: Yes, I know you said stylistically, but I was curious as to whether or not there was any reason given by your prof.

I don't recall an explicit reason being given.  I think it was to make the code easier to work with.

Sounds to me like you had a stubborn teacher.  Why would Do-While loops exist if there was never a good reason to use them?  Don't worry though, you have inspired me to be diligent about examining loops.

Best prof in the department, though.  Granted I never thought very highly of my CS profs, by and large.  That particular prof was being stringent to try to teach us good coding practices while we were still learning.  I can understand that such a thing is sketchy at best.  I'm not sure why do loops exist.  In fact, when teaching us loops initially, he skipped them entirely.  We were only initially taught about while and for loops.  Why he did that, I don't know.  It's just as a consequence that I'm inclined not to use them often.  You inherit a lot of your coding style from how you first learned to do things.  And then I started ignoring parts of it as I figured out what I was doing.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #544 on: January 13, 2012, 11:18:21 pm »

Programmers get death threats for using GOTO statements to control their flow. (not really, but you would think that from the amount of hate for it...)

... I tend to use GOTO statements, but then again no one usually gets to see my code. I use them sparingly, and only when using them will help me understand a section of code better than I would otherwise. When I use them I always pay a lot more attention to how my code is flowing because it's easy enough to use them wrongly. WRONGLY.

Note, I can only speak for C# which I've read in multiple places is safe for the computer's memory so long as you don't fuck up.

I was more referring to C and C++, which can both have some very serious consequences stemming from mixing goto and dynamic allocation.

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #545 on: January 13, 2012, 11:56:19 pm »


I'm calling this a partial success.  What's important is, it's working well enough to draw the map and print it.  I'm pretty sure I know where the overwrites are coming from.  Also takes a while to generate - I think I can optimize a few things, but I'm not entirely sure how to go about it yet.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #546 on: January 14, 2012, 12:07:03 am »

I spent the night running someone through what amounted to a crash course in ruby on rails for a project we're working on. They've been at it for about a week now, but damn has my ego been boosted. ;)

It's funny that 8 months ago I was a clueless idiot, and now I'm having trouble seeing why he would have any difficulty with such "obvious" stuff...
Logged

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #547 on: January 14, 2012, 12:10:12 am »

Yeah, that's how programming tends to work.  Does feel good when people benefit from me teaching them.  The crash courses are especially fun.
Logged

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #548 on: January 14, 2012, 12:11:46 am »

It's funny that 8 months ago I was a clueless idiot, and now I'm having trouble seeing why he would have any difficulty with such "obvious" stuff...
I feel like that every time I code.

"Damn how could I have forgotten this over the last three days?"
Logged

optimumtact

  • Bay Watcher
  • I even have sheep
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #549 on: January 14, 2012, 01:53:07 am »

Programmers get death threats for using GOTO statements to control their flow. (not really, but you would think that from the amount of hate for it...)

... I tend to use GOTO statements, but then again no one usually gets to see my code. I use them sparingly, and only when using them will help me understand a section of code better than I would otherwise. When I use them I always pay a lot more attention to how my code is flowing because it's easy enough to use them wrongly. WRONGLY.

Note, I can only speak for C# which I've read in multiple places is safe for the computer's memory so long as you don't fuck up.

Of course they get stick for it, they're supposed to use the highly superior come from statement  :P
Logged
alternately, I could just take some LSD or something...

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #550 on: January 14, 2012, 05:02:06 am »

I went back and forth with a few different revisions to my corridor codewall, all of which went nowhere.  Then I thought about it for a minute, and looked at a piece of placeholder code I had commented out for testing purposes, when inspiration struck me.

It kept writing corridors all over the rooms, even though it wasn't supposed to... even though the code that was supposed to prevent that looks backwards to me, but Mego said it would work and it looked like it would.  All the test runs showed the corridors were trying to get to the doors, but they were either on the wrong side of the map or drawing off in weird directions.  And then I figured it out.

It made a list of doors and their coordinates, and tried to walk paths onto one door from another... Except doors were part of its forbidden walking-spaces.  Whoops.  So who knows what crazy crap it was trying to do, since the code worked but the logical underpinnings didn't.  Then I revived my test segment, and modified it to move the target-locations to next to the doors.


Okay, so it still looks like total shit, and is still drawing some corridors on the wrong side of the map, but it's not overwriting anything, it's reaching the doors, and it doesn't crash.  It is technically everything I needed, and who knows, maybe the extra weird pathways give it some flavor.  And I might be able to fix that.  And in my desperation I may have come up with a whole new way of making maps, rather than trying to ape NetHack.

Point is, success.  Onward and upward.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #551 on: January 14, 2012, 05:17:51 am »

That is pretty fucking sexy Aqizzar.
I'm still having trouble with my SplitRooms. For some reason it is going into index out of bounds exceptions... It is strange because a SplitRoom should be the same size as a splitRoom, so I don't know why it works for making ArrayRooms and not SplitRooms.

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #552 on: January 14, 2012, 06:03:56 am »

I'm still having trouble with my SplitRooms. For some reason it is going into index out of bounds exceptions... It is strange because a SplitRoom should be the same size as a splitRoom, so I don't know why it works for making ArrayRooms and not SplitRooms.

I'll bet money you've got a counter somewhere that's racking too high, or trying to call some position that it racks before calling again, or you need a (array.length - 1) catch somewhere.  Lord knows I ran into those.

I was going to say that I'm halfway to a working Open Doors function, but then I realized where all the problems were and fixed them.  Now I have a completely working Open Doors function.  The groundwork has been laid for interacting with the map, and with all that complete, I can move on the next Big Thing.

Making monsters.  And some kind of turnstep function, so the game doesn't advance for some keypresses and does for others.  No sweat.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #553 on: January 14, 2012, 06:17:47 am »

Na, it comes up when I print my room onto my main map, meaning that somewhere a room was made larger than it should have been... Kind of annoying, because as I said, it works for the arrayrooms...

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #554 on: January 14, 2012, 06:36:59 am »

If anybody is interested in just what I am trying to do, basically it starts by making a single large room, as shown
Spoiler (click to show/hide)
That room then splits itself along one of its axis at a random spot, and makes two smaller rooms on either side, with a wall going down the middle.
Spoiler (click to show/hide)
These two rooms then do the exact same thing, split into smaller rooms with another wall between them.
Spoiler (click to show/hide)
Keep going for a few more rooms, until it starts to look a bit like a level.
Spoiler (click to show/hide)
Then each room places a door randomly along its wall. It dosn't matter where the door is placed, because of the room structure each and every room will be accessible.
Spoiler (click to show/hide)
Pages: 1 ... 35 36 [37] 38 39 ... 796