示例#1
0
        public static void drawCheck(Image xDraw, params UniPanel[] xPanel)
        {
            //CHECK DRAWN BITMAP
            double[] dblArray = NetMain.Cam.getDoubleArray();

            //GET ANSWER
            int answer = NetMain.neuralNetworkQuery(dblArray, 0.0, true);

            //ABBRUCH
            if (xPanel.Length == 0 || answer == int.MinValue)
            {
                return;
            }

            //TRANSFER IMAGE AND TOOLTIP TO NEXT PANEL
            for (int i = xPanel.Length - 2; i >= 0; i--)
            {
                if (xPanel[i].BackgroundImage != null)
                {
                    xPanel[i + 1].BackgroundImage = xPanel[i].BackgroundImage;
                }
                ;
                xPanel[i + 1].setToolTip(xPanel[i].getToolTip());
            }

            //SET FIRST PANEL
            Size size = xPanel[0].Size;

            xDraw = (Bitmap)Mod_PNG.getScaleImage(xDraw, size, false);
            Graphics g = Graphics.FromImage(xDraw);

            g.DrawString(Mod_Convert.IntegerToString(answer), Fonts.getFontCooper(9), new SolidBrush(Color.Red), new Point(size.Width - 14, size.Height - 18));
            xPanel[0].BackgroundImage = xDraw;
            xPanel[0].setToolTip(NetMain.ConsoleBox.Tag.ToString());
        }
示例#2
0
        private void eventPaint(object sender, PaintEventArgs e)
        {
            //TAKE LIVE IMAGE
            Bitmap screen = new Bitmap(CamWidth, CamHeight, PixelFormat.Format32bppArgb);

            Opacity = 0.0;
            Graphics.FromImage(screen).CopyFromScreen(CamLeft, CamTop, 0, 0, screen.Size, CopyPixelOperation.SourceCopy);
            Opacity = NetMain.TrackOpacity.getValue();

            //GET FRAME RATE
            NetMain.LabelFps.Text = getFrameRate().ToString();

            //INITIALIZE LAST FRAME
            if (LastFrameCam == null)
            {
                LastFrameCam = screen;
            }

            //SET TO SHOW PANEL
            NetMain.PanelShow.BackgroundImage = new Bitmap((Bitmap)NetDraw.ScaleUp(screen));
            ListFrame.Push(new Bitmap(screen));

            //DELAY
            if (ListFrame.Limit > 0)
            {
                screen = ListFrame.getLast();
            }

            //INITIALIZE VARIABLES
            bool  next = false;
            Color getColor, setColor = Color.White;

            //SCALE DOWN
            screen = (Bitmap)NetDraw.ScaleDown(screen);
            Bitmap bmp = new Bitmap(screen);

            //CONVERT GRAY SCALE
            for (int y = 0; y < bmp.Height; y++)
            {
                for (int x = 0; x < bmp.Width; x++)
                {
                    getColor = bmp.GetPixel(x, y);

                    //CHECK IS ALIVE
                    if (isAlive(getColor, x, y))
                    {
                        next = true;
                    }

                    switch (NetMain.Net.Mode)
                    {
                    case MODE.PIXEL: setColor = Colors.getGray(getColor); break;                //GREY SCALE CONVERSION

                    case MODE.HSENSOR: setColor = Colors.getBlackWhite(getColor); break;        //BLACK OR WHITE CONVERSION
                    }

                    //CUSTOM CONVERSION
                    setColor = getCustomConversion(getColor, setColor);

                    //SET PIXEL COLOR
                    bmp.SetPixel(x, y, setColor);
                }
            }

            //AFTER CONVERSION
            switch (NetMain.Net.Mode)
            {
            case MODE.PIXEL: ModePixel(bmp); break;

            case MODE.HSENSOR: ModeHSensor(new Bitmap(bmp), e); break;
            }

            //SET LAST FRAME AND ALIVE
            LastFrameCam = screen;
            LastFrameNet = bmp;
            Alive        = next;

            //NET QUERY
            if (NetMain.ToggleQuery.Checked)
            {
                NetDraw.Draw(NetDraw.ScaleDown(bmp));
            }

            //NET SEND KEYS
            if (NetMain.ToggleSend.Checked)
            {
                eventGlobalSendKeys(NetMain.neuralNetworkQuery(getDoubleArray(), 0.5));
            }

            //NET LEARNING
            else
            {
                NetMain.Mario.LearningRun();
            }
        }