Friday, March 2, 2012

day 570



The code on the upper left does the same as the code on the upper right, but it is far less efficient, it calls for repetition and many more lines. Knowing more is power, but in code 'less is more.'


.pc

3 comments:

  1. It might be that it's late and I'm not thinking right, but why do you remove the lo and hi scores from the sum and then remove two from the count when computing the average (line 27 of the updated code)? It seems like a simple

    avg = sum/count

    would do the same thing with a couple less operations.

    Good job in this class, though. I'm glad to see they're teaching you C++ and not Java like ISU did (though I did take C++ at ECC before that). You should be able to hack at the code for my game in no time!

    ReplyDelete
  2. We are supposed to remove the highest and lowest scores from the sum and average, is there a better way to do this? And thank you for the compliment, that means a TON coming from you, although I am sure I am a long way from hacking at game code, but hopefully someday.

    ReplyDelete
  3. Okay, it's just a specific instruction to compute the average while excluding those? That makes sense. I don't have a better way to do that, I just didn't understand the requirement.

    Game code probably isn't as arcane as you think, or at least its arcaneness is sufficiently domain-specific to not be taught at any point in a regular programming class. Its incantations can, for the most part, only be picked up by actually hacking at games. I'm sure by the end of this semester you'll be able to understand most of what is going on there.

    ReplyDelete