Beispiel #1
0
        private static string bash(string cmdString, OUTPUT output = OUTPUT.GET_OUTPUT)
        {
            ProcessStartInfo processStartInfo = new ProcessStartInfo();

            processStartInfo.FileName  = "/bin/bash";
            processStartInfo.Arguments = $"-c \"{cmdString}\"";
            if (output == OUTPUT.GET_ERROR)
            {
                processStartInfo.RedirectStandardError = true;
            }
            else
            {
                processStartInfo.RedirectStandardOutput = true;
            }
            processStartInfo.UseShellExecute = false;
            processStartInfo.CreateNoWindow  = true;

            Process process = Process.Start(processStartInfo);
            string  result;

            if (output == OUTPUT.GET_ERROR)
            {
                result = process.StandardError.ReadToEnd();
            }
            else
            {
                result = process.StandardOutput.ReadToEnd();
            }
            process.WaitForExit();
            return(result);
        }
Beispiel #2
0
        public void AddData(InputData input, OUTPUT output)
        {
            StringBuilder s = new StringBuilder();

            s.Append("[");

            int c = 0;

            foreach (var item in input._Input)
            {
                switch ((INPUT)c)
                {
                case INPUT.ES_STAND:
                case INPUT.MS_STAND:
                case INPUT.MS_STAND2:
                case INPUT.MS_STAND3:
                    s.Append("[");
                    s.Append(item.ToString());
                    break;

                case INPUT.ES_DODGE:
                case INPUT.MS_DODGE:
                case INPUT.MS_DODGE2:
                case INPUT.MS_DODGE3:
                    s.Append(item.ToString());
                    s.Append("]");

                    break;

                default:
                    s.Append(item.ToString());
                    break;
                }
                c++;
            }

            s.Append("] [");

            s.Append(output.ToString());



            s.Append("]");


            _form.listBox1.Items.Insert(0, s.ToString());


            KLearnData data = new KLearnData();

            data._Input  = input._Input;
            data._Symbol = output.ToString();

            _Learning.Run(data);
        }
Beispiel #3
0
        public OUTPUT GetNextAction(InputData input)
        {
            string strOutPut = _Learning.Estimate(input._Input);

            if (strOutPut == null)
            {
                return(OUTPUT.STAND);
            }
            OUTPUT output = (OUTPUT)Enum.Parse(typeof(OUTPUT), strOutPut);

            return(output);
        }
 public override void Dispose()
 {
     try
     {
         if (_upto > 0)
         {
             // NOTE: entries in the block after current upto are
             // invalid
             FlushBlock();
         }
     }
     finally
     {
         OUTPUT.Dispose();
     }
 }
Beispiel #5
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);



            if (CombatSprite.GetcurrentAnimation() != null && CombatSprite.GetcurrentAnimation().IsLoop == false)
            {
                if (CombatSprite.IsPlaybackComplete == false)
                {
                    return;
                }

                State = RolePlayingGameData.Character.CharacterState.Idle;
            }


            switch (State)
            {
            case RolePlayingGameData.Character.CharacterState.Walking:
            case RolePlayingGameData.Character.CharacterState.Idle:


                WindowsGame2.AI.InputData input = GetInputData();

                _CurAIState = MyLearning.I.GetNextAction(input);

                break;
            }


            switch (_CurAIState)
            {
            case OUTPUT.STAND:
                State = RolePlayingGameData.Character.CharacterState.Idle;

                break;

            case OUTPUT.ATTACK:
                State = RolePlayingGameData.Character.CharacterState.Attack;
                break;

            case OUTPUT.FAR:
                break;
            }
        }
Beispiel #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.rbPrinter.Checked)
            {
                this.output = OUTPUT.PRINTER;
            }
            else if (this.rbScreen.Checked)
            {
                this.output = OUTPUT.SCREEN;
            }
            else if (this.rbFile.Checked)
            {
                this.output = OUTPUT.FILE;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Beispiel #7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.rbPrinter.Checked)
            {
                this.output = OUTPUT.PRINTER;
            }
            else if (this.rbScreen.Checked)
            {
                this.output = OUTPUT.SCREEN;
            }
            else if (this.rbFile.Checked)
            {
                this.output = OUTPUT.FILE;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Beispiel #8
0
        /// <summary>
        /// Writes the output in Logisim format
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="output"></param>
        private void addOutput(OUTPUT output)
        {
            writer.WriteStartElement("comp");

            // Declare that it's a Pin
            writer.WriteAttributeString("lib", "0");
            writeElementLocation(output);
            writer.WriteAttributeString("name", "Pin");

            writeElementName(output.Name);
            writeOrientation(180); // Orientation defaults to West for output.

            // Declare that it's an output
            writer.WriteStartElement("a");
            writer.WriteAttributeString("name", "output");
            writer.WriteAttributeString("val", "true");
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            this.dealer_from = this.txtFrom.Text;
            this.dealer_to   = this.txtTo.Text;
            this.condition   = this.txtCond.Text;
            if (this.rbScreen.Checked)
            {
                this.output = OUTPUT.SCREEN;
            }
            else if (this.rbPrinter.Checked)
            {
                this.output = OUTPUT.PRINTER;
            }
            else if (this.rbFile.Checked)
            {
                this.output = OUTPUT.FILE;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Beispiel #10
0
        public override void Dispose()
        {
            try
            {
                if (_hitExcDuringWrite)
                {
                    return;
                }

                // stuff 0s in until the "real" data is flushed:
                var stuffed = 0;
                while (_upto > stuffed)
                {
                    _upto -= Add(0) - 1;
                    Debug.Assert(_upto >= 0);
                    stuffed += 1;
                }
            }
            finally
            {
                OUTPUT.Dispose();
            }
        }
Beispiel #11
0
        public void AddData(InputData input,OUTPUT output )
        {
            StringBuilder s = new StringBuilder();
            s.Append("[");

            int c = 0;
            foreach (var item in input._Input)
            {

                switch ((INPUT)c)
                {
                    case INPUT.ES_STAND:
                    case INPUT.MS_STAND:
                    case INPUT.MS_STAND2:
                    case INPUT.MS_STAND3:
                        s.Append("[");
                        s.Append(item.ToString());
                        break;
                    case INPUT.ES_DODGE:
                    case INPUT.MS_DODGE:
                    case INPUT.MS_DODGE2:
                    case INPUT.MS_DODGE3:
                        s.Append(item.ToString());
                        s.Append("]");

                        break;
                    default:
                        s.Append(item.ToString());
                        break;

                }
                c++;

            }

            s.Append("] [");

            s.Append(output.ToString());

            s.Append("]");

            _form.listBox1.Items.Insert(0,s.ToString());

            KLearnData data = new KLearnData();
            data._Input = input._Input;
            data._Symbol = output.ToString();

            _Learning.Run(data);
        }
Beispiel #12
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (CombatSprite.GetcurrentAnimation() != null && CombatSprite.GetcurrentAnimation().IsLoop == false)
            {
                if (CombatSprite.IsPlaybackComplete == false)
                    return;

                State = RolePlayingGameData.Character.CharacterState.Idle;
            }

            switch (State)
            {
                case RolePlayingGameData.Character.CharacterState.Walking:
                case RolePlayingGameData.Character.CharacterState.Idle:

                    WindowsGame2.AI.InputData input = GetInputData();

                    _CurAIState = MyLearning.I.GetNextAction(input);

                    break;

            }

            switch (_CurAIState)
            {
                case OUTPUT.STAND:
                    State = RolePlayingGameData.Character.CharacterState.Idle;

                    break;
                case OUTPUT.ATTACK:
                    State = RolePlayingGameData.Character.CharacterState.Attack;
                    break;
                case OUTPUT.FAR:
                    break;
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            this.dealer_from = this.txtFrom.Text;
            this.dealer_to = this.txtTo.Text;
            this.condition = this.txtCond.Text;
            if (this.rbScreen.Checked)
            {
                this.output = OUTPUT.SCREEN;
            }
            else if (this.rbPrinter.Checked)
            {
                this.output = OUTPUT.PRINTER;
            }
            else if (this.rbFile.Checked)
            {
                this.output = OUTPUT.FILE;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }