8 Replies - 342 Views - Last Post: 03 February 2011 - 01:34 PM Rate Topic: -----

#1 EvanSchoffstall  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 17
  • Joined: 23-May 10

[Issue] Combat throwing unexpected results

Posted 03 February 2011 - 11:55 AM

I have created a small bit of code for small project I'm working on. Executing the program; I get expected results but, executing the program several times, I receive results that don't even make sense.
I ran the program ten times.

Expected Program Output (8/10)
[Zombie] << Spawns with [2 hp]
[Player] << Spawns with [10 hp]
[Player] << (4 dmg).
[Zombie] dies (2 overkill)


Uncommon Program Output (2/10)
[Player] >> combat
[Zombie] << Spawns with [2 hp]
[Player] << Spawns with [10 hp]
[Player] << (1 dmg).
[Zombie] << (0 hp).
[Zombie] << (2 dmg).
[Player] dies (2 overkill)

The above output is off because "2-1" is not "0" and an if statement is called to return the program "0" when the player's health or zombie's health reaches "0". Also, "10-2" should not kill the player therefore no overkill value.

This post has been edited by EvanSchoffstall: 03 February 2011 - 12:22 PM


Is This A Good Question/Topic? 0
  • +

Replies To: [Issue] Combat throwing unexpected results

#2 eker676  Icon User is offline

  • Software Engineer
  • member icon

Reputation: 378
  • View blog
  • Posts: 1,833
  • Joined: 18-April 09

Re: [Issue] Combat throwing unexpected results

Posted 03 February 2011 - 12:08 PM

Line 38.

You are using single equals '=' not double '=='. Therefore that statement will always be true.
Was This Post Helpful? 1
  • +
  • -

#3 EvanSchoffstall  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 17
  • Joined: 23-May 10

Re: [Issue] Combat throwing unexpected results

Posted 03 February 2011 - 12:13 PM

View Posteker676, on 03 February 2011 - 12:08 PM, said:

Line 38.

You are using single equals '=' not double '=='. Therefore that statement will always be true.


Much thanks!
Was This Post Helpful? 0
  • +
  • -

#4 eker676  Icon User is offline

  • Software Engineer
  • member icon

Reputation: 378
  • View blog
  • Posts: 1,833
  • Joined: 18-April 09

Re: [Issue] Combat throwing unexpected results

Posted 03 February 2011 - 12:15 PM

If you didn't catch the other two.

Line 61 and 85 also have single equals.
Was This Post Helpful? 1
  • +
  • -

#5 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1643
  • View blog
  • Posts: 3,120
  • Joined: 30-May 10

Re: [Issue] Combat throwing unexpected results

Posted 03 February 2011 - 12:34 PM

Yeah, thanks for deleting the code so nobody else can make a contribution.
Was This Post Helpful? 0
  • +
  • -

#6 EvanSchoffstall  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 17
  • Joined: 23-May 10

Re: [Issue] Combat throwing unexpected results

Posted 03 February 2011 - 01:08 PM

View Posteker676, on 03 February 2011 - 12:15 PM, said:

If you didn't catch the other two.

Line 61 and 85 also have single equals.


Yeah saw those.
Was This Post Helpful? 0
  • +
  • -

#7 EvanSchoffstall  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 17
  • Joined: 23-May 10

Re: [Issue] Combat throwing unexpected results

Posted 03 February 2011 - 01:15 PM

View PostSalem_c, on 03 February 2011 - 12:34 PM, said:

Yeah, thanks for deleting the code so nobody else can make a contribution.


Why would anyone WANT to make a contribution? Out of the good of their heart? doubtful. So why would you want this "contribution"? For rep? Most likely.
I removed the source for good reasons. I got my response and was thankful. The issue was done. I don't want my source floating around the internet on dreamincode for scriptkiddies to use in their program. They want it; they have to code it. I'm all for open source, but dreamincode is not a project host or licenses programs. You'll see it on googlecode if you care so much. With that "attitude", I'm sure your looking to "contribute" out of the good of your heart.
Was This Post Helpful? -5
  • +
  • -

#8 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1643
  • View blog
  • Posts: 3,120
  • Joined: 30-May 10

Re: [Issue] Combat throwing unexpected results

Posted 03 February 2011 - 01:23 PM

So how the hell do you know you've got all the advice you could have got?

Oh that's right, you got the answer to your immediate problem and the rest of the code is pretty well damn perfect.
Fuck off.

We see it time and time again, one person spots a problem, makes a mistake in the answer. Someone else comes along, fixes the mistake and finds other issues.

If you're going to run off as soon as you've got the first answer which satisfies your ego trip, then good look to you.
Was This Post Helpful? 0
  • +
  • -

#9 EvanSchoffstall  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 17
  • Joined: 23-May 10

Re: [Issue] Combat throwing unexpected results

Posted 03 February 2011 - 01:34 PM

View PostSalem_c, on 03 February 2011 - 01:23 PM, said:

So how the hell do you know you've got all the advice you could have got?

Oh that's right, you got the answer to your immediate problem and the rest of the code is pretty well damn perfect.
Fuck off.

We see it time and time again, one person spots a problem, makes a mistake in the answer. Someone else comes along, fixes the mistake and finds other issues.

If you're going to run off as soon as you've got the first answer which satisfies your ego trip, then good look to you.


I don't know that I did, but at this point It doesn't matter. Yeah very great service, extremely immediate. No my code is very messy. Sure, he spotted the problem, and the solution worked.
The solution satisfied my code, not my ego? How can a programming langue "satisfy" my ego? Thank you for the good "look".

Quote

then good look to you.

Was This Post Helpful? -2
  • +
  • -

Page 1 of 1