1. Welcome to the Brawl website! Feel free to look around our forums. Join our growing community by typing /register in-game!

Technology A little help...

Discussion in 'Off Topic' started by MattM1PVP, May 13, 2016.

Thread Status:
Please be aware that this thread is more than 30 days old. Do not post unless the topic can still be discussed. Read more...
  1. MattM1PVP

    MattM1PVP Ex-HG Staff Member

    Joined:
    May 22, 2015
    Messages:
    2,148
    Ratings:
    +705
    Expressions are written in post-fix form and are case-insensitive. Expressions are composed of three parts:

    1. Numbers - Constant values such as 3, -1, and 0.5
    2. Variables - Dynamic values, represented by letters, such as "n" or "d".
    3. Operators - Perform operations such as +, -, * (multiplication), / (division)
    Syntax

    Syntax is written in post-fix (also known as reverse Polish notation) form. This means the operator comes AFTER the operands.

    There MUST be a space between each number, variable, and operator.

    Mathematics is usually done with in-fix notation—the familiar x + y. In post-fix, this is written x y +. The advantage of this is that there are no grouping symbols and the order of execution is clear. (basically, it's a hell of a lot easier for me to program post-fix evaluation)

    We will try converting some expressions to post-fix from infix:

    1 + 1
    1 1 +

    (a + b) / c
    (a b +) / c
    (a b +) c /
    a b + c /

    (a - b) / c * (d - b) + 15
    (a b -) / c * (d b -) + 15
    ((a b -) c /) * (d b -) + 15
    (((a b -) c /) (d b -) *) + 15
    (((a b -) c /) (d b -) *) 15 +
    a b - c / d b - * 15 +

    So far, we have only looked at binary operations—operations with two operands (numbers). Some operations, such as "abs", or absolute value, have only one operand.

    In standard mathematical notation, we write for "the absolute value of 'a'":

    a
    In ChangeDamage, we use:

    a abs

    The same applies for:

    |a + b|
    |a b +|
    a b + abs

    There is one operation (so far) with no operands: random. This operation creates a random number between 0 and 1, such that 0 < rand < 1, or, alternately, rand ? ]0, 1[.
    The syntax is as follows:

    rand

    For example, to obtain a random number between 0 and 10:

    rand 11 * floor

    Details on numbers

    All numbers are stored as decimals (technical terms: double precision floating point, aka "double") Scientific notation can be used. For example, 2e1 is 20.

    Details on variables

    Variables are treated as numbers that can be modified during evaluation. It is important to note that variables always take precedence over operators, so if a variable is named "x", you will have to use "*" for multiplication.

    Exhaustive list of operations

    Zero operands:

    • Random number: random, rand, r
    One operand:

    • Absolute value: abs
    • Round down/Floor: floor, fl
    • Round: round, rd
    • Round up/Ceiling: ceiling, ceil
    Two operands:

    • Addition: +
    • Subtraction: -
    • Multiplication: *, x
    • Division: /
    • Bitwise left shift: <<
    • Bitwise right shift (unsigned): >>
    • Bitwise right shift (signed): >>>

    If anyone understands this, can someone help me deduce the original equation of these statements?

    expression:
    critical: i i 2 / 2 + rand * fl +
    weakness: i 2 w << -
    strength: i 3 s << +
     
  2. williamthegreat

    Joined:
    Jun 13, 2015
    Messages:
    2
    Ratings:
    +0
  3. Phanta

    Phanta Well-Known Member

    Joined:
    Jan 1, 2014
    Messages:
    2,555
    Ratings:
    +997
    Code:
    critical: i i 2 / 2 + rand * fl +
    i i 2 / 2 + rand * fl +
    i (i / 2) 2 + rand * fl +
    i ((i / 2) + 2) rand * fl +
    i (((i / 2) + 2) * rand) fl +
    i floor(((i / 2) + 2) * rand) +
    floor (((i / 2) + 2) * rand) + i
    Code:
    weakness: i 2 w << -
    i 2 w << -
    i (2 << w) -
    i - (2 << w)
    i - (2 * 2^w)
    Code:
    strength: i 3 s << +
    i 3 s << +
    i (3 << s) +
    i + (3 << s)
    i + (3 * 2^s)
     
  4. MattM1PVP

    MattM1PVP Ex-HG Staff Member

    Joined:
    May 22, 2015
    Messages:
    2,148
    Ratings:
    +705
    Thanks!
     
Loading...
Similar Threads Forum Date
Little help Raid Jun 4, 2018
Something to help the community a little. Discussion May 14, 2017
Little tip that will help most games. Guides Aug 29, 2015
Technology A little bit of help D: Off Topic Apr 7, 2015
A little help... Q & A Jan 1, 2015
Thread Status:
Please be aware that this thread is more than 30 days old. Do not post unless the topic can still be discussed. Read more...