Exemple #1
0
        public static void PlayPongNN()
        {
            SimpleNetVer Jeff = new SimpleNetVer(50, 1, -0.4, 0.8, 6, 50, 25, 3);

            Jeff.SetAfNames("r", "TL", "s");
            Jeff.SetAfT(1, 0);
            Jeff.SetAfT(2, 5, 2);
            Jeff.SetAfT(3, 1);


            SimpleNetVer Jeffine = new SimpleNetVer(50, 1, -0.4, 0.8, 6, 100, 50, 3);

            Jeffine.SetAfNames("r", "TL", "s");
            Jeffine.SetAfT(1, 0);
            Jeffine.SetAfT(2, 5, 2);
            Jeffine.SetAfT(3, 1);



            Pong.DrawMap();
            Random rnd = new Random();

            while (true)
            {
                Jeff.SetInput(Pong.GetState1NN().Concat(new double[] { rnd.NextDouble() * 100 - 50 }).ToArray());
                Jeff.OutputBerechnen();

                Jeffine.SetInput(Pong.GetState2NN().Concat(new double[] { rnd.NextDouble() * 100 - 50 }).ToArray());
                Jeffine.OutputBerechnen();


                Pong.punktePlayer1 = 0;
                Pong.punktePlayer2 = 0;


                Pong.Play(Jeff.GetMaxOutputIndex(), Jeffine.GetMaxOutputIndex());

                if (Pong.punktePlayer1 != 0)
                {
                    Jeff.LearnWithRegister(Pong.punktePlayer1, true, 1);
                    Jeff.lastInput = new List <double[]>();
                }

                if (Pong.punktePlayer2 != 0)
                {
                    Jeffine.LearnWithRegister(Pong.punktePlayer2, true, 1);
                    Jeffine.lastInput = new List <double[]>();
                }


                //System.Threading.Thread.Sleep(20);
            }
        }
        static void Main(string[] args)
        {
            Connection  y = new Connection(new NeuronPosition(0, 0));
            KuhleKlasse x = new KuhleKlasse();

            Console.WriteLine(GetLength(y));



            Console.ReadLine();
            Programme.PlayPongN();
            Pong.DrawMap();

            while (true)
            {
                Console.SetCursorPosition(0, 0);
                char c = Console.ReadKey().KeyChar;
                if (c == 'w')
                {
                    Pong.Play(0, 0);
                }
                else if (c == 's')
                {
                    Pong.Play(1, 0);
                }
            }

            Console.ReadLine();
            Tetris.TetrisSetup();
            Tetris.MapAktualisieren(true);
            while (true)
            {
                Tetris.UserBewegung(Console.ReadKey().KeyChar);
            }
            int a = 6;
            int b = 2;

            Console.WriteLine(Convert.ToInt32(Math.Round(Convert.ToDouble(a) / Convert.ToDouble(b), MidpointRounding.AwayFromZero)));

            double[,] arr = new double[5, 5] {
                { 0, 1, 2, 3, 4 }, { 5, 6, 7, 8, 9 }, { 10, 11, 12, 13, 14 }, { 15, 16, 17, 18, 19 }, { 20, 21, 22, 23, 24 }
            };
            double[,] arr2 = CNN2D.GetPice(arr, 1, 1, 5, 5);
            CNN2D.InsertValue(arr, 1, 1, 2, 2, 30);

            Console.ReadLine();
        }
Exemple #3
0
        public static void PlayPongN()
        {
            SimpleNetVer Jeff = new SimpleNetVer(7, 1, -1, 2, 5, 20, 40, 100, 40, 3);

            Jeff.SetAfNames("t", "rtL", "rtL", "rtL", "s");
            Jeff.SetAfT(1, 1);
            Jeff.SetAfT(2, 0, 1, 2);
            Jeff.SetAfT(3, 0, 1, 2);
            Jeff.SetAfT(4, 0, 1, 2);
            Jeff.SetAfT(5, 1);


            //Q_Learning Jeffine = new Q_Learning(0.9, 0, 3, 0);



            Pong.DrawMap();
            Random rnd = new Random();

            while (true)
            {
                Jeff.SetInput(Pong.GetState1NN() /*.Concat(new double[] { rnd.NextDouble() * 10 - 5 }).ToArray()*/);
                Jeff.OutputBerechnen();

                //int act = Jeffine.Get_SetAction(Pong.GetState2(), Pong.punktePlayer2);


                Pong.punktePlayer1 = 0;
                Pong.punktePlayer2 = 0;


                Pong.Play(Jeff.GetMaxOutputIndex(), null);

                if (Pong.punktePlayer1 != 0)
                {
                    Jeff.LearnWithRegister(Pong.punktePlayer1, true, 0.9);
                    Jeff.lastInput = new List <double[]>();
                }


                //System.Threading.Thread.Sleep(20);
            }
        }