Beispiel #1
0
        /**
         * Does the computation
         */
        protected override void SolveRabbitInstance(IGH_DataAccess DA)
        {
            /*
             * //Get the evolution rules of the cell
             * List<GH_ObjectWrapper> EvolutionRulesWrapper = new List<GH_ObjectWrapper>();
             * DA.GetDataList(0, EvolutionRulesWrapper);//param index, place holder
             *
             * //init the list of evolution rules:
             * List<CellularRule> EvolutionRules = new List<CellularRule>();
             * foreach (GH_ObjectWrapper EvolutionRuleWrapper in EvolutionRulesWrapper)
             *  EvolutionRules.Add((CellularRule)EvolutionRuleWrapper.Value);
             */

            //get the inputs
            List <int> bornRuleNeighbors = new List <int>();

            DA.GetDataList <int>(0, bornRuleNeighbors);//param index, place holder
            List <int> survuveRuleNeighbors = new List <int>();

            DA.GetDataList <int>(1, survuveRuleNeighbors);//param index, place holder

            if (bornRuleNeighbors.Count == 0 && survuveRuleNeighbors.Count == 0)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Unsufficient evolution rules: At least one rule should be defined.");
                return;
            }
            //----------------------------------------------------------------------
            //init the list of evolution rules:
            List <CellularRule> EvolutionRules = new List <CellularRule>();

            //init the Born Rules(if any)
            if (bornRuleNeighbors.Count > 0)
            {
                //creates the Evolution Rule:
                BornRule bornRule = new BornRule(bornRuleNeighbors);
                EvolutionRules.Add(bornRule);
            }

            //Init the Survive Rules(if any)
            if (survuveRuleNeighbors.Count > 0)
            {
                //creates the Evolution Rule:
                SurviveRule surviveRule = new SurviveRule(survuveRuleNeighbors);
                EvolutionRules.Add(surviveRule);
            }

            //Create the Life-Like Cell Prototype
            CellState    ghAliveState = new GH_CellState(new GH_Boolean(true));
            CellState    ghDeadState  = new GH_CellState(new GH_Boolean(false));
            LifeLikeCell prototype    = new LifeLikeCell(-1, ghAliveState, ghDeadState, EvolutionRules);

            //set the output parameters
            DA.SetData(0, prototype);
        }
Beispiel #2
0
        /**
         * Does the computation
         */
        protected override void SolveRabbitInstance(IGH_DataAccess DA)
        {
            List <int> livingNeighborsRequirements = new List <int>();

            //get the input parameters
            DA.GetDataList <int>(0, livingNeighborsRequirements);//param index, place holder

            //creates the Evolution Rule:
            BornRule BornRule = new BornRule(livingNeighborsRequirements);

            //set the output parameters
            DA.SetData(0, BornRule);
        }