**Quick Reference Sheet**

Any uppercase letter e.g. "A", "B", "C": A variable or counter, something that has an unknown value in game.

Any lowercase letter e.g. "a", "b", "c": A constant, a value hard-coded in the map.

All division (e.g. "A/B") in this guide and generally in the context of StarCraft should be assumed to be integer division (that is, it by default implies "FLOOR(A/B)") unless otherwise specified or unless wrapped explicitly e.g. "ROUND(A/B)" or "CEILING(A/B)".

Operation Shorthand: Defining what you are doing. You're writing down what you're trying to achieve and maybe using math to simplify or get it closer to something you can do in countoff shorthand.

Countoff Shorthand: Defining how you are doing it. You're writing down something that represents and can be directly converted into triggers.

Note that the same symbol may mean something different in operation shorthand than it does in countoff shorthand, and that neither may perfectly align with what you'd expect from regular mathematics or in programming.

**Operation Shorthand**

% ___________________ "Modulus" finds the remainder from division of the left hand side by the right hand side

= ___________________ The assignment operator (the variable on the left hand side is assigned the value the expression on the right hand side evaluates to)

+= __________________ Adds the value on the right hand side to the value on the left hand side

-= __________________ Subtracts the value on the right hand side from the value on the left hand side

*= __________________ Multiplies the value on the left hand side by the value on the right hand side

/= __________________ Divides the value on the left hand side by the value on the right hand side

%= __________________ Sets the value on the left hand side to the remainder from division of the left hand side by the right hand side

? _______________________________ If the expression on the left evaluates to true, then do the operation on the right

(expression) ? (op1) : (op2) ____ If (expression) evaluates to true, then do (op1), if it evaluates to false, then do (op2)

== __________________ Comparing whether the expression on the left hand side equals the expression on the right hand side

!= __________________ Checks whether the expression on the left hand side is not equal to the expression on the right hand side

>= __________________ Checking whether the expression on the left hand side evaluates to a value greater than or equal to the value the expression on the right hand side evaluates to

<= __________________ Checking whether the expression on the left hand side evaluates to a value less than or equal to the value of expression on the right hand side evaluates to

... = ... A@ ... ____ When the operation is complete A must have the value it had before the operation started

A = B _______________ The value of B gets stored in A, when the operation is complete the value of B is undefined

A = B@ ______________ The value of B gets stored in A, when the operation is complete the value of B is unchanged

A = b*B/C ___________ The value that "b*B/C" evaluates to gets stored in A, when the operation is complete the values of B and C are undefined

A = A

_{31}+ A

_{30}+ ... + A

_{1}+ A

_{0}___ Expansion into conditional bits

A

_{31}is 2

^{31}if A >= 2

^{31}, else A

_{31}is 0

A

_{30}is 2

^{30}if A-A

_{31}>= 2

^{30}, else A

_{30}is 0

A

_{29}is 2

^{29}if A-A

_{31}-A

_{30}>= 2

^{29}, else A

_{29}is 0

... and so on till A

_{0}

**Countoff Shorthand**

__Shorthand________Net Effect____________Wording__A # B ________ B += A, A = 0 _____ "Countoff A into B" (using an unspecified base, usually binary)

A #

^{2}B _______ B += A, A = 0 _____ "Countoff A into B using binary countoffs"

A #

^{3}B _______ B += A, A = 0 _____ "Countoff A into B using ternary countoffs"

A #

^{4}B _______ B += A, A = 0 _____ "Countoff A into B using quaternary countoffs"

A # B,C ______ B += A, C += A, A = 0 _____________________________ "Countoff A into B and C"

A,B # 0 ______ A -= MIN(A, B), B -= MIN(A, B) ____________________ "Countoff A and B to zero"

A,B # C ______ C += MIN(A, B), A -= MIN(A, B), B -= MIN(A, B) ____ "Countoff A and B into C"

A # bB __________ B += b*A, A = 0 _____ "Countoff b times A into B"

aA # B __________ B += A/a, A = 0 _____ "Countoff A over a into B"

aA # bB _________ B += bA/a, A = 0 ____ "Countoff A into B scaled by a and b"

aA # bB,cC ______ B += bA/a, C += cA/a, A = A%a ________________________________________________________ "Countoff A into B and C scaled by a, b, and c"

aA,bB # cC ______ C += c*MIN(A/a, B/b), A -= MIN(A/a, B/b), B -= MIN(A/a, B/b) _________________________ "Countoff A and B into C scaled by a, b, and c"

aA,bB # cC,dD ___ C += c*MIN(A/a, B/b), D += d*MIN(A/a, B/b), A -= MIN(A/a, B/b), B -= MIN(A/a, B/b) ___ "Countoff A and B into C and D scaled by a, b, c, and d"

A # B,C # A ____ B += A ____ "Countoff A into B and C then countoff C into A"

*- If you didn't understand a word on this post, good, that's why I wrote the next 10 posts*

Post has been edited 5 time(s), last time on Aug 23 2019, 3:07 am by jjf28.

TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.