I Keep Coding Until I Make It

Поделиться
HTML-код
  • Опубликовано: 30 янв 2025

Комментарии • 25

  • @KedrigernGaming
    @KedrigernGaming  2 месяца назад +4

    Disclaimer: Copying code is never good. My mind was elsewhere when doing it, so I did not come up with the proper solution. But when writing the 'no water' function, I should have just added a parameter to the original large function and renamed it. Then, I should have a new function with the original name, which would simply call the new function with 'True' = use water.
    That would be the right way of doing this while still keeping things backward compatible (having a function with the original name that uses water).

    • @electrowizard2000
      @electrowizard2000 2 месяца назад

      Or could have abstracted the watering to be a function that checks the unlock first - but I guess there's inefficiency in checking the unlock every square too!

  • @danser_theplayer01
    @danser_theplayer01 2 месяца назад +1

    19:50 I'm anticipating pumpkins to fail because the check is a NAND when you should have a NOR, it passes if you have OR.
    So if you have planting but no pumpkins a guard return doesn't happen, and the function tries to do something that is not unlocked yet.

    • @Soken50
      @Soken50 2 месяца назад

      That's the opposite, he used a NOR where he'd need a NAND but I'm not gonna fault you for it, Boolean Algebra is confusing and I never get it on the first try either.

    • @KedrigernGaming
      @KedrigernGaming  2 месяца назад +1

      Ooooh yeah, I messed up. But as soon as I saw a comment saying 'you are wrong...NAND...OR' I was like "yeah, you are probably right".
      I agree that this is confusing! My suggestion: Just always split the if statements. Easier to read anyway and these bugs are a nightmare to find and fix. Should have done that here...

    • @danser_theplayer01
      @danser_theplayer01 2 месяца назад

      ​@@Soken50 He used NOT one AND NOT two. That's a negative AND. NOR doesn't fail if only one parameter is NOT, it would be true and the function would return right away. Remember he's using that logic for a guard return.
      Example: ((NOT false) OR (NOT true)) { execute code here because OR returned true on first condition }, now imagine that the false condition is planting and the true condition is pumpkins. On the other hand:
      ((NOT false) AND (NOT true)) { AND is false, move on to next code block }

    • @danser_theplayer01
      @danser_theplayer01 2 месяца назад

      @@KedrigernGaming Splitting makes it very clear, I'm just used to a couple conditions in a row. Especially since in my language it only checks the conditions in order left to right and doesn't keep checking the rest after the first condition that failed.
      I also played a videogame for a while where I made heavy use of logic gates, almost got into making a tiny binary computer, but didn't have the time.

    • @danser_theplayer01
      @danser_theplayer01 2 месяца назад

      @@Soken50 P.s. booleans are indeed confusing for some.

  • @Soken50
    @Soken50 2 месяца назад

    What a productive episode!
    I like your approach of defining a specific function for getting each resource, I went with a generalist Farm(resource) function that could get anything and it ended up a messy web of unlock checks and endless if branches passing around a big dictionary of variables to handle each resource's specificity.
    In retrospect your approach is much more clean and efficient.

    • @KedrigernGaming
      @KedrigernGaming  2 месяца назад

      Thanks :) I mean...I fully understand you going for this approach. I feel my lack of confidence and laziness is what helps me here. I am usually the only person at my job able to accurately make a time estimate on tasks as I NEVER underestimate. Like...so many things go wrong always and I am just counting on it. So what you did would be my thought too probably...but I just knew I wouldn't be able to make it.
      Glad you find this clean! Now let's see if I manage to finish it!

  • @sakkiediereaper
    @sakkiediereaper 2 месяца назад

    Great video! Your videos teach me so much, like how to solve any problem in coding. "If at first you don't succeed, cry CRY again" 😂Love your videos, man

    • @KedrigernGaming
      @KedrigernGaming  2 месяца назад

      Thank you so much!!!
      Yes, sadly that is often the truth. But hopefully in the end there will be tears of joy!

  • @danser_theplayer01
    @danser_theplayer01 2 месяца назад

    Idk about python, but in javascript adding a new argument will just let me call a function with (arg1, undefined) and it will be fine as long as I don't try to work on the second arg.
    I can still ask if (arg2) {} and undefined will automatically be considered falsey. I can even define default assignment to arg2 in case I have code calling this function sometimes with 2 args and sometimes with 1.
    You could try looking if python can handle args defined in function but missing in calls, it will save time on refactoring.

    • @KedrigernGaming
      @KedrigernGaming  2 месяца назад

      Damn, don't think I've heard of that! I don't think it can, but not sure. The closest thing I tried was overloading (two functions, same names, different arguments) - did not work.

    • @danser_theplayer01
      @danser_theplayer01 2 месяца назад

      @@KedrigernGaming my intuition says overloading is not a thing. What language does that anyway? And how? Defining 2 identically named functions in the same scope will overwrite the old one, or most likely complain with an error.

    • @KedrigernGaming
      @KedrigernGaming  2 месяца назад

      C++, C, Java to name just a few. It sounds weird at first but is actually super useful.
      Its useful when you want to have a function do a thing but accept different data types and handle them appropriately (so one has to say convert a string to int and the other does not). But every time you call the same function and the right one gets chosen based on the data types you feed it. So you don't have to do many checks before.
      Or even functions with vs without a parameter where 'no parameter' means 'use the default value, whatever it may be, I don't care'.

    • @danser_theplayer01
      @danser_theplayer01 2 месяца назад

      @@KedrigernGaming Functions with or without parameter (at the call, not at the function) and default value I can understand. But since javascript is not compiled and not strongly typed it would have a hard time using the same-but-different function. So I've never seen that.
      I could manually manage that by writing logic in the function to check the inputs, but not by having two identical functions in the scope (by identical I mean name, js doesn't _really_ see function signature).

  • @RoskoFig
    @RoskoFig 2 месяца назад +1

    This is fire education.

  • @Odod4000
    @Odod4000 2 месяца назад

    farmers in the future be like!

  • @МирасНескажу
    @МирасНескажу 2 месяца назад +1

    1st