Пример #1
0
        public void Bind()
        {
            // Initialize the InputValues collection with all the names of inputs.

            Vertex.InEdges.ForEach(e => InputValues.Add(ReverseInput(e.Source.Name), null));

            Node.Bind(this);
        }
Пример #2
0
        static void Main(string[] args)
        {
            // Ask user for the range of numbers to loop through
            Console.Write("Enter a starting number: ");
            var start = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter an ending number: ");
            var end = Convert.ToInt32(Console.ReadLine());

            // Allow user to enter as many divisor and corresponding values as they want
            var values = new InputValues();

            while (true)
            {
                Console.Write("Enter multiplier number or type 'Quit' to exit: ");
                var multiNum = Console.ReadLine();
                if (multiNum.ToLower() == "quit")
                {
                    break;
                }

                Console.Write("Enter cooresponding word or type 'Quit' to exit: ");
                var multiWord = Console.ReadLine();
                if (multiWord.ToLower() == "quit")
                {
                    break;
                }

                var multiplier = Convert.ToInt32(multiNum);

                // Add user input values to List<Values>
                values.Add(multiplier, multiWord);
            }

            // Pass range of numbers from user input and Values list
            var range = new Range(start, end, values);

            range.Output();
            Console.ReadLine();



            /*  From phone interview - put FizzBuzz in a separate class */
            //  Console.WriteLine(FizzBuzzing.DoFizzBuzz());
            //  Console.ReadLine();
        }
Пример #3
0
        public SymbolChild(Symbol symbol, Guid childId, Symbol parent)
        {
            Symbol = symbol;
            Id     = childId;
            Parent = parent;

            foreach (var inputDefinition in symbol.InputDefinitions)
            {
                InputValues.Add(inputDefinition.Id, new Input(inputDefinition));
            }

            foreach (var outputDefinition in symbol.OutputDefinitions)
            {
                var outputData = (outputDefinition.OutputDataType != null) ? (Activator.CreateInstance(outputDefinition.OutputDataType) as IOutputData) : null;
                var output     = new Output(outputDefinition, outputData)
                {
                    DirtyFlagTrigger = outputDefinition.DirtyFlagTrigger
                };
                Outputs.Add(outputDefinition.Id, output);
            }
        }
Пример #4
0
 public void AddInput(string name, object value)
 {
     InputValues.Add(name, value.ToString());
 }
Пример #5
0
        /// <summary>
        /// Updates all of the robot's GoalSensors. Called on each simulator tick.
        /// </summary>
        /// <param name="env">The simulator CurrentEnvironment.</param>
        /// <param name="robots">List of other robots in the CurrentEnvironment. Not actually used in this function, only included for inheritance reasons.</param>
        /// <param name="cm">The CurrentEnvironment's collision manager.</param>
        public override void updateSensors(Environment env, List <Robot> robots, CollisionManager cm)
        {
            // Clear out GoalSensors from last time
            InputValues.Clear();
            foreach (Radar r in GoalSensors)
            {
                r.Activation = 0;
            }
            foreach (Radar r in CompassSensors)
            {
                r.Activation = 0;
            }

            // Update regular (target) GoalSensors
            double  angle = 0;
            Point2D temp;

            temp    = new Point2D(env.goal_point.X, env.goal_point.Y);
            temp.X -= (float)AreaOfImpact.Position.X;
            temp.Y -= (float)AreaOfImpact.Position.Y;

            angle  = (float)temp.angle();
            angle -= Heading;
            angle *= 57.297f; // convert radians to degrees

            while (angle > 360)
            {
                angle -= 360;
            }
            while (angle < 0)
            {
                angle += 360;
            }

            foreach (Radar r in GoalSensors)
            {
                // First, check if the Angle is in the wonky pie slice
                if ((angle < 45 || angle >= 315) && r.StartAngle == 315)
                {
                    r.Activation = 1;
                    break;
                }

                // Then check the other pie slices
                else if (angle >= r.StartAngle && angle < r.EndAngle)
                {
                    r.Activation = 1;
                    break;
                }
            }

            // Update the compass/northstar GoalSensors
            // Note: This is trivial compared to rangefinder updates, which check against all walls for collision. No need to gate it to save CPU.
            double northstarangle = Heading;

            northstarangle *= 57.297f; // convert radians to degrees

            while (northstarangle > 360)
            {
                northstarangle -= 360;
            }
            while (northstarangle < 0)
            {
                northstarangle += 360;
            }

            foreach (Radar r in CompassSensors)
            {
                // First, check if the Angle is in the wonky pie slice
                if ((northstarangle < 45 || northstarangle >= 315) && r.StartAngle == 315)
                {
                    r.Activation = 1;
                    break;
                }

                // Then check the other pie slices
                else if (northstarangle >= r.StartAngle && northstarangle < r.EndAngle)
                {
                    r.Activation = 1;
                    break;
                }
            }

            // Update the rangefinders
            foreach (RangeFinder r in WallSensors)
            {
                r.update(env, robots, cm);
            }

            // Update wall sensor inputs
            for (int j = 0; j < WallSensors.Count; j++)
            {
                Inputs[j] = (float)(1 - (WallSensors[j].getActivation()));
                if (Inputs[j] > 1.0)
                {
                    Inputs[j] = 1.0f;
                }
            }

            // Update pie slice sensor inputs
            for (int j = WallSensors.Count; j < WallSensors.Count + GoalSensors.Count; j++)
            {
                Inputs[j] = (float)GoalSensors[j - WallSensors.Count].getActivation();
                if (Inputs[j] > 1.0)
                {
                    Inputs[j] = 1.0f;
                }
            }

            // Update NN inputs based on GoalSensors
            Brain.setInputSignals(ID, Inputs);

            // Make the sensor values accessible to the behavior characterization
            for (int i = 0; i < Inputs.Length; i++)
            {
                InputValues.Add(Inputs[i]);
            }
        }