topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Sunday December 15, 2024, 9:10 pm
  • Proudly celebrating 15+ 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 4531 times)

anandcoral

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 783
    • View Profile
    • Free Portable Apps
    • Donate to Member
robots are killing
« on: September 02, 2016, 07:31 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,198
    • View Profile
    • Donate to Member
Re: robots are killing
« Reply #1 on: September 02, 2016, 10:04 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,645
    • View Profile
    • Donate to Member
Re: robots are killing
« Reply #2 on: September 02, 2016, 12:29 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: 243
    • View Profile
    • Donate to Member
Re: robots are killing
« Reply #3 on: September 02, 2016, 12:58 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: 9,778
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: robots are killing
« Reply #4 on: September 02, 2016, 01:06 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: 243
    • View Profile
    • Donate to Member
Re: robots are killing
« Reply #5 on: September 02, 2016, 01:30 PM »
OK, thanks :]