logic blocks: All, NAll, One, NOne, Even, Odd

    NeonSturm

    StormMaker
    Joined
    Dec 31, 2013
    Messages
    5,110
    Reaction score
    617
    • Wired for Logic
    • Thinking Positive
    • Legacy Citizen 5
    Our current And is not really an And element.
    It is a variable number of stacked and elements - what it really is: an "All" element.

    Likewise our Or is not really an Or - it is an "Either" or "One".


    Just the Not is a Not, because it is bugged with multiple inputs.


    Why not just make them be 4 condensed blocks:
    All=And
    NAll=NAnd -- (And->Not)
    One=Or
    NOne=NOr -- (Or->Not)​

    Let players just use either NOne, NAll or Even instead of Not
    • I guess it has almost no performance impact, as Not should rarely gotten used alone.

    And add 2 new:
    Odd (XOR)
    Even (XOR->Not)​


    JavaScript:
        public class Logic_Element
        {
            // ((super.update))
            public int state = 0;
            public LinkedList inputs = new LinkedList();
    
    
            public boolean updating = false;
            private static LinkedList updateElements = new LinkedList();
    
            public void update()
            {
                this.updating = false;
                int state = 0;
                ListIterator li = inputs.listIterator();
                while( li.hasNext() )
                {
                    state = this.process(state, li.next().state)
                }
                if( (state = this.finalProcess(state)) != this.state )
                {
                    this.state = state;
                    if( !this.updating )
                    {
                        this.updating = true
                        updateElements.add( this );
                   }
                }
            }
    
            private int process(int state1, int state2)
            {}
            private int finalProcess(int state)
            {}
        }
    
        public class Logic_All extends Logic_Element
        {
            public int process(int state1, int state2)
            {
                return state1 & state2;
            }
        }
        public class Logic_Nall extends Logic_Element
        {
            public int process(int state1, int state2)
            {
                return state1 & state2;
            }
            public int finalProcess(int state)
            {
                return ~state
            }
        }
        public class Logic_One extends Logic_Element
        {
            public int process(int state1, int state2)
            {
                return state1 | state2;
            }
        }
        public class Logic_None extends Logic_Element
        {
            public int process(int state1, int state2)
            {
                return state1 | state2;
            }
            public int finalProcess(int state)
            {
                return ~state
            }
        }
        public class Logic_Odd extends Logic_Element
        {
            public int process(int state1, int state2)
            {
                return state1 ^ state2;
            }
        }
        public class Logic_Even extends Logic_Element
        {
            public int process(int state1, int state2)
            {
                return state1 ^ state2;
            }
            public int finalProcess(int state)
            {
                return ~state
            }
        }
     
    Last edited:
    Joined
    Jul 21, 2013
    Messages
    2,932
    Reaction score
    460
    • Hardware Store
    1. An AND is per definition not limited to just 2 inputs.
    2. I agree, that we could use NAND and NOR modules.
    3. NOT is used pretty often to negate a single input of a gate. However I think multiple inputs to a single-input gate should always be OR'd automatically IMO
    4. Yes, we need XOR and ODD-Parity modules(since XOR behaves different than ODD-Parity at 3+ inputs)
     

    NeonSturm

    StormMaker
    Joined
    Dec 31, 2013
    Messages
    5,110
    Reaction score
    617
    • Wired for Logic
    • Thinking Positive
    • Legacy Citizen 5
    Maybe I need to clarify:
    ANDs are something like ((A&B) & (C&D)) or (((A&B)&C)&D) - externally one, internally multiple.

    That is why I said it is not really _one_ And or _one_ Or.


    Real logic elements have a fixed number of inputs and outputs.
    • ANDs need to fill unused inputs with a permanent "on"
    • You can't just join 2 outputs together. Maybe you can do it with 2, but with 5 you have 5x the Ampere and may burn something or get wrong results.
    • If you split an output into two, it may have not enough power to supply the following.
     
    Last edited: