Example #1
0
    public bool validate(IOrganismo memoryContainer)
{
    if (memoryContainer == null)
    {
        memoryContainer = this;
    }
    int memorySize2 = getMemorySize();
    memorySize2 = CONSTS.validateMemorySize(parent(), memorySize2);
    if (memorySize2 == 0)
    {
        parent().criticalError();
        return false;
    }
    bool hasMal = false;
    bool hasDivide = false;

    bool hasRequireTemplate = false;

    int sp = sp();
    int i = 0;
    int step = 1;
    while (i < memorySize2)
    {
        Instruction inst = memoryContainer.getInstructionAt(sp + i);
        if (inst != null)
        {
            step = inst.getStep();
            if ((inst instanceof MalInstruction)

                        || (inst instanceof ConnectInstruction)) {
                hasMal = true;
            }
            if ((inst instanceof DivideInstruction)

                        || (inst instanceof DisconnectInstruction)) {
                hasDivide = true;
            }
            if (inst.requiresTemplate())
            {
                hasRequireTemplate = true;
            }
        }
        else
        {
            step = 1;
        }
        i += step;
    }

    if (!hasMal || !hasDivide)
    {
        return false;
    }
    else
    {
        addFitness();
        return true;
    }

}
Example #2
0
        public String debugInfo()
        {
            String s = "Stack: ";

            for (int i = 0; i < pos; i++)
            {
                s += CONSTS.numberFormat(stack[i]) + " | ";
            }
            return(s);
        }
Example #3
0
        public string debugInfo(string prefix)
        {
            string saida = prefix + " = ";

            for (int i = 0; i < CONSTS.REGISTRADORES; i++)
            {
                saida += CONSTS.getLetter(i) + "X:"
                        + CONSTS.numberFormat(getReg(i)) + " ";
            }
            saida += "SP:" + CONSTS.numberFormat(sp()) + " IP:"
                    + CONSTS.numberFormat(ip) + " E:" + ((int)_error)
                    + " ID:" + id;
            if (_child != null)
            {
                saida += " (Child:" + _child.id + " size:"
                        + CONSTS.numberFormat(_child.getMemorySize()) + " )";
            }

            saida += "\n#" + stacks.debugInfo();
            return saida;
        }
Example #4
0
    public void setCurrStack(int to)
{
    currStack = CONSTS.calcIndex(to, CONSTS.STACKS);

}