Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 736 737 [738] 739 740 ... 795

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

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #11055 on: December 12, 2018, 04:12:03 pm »

I think when I was at uni in first year they were teaching people using BlueJ for Java. After that they mostly left you to your own devices for what tools to use.

I switched to Eclipse and then IntelliJ first chance I got. I'll take working autocomplete and automatic importing and the like over a tool that shows you a diagram of the code you just wrote please. But again, I'd already programmed in C++ and C# for about 4 years at that point, so diagram-of-your code may be more useful if uni is your first experience of programming.

Heh, I even had a first year lecturer tell me not to come to his lectures (101 Programming) because after talking to me about personal projects I was working on, he flat out told me "You won't learn anything you don't already know".

Not sure if lecturers are supposed to tell their students that but...well, gave me an extra lie-in xD
Logged

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #11056 on: December 13, 2018, 10:35:28 pm »

Definitely not, attendance is required for credit without exception in most cases, but the only person who would bust you for not attending lecture is your teacher so...

Related: one of my teachers doesn't require attendance in their syllabus, which you're not allowed to tell your students attendance isn't required but the faculty tolerate it for some reason.
« Last Edit: December 13, 2018, 10:37:42 pm by Parsely »
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #11057 on: December 14, 2018, 08:18:41 am »

I still attended the sessions, which were the practical side of it and had exercises that were a part of your grade (although you could do them anytime, not just at the sessions). Usually I finished the exercise in like 5 minutes and spent the rest of the time helping everyone else. But I got to skip the lectures, which is nice since 1 hour of "This is a for loop" would have put me to sleep.

In general they seemed more concerned about attendance for sessions than lectures at my uni. But this is University in England, so other countries and unis may differ.

(Plus they probably cared less since first year doesn't even count to your degree, you just have to pass it.)
« Last Edit: December 14, 2018, 08:28:07 am by MorleyDev »
Logged

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11058 on: December 14, 2018, 08:28:59 am »

Oh come on now. You haven't lived until you've been a TA, and done your darndest to explain what a strange loop is, and why you should avoid it-- or worse, explain how a student's code contains one, when they INSIST it is just a normal For loop. (Or worse, a While loop.)

God help you if they try implementing recurrence/re-entrant loops.

:D  I totally understand recurrence, but have suffered enough PTSD from helping other students with it, that I have cold sweats thinking about it still.  (I've used it successfully many times to walk directory and or data structures, but I just cant help but be reminded of the bizarre output and strange behavior I have seen come out of other peoples code, every time I must employ recursion. Mostly because they did not properly segregate their functions into discrete parts before calling them, but still [others, it's because they dont understand how to NOT use global variables for every damn thing]. At least that PTSD causes me to be extra careful when designing functions that I know must be done re-entrantly.)
« Last Edit: December 14, 2018, 08:36:24 am by wierd »
Logged

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #11059 on: December 14, 2018, 02:13:07 pm »

I still attended the sessions, which were the practical side of it and had exercises that were a part of your grade (although you could do them anytime, not just at the sessions). Usually I finished the exercise in like 5 minutes and spent the rest of the time helping everyone else. But I got to skip the lectures, which is nice since 1 hour of "This is a for loop" would have put me to sleep.

In general they seemed more concerned about attendance for sessions than lectures at my uni. But this is University in England, so other countries and unis may differ.

(Plus they probably cared less since first year doesn't even count to your degree, you just have to pass it.)
I'm assuming that a "session" is the same as what we call "lab" in the USA, where you're working independently on assignments (sometimes being guided through a project by the teacher)? Sometimes labs are open and the students choose to come and other times labs are another course you take for credit that's tied to your lecture course and it may or may not require attendance.

Yeah generally professors don't care if you attend labs in CompSci because you can write code at home.

Oh come on now. You haven't lived until you've been a TA, and done your darndest to explain what a strange loop is, and why you should avoid it-- or worse, explain how a student's code contains one, when they INSIST it is just a normal For loop. (Or worse, a While loop.)

God help you if they try implementing recurrence/re-entrant loops.

:D  I totally understand recurrence, but have suffered enough PTSD from helping other students with it, that I have cold sweats thinking about it still.  (I've used it successfully many times to walk directory and or data structures, but I just cant help but be reminded of the bizarre output and strange behavior I have seen come out of other peoples code, every time I must employ recursion. Mostly because they did not properly segregate their functions into discrete parts before calling them, but still [others, it's because they dont understand how to NOT use global variables for every damn thing]. At least that PTSD causes me to be extra careful when designing functions that I know must be done re-entrantly.)
I find people generally get for loops once you show them the magic of debug mode.

I've always had people get very confused about the association of a class with the object it creates though (and thus not understanding why get() and set() is needed and that it's modifying JUST the instance you call it on) and I remember it kind of blowing my mind for a while too.
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11060 on: December 16, 2018, 03:00:39 am »

So apparently C++ (or at least gcc) delays instantiation of member functions of templates until those member functions are used. Which means even if a member function of a template specialization uses buttloads of member types and functions of a template parameter that don't even goddamn exist gcc will still happily instantiate the template according to the specialization anyway, instead of the general template. Which makes SFINAE not work.

Goddammit this is so annoying.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11061 on: December 16, 2018, 01:26:31 pm »

Oh come on now. You haven't lived until you've been a TA, and done your darndest to explain what a strange loop is, and why you should avoid it-- or worse, explain how a student's code contains one, when they INSIST it is just a normal For loop. (Or worse, a While loop.)

God help you if they try implementing recurrence/re-entrant loops.

:D  I totally understand recurrence, but have suffered enough PTSD from helping other students with it, that I have cold sweats thinking about it still.  (I've used it successfully many times to walk directory and or data structures, but I just cant help but be reminded of the bizarre output and strange behavior I have seen come out of other peoples code, every time I must employ recursion. Mostly because they did not properly segregate their functions into discrete parts before calling them, but still [others, it's because they dont understand how to NOT use global variables for every damn thing]. At least that PTSD causes me to be extra careful when designing functions that I know must be done re-entrantly.)
What is a strange loop?  I might know what it is (I've made some strange loops in my time) but I've never heard the phrase.
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11062 on: December 16, 2018, 02:35:11 pm »

A strange loop is what happens when your code returns to where it started from, instead of reaching the bottom of a parsed hierarchy, or reaching the last index in a for loop and exiting.

It can happen in object oriented code very easily by reinstatiation with an object class, especially if you try to use a global variable instead of a local one for the instantiation.

https://en.m.wikipedia.org/wiki/Strange_loop

It can also happen on UNIX file systems, if people have been stupid with symbolic links, because it will result in an infinitely deep directory tree.
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11063 on: December 16, 2018, 07:20:08 pm »

It can also happen on UNIX file systems, if people have been stupid with symbolic links, because it will result in an infinitely deep directory tree.

It only becomes a problem if people are also stupid with how they implement directory traversal.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11064 on: December 16, 2018, 10:14:20 pm »

True enough. Check if the subdir is symlink, if yes, check if symlink points higher than local context. If yes, stop and tell user they are an idiot. :)
Logged

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #11065 on: December 17, 2018, 12:55:45 am »

Anyone out there familiar with Lua, and if so are they also familiar with Love2D?

I'm learning Lua and the Love2D framework and I'm trying to get this tilemapping example from the Love2D wiki working: https://love2d.org/wiki/Tutorial:Tile-based_Scrolling

If someone can help, I'll post my code and describe my problem.

Edit: Nevermind fixed it. May have issues in the future though!
Spoiler (click to show/hide)
« Last Edit: December 17, 2018, 01:28:11 am by Parsely »
Logged

Kagus

  • Bay Watcher
  • Olive oil. Don't you?
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11066 on: December 17, 2018, 04:28:02 am »

It's not really the same, but SS13 had an issue a while back where you'd stick donk pockets in the microwave to warm up. Donk pockets had a line of code that gave them a couple drops of healing medicine and turned them into "warm" donk pockets upon being heated in a microwave. Warm donk pockets were a subtype of donk pockets.

So, as someone found out, you could just infinitely heat and re-heat the donks, adding an ever-increasing amount of medicine to their composition, until taking a bite would result in a potentially lethal overdose.

This exploit was immediately placed on the "to-do" list.

Eschar

  • Bay Watcher
  • hello
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11067 on: December 17, 2018, 11:35:01 pm »

Augh.

This Python code is supposed to return one iteration of the "4-5 rule" (a mechanism for generating a cave in a roguelike.)

Spoiler (click to show/hide)
Instead, it turns the whole level into floors. No idea why.
« Last Edit: December 17, 2018, 11:41:09 pm by Eschar »
Logged

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11068 on: December 18, 2018, 12:00:19 am »

Augh.

This Python code is supposed to return one iteration of the "4-5 rule" (a mechanism for generating a cave in a roguelike.)

Spoiler (click to show/hide)
Instead, it turns the whole level into floors. No idea why.
You are only checking 4 neighbours of each tile so the number of "wall_rock"s is never going to be 5. Also the index -1 refers to the last element of a list (not sure if this is intended behaviour or not).
« Last Edit: December 18, 2018, 12:04:37 am by RulerOfNothing »
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11069 on: December 18, 2018, 12:19:21 am »

In general, helpful debugging advice is to print everything to the console. print() statements everywhere, for variables, loop indices, function arguments, absolutely everything. If the program crashes at some point, also put print checkpoints everywhere so you know exactly when it crashes. Then you can look through the log, simulating the algorithm in your head (or on paper), and seeing where it goes wrong. Remember, everything -- if you don't know why your program isn't working and you didn't log something, it's probably that.

Make sure to put accurate descriptions before the values, though, so you can see what's what, like so:
Code: [Select]
print("i:", i)

This is a nearly foolproof method to debug anything you want usually by yourself.

Also, try not to delete the log statements, but comment them out instead. Most text editors/IDEs have a keyboard shortcut for this.

EDIT: Additionally, it's worth mentioning that there's a 'logging' module in Python, for finer control of your logging, but I haven't really bothered with it. Good ol' print() statements are quicker and easier to set up.
« Last Edit: December 18, 2018, 12:29:35 am by bloop_bleep »
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.
Pages: 1 ... 736 737 [738] 739 740 ... 795