NCB Craziness

Now, you would think that if I have a mďsn's Availability field with the following bit combo:

b100 & b53 & !b666

or, for that matter, only

b100 b53 !b666

That would mean that as long as b100 and b53 are set and b666 isn't, the mission would be available, right?

Nope.

It's always available.

As soon as I take the !b666 out of the field, it's no longer available. Problem is, I need it not to work when !b666.

You'd think that if I had a shďp or përs with its OnAppear field set as:

b16 & !b14 & !b5136

or

b16 !b14 !b5136

Then, so long as all three bits are not set, the ship would not appear, right?

Nope. It appears anyway.

What the hell is going on?

UncleTwitchy, on Aug 21 2005, 09:17 PM, said:

Now, you would think that if I have a mďsn's Availability field with the following bit combo:

b100 & b53 & !b666

or, for that matter, only

b100 b53 !b666

That would mean that as long as b100 and b53 are set and b666 isn't, the mission would be available, right?

Nope.

( )
What the hell is going on?
View Post

Does it work better if you set the following:
(b100 & b53) & !b666
?

I'll find out.

(edit) Yes, yes it does. Hmm. Now, how to configure it when there are multiple negatives.

This post has been edited by UncleTwitchy : 21 August 2005 - 03:00 PM

UncleTwitchy, on Aug 21 2005, 09:46 PM, said:

I'll find out.

(edit) Yes, yes it does. Hmm. Now, how to configure it when there are multiple negatives.
View Post

🙂 Always use that technique. I recommend always putting maximum two things together without using brackets.
Example:

((b911 & b912) | b142) & !((b143 | b913) | b910)) (=> that's also how you do multiple negatives use the "or" operator to your advantage)

Got it. So:
b1 & !(b2 & b3)

is better than

(b1 & !b2) & !b3

But both should work, right?

UncleTwitchy, on Aug 21 2005, 10:25 PM, said:

Got it. So:
b1 & !(b2 & b3)

is better than

(b1 & !b2) & !b3

But both should work, right?
View Post

!(b2 | b3) ("shift" + "alt" + "L" = |, the "or" operator)

If you set "!(b2 & b3)", then the whole expression will evaluate as true every time that b2 and b3 aren't set at the same time.
Think in English:
(b1 & b2) means b1 and b2 have to be set at the same time
(b1 | b2) means either b1 needs to be set, or it's b2 that needs to be set.
Negations:
You don't want b1 nor b2 => !(b1 | b2)
You don't want them both set at the same time => !(b1 & b2)

A good way to understand NCBs is to read Entarus' NCB Guide. Very, very accurate, and it provides all the info you need to make complex expressions.

Mind you, the OR operator | may be found on a key on the PC keyboard, although I'm not sure whether or not it's the same on a mac (it is on my old Performa 5260). Basically, it's on the \ key, which is usually near the carriage return key or the backspace key.

In any case, to figure out the logic of long statements, I find it can help to say them out loud. Unlike the AND and OR operators, the NOT operator is not commutative (because it's not a binary operator). Thus !(A & B) is not the same as !A & !B. When saying it aloud, it becomes "not A and B" while !(A | B) is "not A or B" or "neither A nor B".

You can also use whatsisface's law... his name escapes me at the moment. In any case, the law states:

!A & !B = !(A | B)

And similarly,

!A | !B = !(A & B)

It's simple to prove this by drawing truth tables... and I'm starting to move away from NCB logic and into digital circuit logic (although they are admittledly identical).

One last point, Nova doesn't like trinary (or higher) operators at all, which is why A & B & C doesn't work. Similarly, neither does R(A B C). Which is why Pace instructed you to always bracket them up so that each block never has more than two operands.

Edited to fix the text. I keep forgetting that B) gets rendered as a smiley...

This post has been edited by Belthazar : 21 August 2005 - 04:39 PM

Bel, Mac and PC keyboards are virtually identical. Pace has one of those new-fangled specially-layed-out keyboards, which he insists are better. UT, you'll find it in its usual place by pressing shift+, but I'm betting you already knew that.

So (!A & !B) = !(A | B)

Got it. That actually makes sense.

(Edit) Damned emoticons.

Thanks, guys -- this has cleared up a lot (and I mean a lot ) of problems in SFA.

This post has been edited by UncleTwitchy : 21 August 2005 - 08:50 PM

I dunno if you like arithmetic, but if so here's a way to view Boolean logic (like control bit evaluation strings) as math:

Let X and Y be control bits (like b666 and b123, for instance). Let x and y be the truth values of those control bits. Let 1 mean TRUE and 0 mean FALSE. So if b666 is on, x = 1, and if b123 is off, y = 0.

Now let the operators, &, |, !, and parentheses, () have the following definitions:

AND means Multiply: X & Y = x * y
OR means Add: X | Y = x + y
NOT means take the absolute value of one less than the number: !X = |x-1|
PARENTHESES mean divide what's inside by itself unless it's zero, in which case leave it alone. That is, round down to one or zero.

So, as an example, let's say b1 is true, b2 is false and b3 is false. The string ((b1 & b2) | b3) is to be evaluated. What is the result?

((b1 & b2) | b3)
= ((1 * 0) + 0)
= ((0) + 0)
= (0 + 0)
= (0)
= 0, and 0 means FALSE.

Now let's try ((b1 | b2) | (!b3 & !(b1 & b2))) with the same bit values.

((1 + 0) + (1 * |(1 * 0) - 1|))
= ((1) + (1 * |(0) - 1|))
= (1/1 + (1 * |-1|))
= (1 + (1 * 1))
= (1 + (1))
= (1 + 1/1)
= (1 + 1)
= (2)
= 2/2
= 1, and 1 means TRUE

Obviously there are some shortcuts, such as "If everything is 0 at some point in the arithmetic then the answer is FALSE" and, "If everything's a 1 and there's no subtraction then the answer's TRUE."

Hope this helps.