public void trainingStep(int ability, ref int pass)
        {
            pass++;
            // 1. initiating ability
            state = stAbilityExecuting;

            // storing chosen ability
            LastUsedAbility = ability;
            // storing current input vectors
            LastInputVecs = Cart.makeInputVector();

            // finding the input vector for the top node
            TopNodeInput = new double[Cart.CogTop.InputNum];
            int i;

            for (i = 0; i < Cart.CogTop.InputNum; i++)
            {
                TopNodeInput[i] = MetaNode.getOutput(Cart.CogTop.Children[i], LastInputVecs, pass);
            }
            // now training
            double[] DesiredOutputVec = STANN.mapInt2VectorDouble(ability, 2, Cart.CogTop.stann.OutputNum);

            // training 6 times
            for (i = 0; i < 6; i++)
            {
                Cart.CogTop.stann.backPropagate(TopNodeInput, DesiredOutputVec);
            }

            // executing ability now..
            Cart.useAbility((t_CartAbility)ability);
        }
Пример #2
0
        public void transitionAction(ref System.Windows.Forms.Panel panel,
                                     System.Windows.Forms.TextBox[] texts, ref int pass)
        {
            switch (state)
            {
            case stIdle:     // nothing
                break;

            case stSonarFiring:
                if (Cart.flagSonarArrayFiringDone)
                {
                    Cart.flagSonarArrayFiringDone = false;
                    // changing state
                    state = stSonarDataTransmission;
                    Cart.requestSensorData();
                }
                break;

            case stSonarDataTransmission:
                if (Cart.flagSensorDataAcquired)
                {
                    Cart.fillSonarTextBoxes(texts);

                    state = stFrameTransmission;
                    Cart.retrieveAbstraction();
                }
                break;

            case stFrameTransmission:
                if (Cart.flagAbstractionReady)
                {
                    Cart.drawAbstraction(panel);
                    state = stAbilityExecuting;
                    // running the cognitive array now
                    double[][] inputVecs = Cart.makeInputVector();
                    pass++;
                    int output = (int)MetaNode.getOutput(Cart.CogTop, inputVecs, pass);
                    if (output < 11)
                    {
                        Cart.useAbility((t_CartAbility)output);
                    }
                    else
                    {
                        state = stIdle;
                    }
                }
                break;

            case stAbilityExecuting:
                if (Cart.flagAbilityDone)
                {
                    Cart.flagAbilityDone = false;
                    state = stIdle;
                }
                break;
            }
        }