doughague / torpy

A command-line arena game.
GNU General Public License v3.0
1 stars 0 forks source link

forf results true/false #12

Closed dday76 closed 10 years ago

dday76 commented 10 years ago

Might figure this one out but I thought I'd post it up since you're around. I hope your day is going well. In the screenshot below you'll see (following each of the two swing commands)

tout << "fightorflight ==> " << w1.forf() << w2.forf() << endl; // test only forf numbers
!w1.forf() ? tout << "1 will defend." << endl : tout << "1 will attack." << endl;
!w2.forf() ? tout << "2 will defend." << endl : tout << "2 will attack." << endl;

From such a result, I would expect to see something like:

fightorflight ==> 10
1 will attack
2 will defend

10 means w1 returned true and w2 returned false, so not true should return defend and not false should return attack (in the if statement). But you see in the screenshot, I get the opposite result. More concerning is in the next swing command, I get 11 - two trues - and different results for an identifical boolean if statement.

Should be very straightforward boolean operations but it's not what I expect.

The question is why in torpy.cxx does do the two if statements starting !w#.forf() return different results for the same outputs of forf()?

image