[2.1] Expand arithmetic combinator to functions of other arities.

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

everything-narrative
Inserter
Inserter
Posts: 26
Joined: Fri Aug 16, 2019 5:31 pm
Contact:

[2.1] Expand arithmetic combinator to functions of other arities.

Post by everything-narrative »

TL;DR
Add more advanced functions to the arithmetic combinator, with other than two arguments.
What?
Expand the functionality of the arithmetic combinator to have functions with one, two, or three arguments.
  • 1 argument
    Common single argument functions include:
    • negation (-)
    • bitwise not (~ or ¬ or NOT)
    (I know it is very possible to simulate these by multiplication by -1 (or as I prefer, subtracting from zero,) as well as XOR with 4294967295.)
      Rarer single argument functions include:
      • integer square root
      • integer logarithms (base 2 = highest bit set, base 10 = number of digits)
      • bitwise population count (number of bits set)
    • 2 arguments
      Common two-argument functions include:
      • Our current set of arithmetic operators.
      • Greatest common divisor (gcd) and least common multiple (lcm), (which can be efficiently implemented with the Euclidean algorithm internally in the game code.)
      Rarer two argument functions include:
      • Quotient and modulo, as opposed to division and remainder.
        The difference being that the modulo is never negative, and so negative divisors behave differently as seen in the way / and % work in C++ versus Python.
    • 3 arguments
      Common three argument functions include:
      • Clamping: constraining a middle value between two extremes (in the same vein of adding min/max as above.)
      • Arithmetic expressions of three arguments (which could then include the whole list of 2-argument functions.)
      • Modulo addition: again eliminating the need for an extra combinator.
    This would of course require some kind of overhaul of the UI.
    Mockups:
    Negation/bitwise not could be built directly into the fields themselves, a checkbox to negate/invert an input:
    08-17-2026, 15-26-26.png
    08-17-2026, 15-26-26.png (21.32 KiB) Viewed 184 times
    Arguments could be set with a slider:
    08-17-2026, 15-53-05.png
    08-17-2026, 15-53-05.png (29.35 KiB) Viewed 171 times
    Here the "nothing" operator is used just to get the negation of A

    Two arguments would be as usual:
    08-17-2026, 15-54-46.png
    08-17-2026, 15-54-46.png (50.46 KiB) Viewed 171 times
    (The "max" function is from the above mentioned proposal.)

    Three arguments could also include a "nothing" operator that allows a small arithmetic expression:
    08-17-2026, 16-18-42.png
    08-17-2026, 16-18-42.png (70.54 KiB) Viewed 170 times
    (Which would need to clarify that it disregards operator precendence.)
    Why?
    In lieu of the decision combinator being massively upgraded, the arithmetic combinator is now very feature-poor in comparison.
    macdjord
    Fast Inserter
    Fast Inserter
    Posts: 219
    Joined: Fri Feb 22, 2013 4:26 am
    Contact:

    Re: [2.1] Expand arithmetic combinator to functions of other arities.

    Post by macdjord »

    If you're doing this, don't forget to add 'division rounded up'. (Yes, it's possible to do this with the current system with some work, because ceil(x/y) = floor((x+y-1)/y), but having it as its own integral operator would be much more convenient.)
    Post Reply

    Return to “Ideas and Suggestions”