Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 29, 2016, 10:16:16 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: robots are killing  (Read 359 times)

anandcoral

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 395
    • View Profile
    • App, to help you : Overlap Wallpaper, Park Cursor Aside, Stick A Note, Merge CSV and Text and many more.
    • Donate to Member
robots are killing
« on: September 02, 2016, 07:31:06 AM »
I needed a second go through the code to locate the mistake,

http://oppressive-si...ics/oh-no-the-robots

That's why testing code is so important.

phitsc

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 1,186
    • View Profile
    • Donate to Member
Re: robots are killing
« Reply #1 on: September 02, 2016, 10:04:42 AM »
... and using up-to-date compilers with warning level set to max (and treat warnings as errors)

mwb1100

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,515
    • View Profile
    • Donate to Member
Re: robots are killing
« Reply #2 on: September 02, 2016, 12:29:25 PM »
That's why testing code is so important

But if you're building robots you should still let someone else perform the testing - what's in the comic *is* a test run.

ConstanceJill

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 84
    • View Profile
    • Donate to Member
Re: robots are killing
« Reply #3 on: September 02, 2016, 12:58:53 PM »
Huh, can anyone please explain the issue for non-programmers ? :p
(Other than the fact that there actually is a command to kill humans in the code, even if it probably wasn't supposed to be triggered.)

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 7,650
    • View Profile
    • The Blog of Deozaan
    • Read more about this member.
    • Donate to Member
Re: robots are killing
« Reply #4 on: September 02, 2016, 01:06:20 PM »
Huh, can anyone please explain the issue for non-programmers ? :p
(Other than the fact that there actually is a command to kill humans in the code, even if it probably wasn't supposed to be triggered.)

The "if" statement assigns isCrazyMurderingRobot to true, instead of just comparing it to see if it is equal to true. Therefore it will never be false when that code executes, and the robots will never "be_nice_to" humans.

One equal sign (x = true) is an assignment. Two equal signs (x == true) is a comparison. It's a common mistake, even for experienced programmers.


ConstanceJill

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 84
    • View Profile
    • Donate to Member
Re: robots are killing
« Reply #5 on: September 02, 2016, 01:30:24 PM »
OK, thanks :]