Exemple #1
0
        /// <summary>
        /// Called when the user releases a key or button
        /// </summary>
        /// <param name="input">The input function pressed</param>
        /// <param name="direction">The direction associated with the input,
        /// if applicable.</param>
        public override void InputRelease(InputFunction input, Vector direction)
        {
            base.InputRelease(input, direction);
            Element controlled = Controlled;

            if (controlled != null && controlled == Active)
            {
                var aA = controlled.GetData <AvailableActions>();

                GameAction action = null;

                if (direction.IsValidNonZero())
                {
                    //Find targeted cell:
                    MapData mD = controlled.GetData <MapData>();
                    if (mD != null && mD.MapCell != null)
                    {
                        MapCell newCell = Stage.Map.AdjacentCell(mD.MapCell.Index, direction);
                        action = aA.ActionForInput(input, newCell.Index);
                    }
                }

                // Haven't found a targeted action; fallback to:
                if (action == null)
                {
                    action = aA.ActionForInput(input);
                }
                if (action != null)
                {
                    action.Enact(Log, new EffectContext(controlled, this, direction));
                    EndTurnOf(controlled);
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Creates an instance of Neuron with default settings: weighted sum input function
 /// and Step transfer function. This is the basic McCulloch-Pitts neuron model.
 /// </summary>
 public Neuron()
 {
     this.inputFunction    = new WeightedSum();
     this.transferFunction = new Step();
     this.inputConnections = new List <Connection>();
     this.outConnections   = new List <Connection>();
 }
    public void OnClick()
    {
        InputFunction function = InputFunction.Undefined;
        EquipmentSlot slot     = this.gameObject.GetBindingDataContext() as EquipmentSlot;

        GameEngine.Instance.Input.InputRelease(slot.HotKey);
    }
Exemple #4
0
 public void registerFunction(InputFunction func, InputType type)
 {
     if (inputMap == null)
     {
         inputMap = new Dictionary <InputType, InputFunction>();
     }
     inputMap.Add(type, func);
 }
Exemple #5
0
 public double CalculateOutput()
 {
     if (Inputs.Count == 0)
     {
         return(InputValue);
     }
     InputValue  = InputFunction.CalculateInput(Inputs);     //liczone wejscie za pomoca danych wyjsciowych z poprzedniego neurona i funkcji Input
     OutputValue = ActivationFunction.Calculate(InputValue); // liczone wyjscie za pomocja danych wejsciowych i funkcji aktywacyjnej
     return(OutputValue);
 }
Exemple #6
0
        /// <summary>
        /// Возвращает значения численного решения дифференциального уравнения, полученные модифицированным методом Эйлера
        /// </summary>
        public static IEnumerable <(double x, double y)> GetModifiedEuler(InputFunction f, double x0, double y0, double h, int count)
        {
            for (var i = 0; i < count; i++)
            {
                yield return(x0, y0);

                y0 += h * f(x0 + h / 2, y0 + h / 2 * f(x0, y0));
                x0 += h;
            }
        }
Exemple #7
0
        public IOFunctionEventArgs(OutputFunction Out1, OutputFunction Out2, OutputFunction Out3, OutputFunction Out4, InputFunction In1, InputFunction In2)
        {
            _out1 = Out1;
            _out2 = Out2;
            _out3 = Out3;
            _out4 = Out4;

            _in1 = In1;
            _in2 = In2;
        }
Exemple #8
0
        public T Return()
        {
            var materializedParameters = new List <object>();

            foreach (var inputParam in InputParameters)
            {
                materializedParameters.Add(inputParam.DynamicInvoke());
            }

            return((T)InputFunction.DynamicInvoke(materializedParameters.ToArray()));
        }
Exemple #9
0
        public void TestToUpperFunction()
        {
            // Invoke the lambda function and confirm the string was upper cased.
            var function = new InputFunction();
            var context  = new TestLambdaContext();
            var response = function.FunctionHandler(new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest {
                Body = "hello world"
            }, context).Result;

            Assert.Equal("HELLO WORLD", response.Body);
        }
Exemple #10
0
 public double CalculateOutput()
 {
     //For first layer neurons (they don't have any inputs) we don't calculate output
     if (Inputs.Count == 0)
     {
         return(InputValue);
     }
     InputValue  = InputFunction.Calculate(Inputs);
     OutputValue = ActivationFunction.Calculate(InputValue);
     return(OutputValue);
 }
 public UtilityConsideration(CurveTypes curve, Vector2 bookends, InputFunction inputFunc, float M, float D, float K, float P, float C)
 {
     CurveType = curve;
     Bookends  = bookends;
     GetInput  = inputFunc;
     m         = M;
     d         = D;
     k         = K;
     p         = P;
     c         = C;
 }
Exemple #12
0
        private static IBooleanFunction GetInputSignFunction(InputSign inputSign)
        {
            IBooleanFunction inputFunction = new InputFunction(inputSign.Index);

            if (inputSign.IsInversed)
            {
                inputFunction = new NotFunction(inputFunction);
            }

            return(inputFunction);
        }
Exemple #13
0
 public double CalculateOutPut()
 {
     //Pierwsza warstwa neuronow nie ma informacji na wejsciu, wiec nie liczymy informacji na wyjsciu
     if (Inputs.Count == 0)
     {
         return(InputValue);
     }
     //wejscie liczymy używajać danych wyjściowych z poprzedniego neurona i funkcji Input
     InputValue = InputFunction.CalculateInput(Inputs);
     //wyjście liczymy używajać danych wejściowych i funkcji Aktywacyjnej
     OutputValue = ActivationFunction.CalculateOutput(InputValue);
     return(OutputValue);
 }
Exemple #14
0
        /// <summary>
        /// Gets the input and output functions. Used in instances of the enums 'OutputFunction', 'InputFunction'.
        /// Triggers the event to commit the values (output, input functions) to the eventHandler in GuiSimpleForm.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            OutputFunction Out1 = (OutputFunction)checkedListOutputIO1.SelectedIndex;
            OutputFunction Out2 = (OutputFunction)checkedListOutputIO2.SelectedIndex;
            OutputFunction Out3 = (OutputFunction)checkedListOutputIO3.SelectedIndex;
            OutputFunction Out4 = (OutputFunction)checkedListOutputIO4.SelectedIndex;

            InputFunction In1 = (InputFunction)checkedListInputIO1.SelectedIndex;
            InputFunction In2 = (InputFunction)checkedListInputIO2.SelectedIndex;

            ReadButtonClicked_IOFunctions.Invoke(this, new IOFunctionEventArgs(Out1, Out2, Out3, Out4, In1, In2));

            this.Close();
        }
Exemple #15
0
    //移動を試みる関数(abstractの上書き)
    protected override void TryToMove()
    {
        //移動方向の検知
        moveDirection.x = (int)InputFunction.GetAxisRaw("Horizontal");
        moveDirection.y = (int)InputFunction.GetAxisRaw("Vertical");

        //左右同時押しなどでmoveDirection.x,yがともに0であれば、ここでreturnする
        if (moveDirection.x == 0 && moveDirection.y == 0)
        {
            return;
        }

        //shiftが押されているのであれば、斜め方向にしか向く(移動)することができない
        if (InputFunction.GetKey("LeftShift") && (moveDirection.x == 0 || moveDirection.y == 0))
        {
            return;
        }

        //自機ユニットの向きを変える(この時点では振る舞いをしたことにならない)
        if (moveDirection.x != 0 || moveDirection.y != 0)
        {
            //faceDirectionにmoveDirectionを代入する
            faceDirection = moveDirection;

            //子要素のコンポーネントarrowAnimatorの変数にfaceDirectionを代入する
            arrowAnimator.SetFloat("faceDirectionX", faceDirection.x);
            arrowAnimator.SetFloat("faceDirectionY", faceDirection.y);
        }

        //spaceが押されている場合は移動することができない(振る舞いをしていない判定で戻り値を返す)
        if (InputFunction.GetKey("LeftControl"))
        {
            return;
        }

        //ユニットが移動可能かを判定する(障害物がないかのチェック)
        canMove = CheckCanMove();
        if (canMove == true)
        {
            //Unitの当たり判定を先んじて移動先にずらしておく(こうしないと次のUnitと移動先がかぶることがある)
            boxCollider2D.offset = moveDirection;

            //振る舞い予定をmoveにする
            scheduledBehavior = ScheduledBehavior.Move;
        }
    }
Exemple #16
0
        /// <summary>
        /// Creates an instance of Neuron with the specified input and transfer functions.
        /// </summary>
        /// <param name="inputFunction">    input function for this neuron </param>
        /// <param name="transferFunction"> transfer function for this neuron </param>
        public Neuron(InputFunction inputFunction, TransferFunction transferFunction)
        {
            if (inputFunction == null)
            {
                throw new System.ArgumentException("Input function cannot be null!");
            }

            if (transferFunction == null)
            {
                throw new System.ArgumentException("Transfer function cannot be null!");
            }

            this.inputFunction    = inputFunction;
            this.transferFunction = transferFunction;
            this.inputConnections = new List <Connection>();
            this.outConnections   = new List <Connection>();
        }
    bool BothInputPerformed(InputFunction func)
    {
        switch (func.Method.Name)
        {
        case "GetPressDown":
            return(gripOrTriggerPressed);

        case "GetPress":
            return(gripOrTriggerHeld);

        case "GetPressUp":
            return(!gripOrTriggerHeld);

        default:
            return(false);
        }
    }
    bool InputPerformed(ViveInput input, InputFunction func)
    {
        switch (input)
        {
        case ViveInput.Grip:
            return(func(ButtonMaskFor(ViveInput.Grip)));

        case ViveInput.Trigger:
            return(func(ButtonMaskFor(ViveInput.Trigger)));

        case ViveInput.Both:
            return(BothInputPerformed(func));

        case ViveInput.None:
        default:
            return(false);
        }
    }
Exemple #19
0
    //移動可能かどうかを判定し、真偽値を返す関数
    //protected bool CheckCanMove() => Unit.CheckCanMove()を継承

    //ユニットの連続的な移動を始める関数
    //public void StartUnitMovement() => Unit.StartUnitMovement()を継承

    //ユニットを連続的に移動させる反復処理関数
    //protected IEnumerator MoveSmoothly() => Unit.MoveSmoothly()を継承

    //移動を試みる関数
    protected override void TryToAttack()
    {
        //攻撃ボタン"z"が押されていたら攻撃
        if (InputFunction.GetKey("Z"))
        {
            attackType = AttackType.Punch;
        }
        else
        {
            return;
        }

        //振る舞い予定を攻撃にする
        scheduledBehavior = ScheduledBehavior.Attack;

        //攻撃を発射する
        LaunchAttack();
    }
Exemple #20
0
        public IFlow <TResult> Call <TResult>(Func <T, TResult> doSomething)
        {
            return(FlowFactory.Create <TResult>(
                       doSomething,
                       new Delegate[]
            {
                new Func <object>(() =>
                {
                    var materializedParameters = new List <object>();
                    foreach (var inputParam in InputParameters)
                    {
                        materializedParameters.Add(inputParam.DynamicInvoke());
                    }

                    return InputFunction.DynamicInvoke(materializedParameters.ToArray());
                })
            },
                       _parameters));
        }
Exemple #21
0
        private static InputFunction createInputFunction(System.Type inputFunctionClass)
        {
            InputFunction inputFunction = null;

            try
            {
                inputFunction = (InputFunction)inputFunctionClass.GetConstructor(new System.Type[] { }).Invoke(new object[] { });
            }
            catch (java.lang.InstantiationException e)
            {
                throw new NeurophException("InstantiationException while creating InputFunction!", e);
            }
            catch (java.lang.IllegalAccessException e)
            {
                throw new NeurophException("IllegalAccessException while creating InputFunction!", e);
            }

            return(inputFunction);
        }
Exemple #22
0
        /// <summary>
        /// Get the vector which indicates the direction associated with this input
        /// (if any)
        /// </summary>
        /// <param name="iF"></param>
        /// <returns></returns>
        public static Vector DirectionVector(this InputFunction iF)
        {
            switch (iF)
            {
            case InputFunction.Up:
                return(new Vector(0, 1));

            case InputFunction.Down:
                return(new Vector(0, -1));

            case InputFunction.Left:
                return(new Vector(-1, 0));

            case InputFunction.Right:
                return(new Vector(1, 0));

            default:
                return(Vector.Unset);
            }
        }
        private void DrawCurve(InputFunction fx, double from, double to)
        {
            var model = new PlotModel {
                Title = "Wykres funkcji f(x)"
            };

            var a = new AreaSeries();

            a.Fill = OxyColor.FromArgb(200, 45, 185, 82);
            for (double x = from; x <= to + (0.1 * 0.5); x += 0.1)
            {
                a.Points.Add(new DataPoint(x, fx.F(x)));
            }
            a.Color2 = OxyColor.FromArgb(0, 0, 0, 0);
            model.Series.Add(a);
            var distanceBetweenPoints = Math.Abs(to - from);
            var fs = new FunctionSeries(fx.F, from - ((distanceBetweenPoints * 20) / 100), to + ((distanceBetweenPoints * 20) / 100), 0.1, "f(x)");

            model.Series.Add(fs);
            CurveView.Model = model;
        }
Exemple #24
0
    //自機ユニットの振る舞いを決定する関数(abstractの上書き)
    public override void DecideBehavior()
    {
        //scheduledBehaviorを未定の状態にする
        scheduledBehavior = ScheduledBehavior.NotDecided;

        //もしキー入力がされていなかったらすぐにreturnする
        if (InputFunction.AnyKey() == false)
        {
            return;
        }


        //もしコマンドウィンドウが表示されている場合
        if (GameManager.commandWindowIsDisplaying == true)
        {
        }
        //そうでない場合
        else
        {
            //pが押された場合パスし、振る舞い予定をパスにする
            if (InputFunction.GetKey("P"))
            {
                scheduledBehavior = ScheduledBehavior.Pass;
            }

            //まずは移動判定を検知する。移動可能であれば振る舞い予定を移動にする。
            if (scheduledBehavior == ScheduledBehavior.NotDecided)
            {
                TryToMove();
            }

            //次に攻撃判定を検知する。攻撃後、振る舞い予定を攻撃にする
            if (scheduledBehavior == ScheduledBehavior.NotDecided)
            {
                TryToAttack();
            }
        }
    }
Exemple #25
0
    /* Used to translate the parameter of the input function to the SteamVR button equivalent */
    bool InputPerformed(ArrayList inputButton, InputFunction function)
    {
        if (inputButton.Count == 0)
        {
            return(false);
        }
        else if (inputButton.Count == 1)
        {
            return(function(ButtonMask((InputButton)inputButton[0])));
        }
        else
        {
            for (int i = 0; i < inputButton.Count; i++)
            {
                if (function(ButtonMask((InputButton)inputButton[i])))
                {
                    return(true);
                }
            }

            return(false);
        }
    }
Exemple #26
0
        private InputFunction IntToInputFunction(int inputMode)
        {
            InputFunction _result = InputFunction.Off;

            switch (inputMode)
            {
            case 0: _result = InputFunction.Off; break;

            case 1: _result = InputFunction.Tare; break;

            case 2: _result = InputFunction.Trigger; break;

            case 4: _result = InputFunction.BreakFilling; break;

            case 5: _result = InputFunction.RunFilling; break;

            case 6: _result = InputFunction.Redosing; break;

            case 7: _result = InputFunction.RecordWeight; break;

            case 8: _result = InputFunction.Zero; break;
            }
            return(_result);
        }
Exemple #27
0
        private int InputFunctionToInt(InputFunction inputMode)
        {
            int _result = 0;

            switch (inputMode)
            {
            case InputFunction.Off: _result = 0; break;

            case InputFunction.Tare: _result = 1; break;

            case InputFunction.Trigger: _result = 2; break;

            case InputFunction.BreakFilling: _result = 4; break;

            case InputFunction.RunFilling: _result = 5; break;

            case InputFunction.Redosing: _result = 6; break;

            case InputFunction.RecordWeight: _result = 7; break;

            case InputFunction.Zero: _result = 8; break;
            }
            return(_result);
        }
 /// <summary>
 /// Creates an instance of CompetitiveNeuron with specified input and transfer functions </summary>
 /// <param name="inputFunction"> neuron input function </param>
 /// <param name="transferFunction"> neuron ransfer function </param>
 public CompetitiveNeuron(InputFunction inputFunction, TransferFunction transferFunction) : base(inputFunction, transferFunction)
 {
     connectionsFromOtherLayers = new List <Connection>();
     connectionsFromThisLayer   = new List <Connection>();
     addInputConnection(this, 1);
 }
Exemple #29
0
 /// <summary>
 /// Creates a new equipment slot with the specified name, hotkey and starting item
 /// </summary>
 /// <param name="hotKey"></param>
 /// <param name="item"></param>
 public EquipmentSlot(string name, InputFunction hotKey, Element item = null) : base(name)
 {
     HotKey = hotKey;
     Item   = item;
 }
Exemple #30
0
 public WindUpAction(ActionFactory actionFactory, InputFunction input) : this(actionFactory)
 {
     Trigger = new ActionInputTrigger(input);
 }