Esempio n. 1
0
        // Tuple: T1: Entity object, T2: prerequisite count, T3: entry indices
        private SymbolTable CreateSymbolTable()
        {
            var symbolTable = new SymbolTable();

            // Action Node (Leaf Node)

            foreach (var entity in actionList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>());
            }

            foreach (var entity in focusList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>());
            }

            foreach (var entity in triggerList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>());
            }

            // Cmposite Node

            foreach (var entity in randomSelectList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: (from x in entity.children select x.GetHashCode()).ToList());
            }

            foreach (var entity in selectList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: (from x in entity.children select x.GetHashCode()).ToList());
            }

            foreach (var entity in sequenceList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: (from x in entity.children select x.GetHashCode()).ToList());
            }

            // Condition Node

            foreach (var entity in ifList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>()
                {
                    entity.thenChild.GetHashCode()
                });
            }

            foreach (var entity in ifElseList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>()
                {
                    entity.thenChild.GetHashCode(), entity.elseChild.GetHashCode()
                });
            }

            foreach (var entity in untilList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>()
                {
                    entity.thenChild.GetHashCode()
                });
            }

            // Decorate Node

            foreach (var entity in forceFailureList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>()
                {
                    entity.child.GetHashCode()
                });
            }

            foreach (var entity in forceSuccessList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>()
                {
                    entity.child.GetHashCode()
                });
            }

            foreach (var entity in invertList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>()
                {
                    entity.child.GetHashCode()
                });
            }

            foreach (var entity in iterateList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>()
                {
                    entity.child.GetHashCode()
                });
            }

            foreach (var entity in stochasticList)
            {
                symbolTable.AddEntity(
                    key: entity.name.GetHashCode(),
                    entity: entity,
                    children: new List <int>()
                {
                    entity.child.GetHashCode()
                });
            }

            return(symbolTable);
        }