• 0 Posts
  • 21 Comments
Joined 2 years ago
cake
Cake day: June 13th, 2023

help-circle










  • The code in the image is C or C++ or similar. In those languages and languages derived from them, curly braces are optional but the parentheses are required. It should be the other way around to avoid logic errors like this:

    if (some expression)
      doSomething()
    else if (some other expression)
      printf(“some debugging code that’s only here temporarily”);
      doSomethingElse();
    

    Based on the indentation you’d think that doSomethingElse was only meant to run if the else if condition was true, but because of the lack of braces and the printf it actually happens regardless of either of the if conditions. This can sometimes lead to logic errors and it doesn’t hold up to a principle of durability under edit — that is, inserting some code into the if statement changes the outcome entirely because it changes the code path entirely, so the code is in a sense fragile to edits. If the curly braces were required instead of optional, this wouldn’t happen.

    I have all of my linters set up to flag a lack of curly braces in these languages as an error because of this. It’s a topic that sometimes causes some debate, ‘cause some people will vociferously defend their right to not have the braces there for one liners and more compact code, but I have found that in general having them be required consistently has led to fewer issues than having arguments about their absence, but to each their own. I know many big projects that have the opposite stance or have other guidelines, but I just make ‘em required on my own projects or projects that I’m in charge of and be done with it.



  • Any idea how long such a run would take? This kill screen took around 40 minutes I think? I

    ’m not a Tetris community member but I’m interested in the whole ordeal as a gamer in general and programmer, and these sorts of things are interesting as an intersection of the two. I’ve also been playing Tetris since before it even came out on the NES or GameBoy and still play it in various instalments from time to time. I think I have to consider it to be the perfect video game in concept to this day, and seeing it get so much love after all these years is endearing to those of us who remember its beginnings.


  • There’s also one weird level that takes 800 lines to clear as opposed to the usual 10.

    The trick to getting that high regardless will be making sure not to hit the conditions required for the kill screen to occur, like getting a single line on level 155 which didn’t happen here, and somehow making it past all of the potential kill screens to reach 255. I’m not knowledgable in the ways of NES Tetris to know if this is possible but I’m surely interested in finding out. I’ve read various analyses that say it’s theoretically possible and theoretically impossible so it would be nice to see something definitive.