Example #1
0
 public void pixel_draw()
 {
     for (int i = 0; i < Setting.Instance().mapSize_Height; i++)
     {
         for (int j = 0; j < Setting.Instance().mapSize_Width; j++)
         {
             if (mapPixel[i, j] == 3)
             {
                 GDIBuffer.Instance().getGraphics.DrawRectangle(new Pen(Brushes.Orange, 1), j * blockSize, i * blockSize, blockSize, blockSize);
                 GDIBuffer.Instance().getGraphics.FillRectangle(new SolidBrush(Color.Orange), j * blockSize, i * blockSize, blockSize, blockSize);
             }
             if (mapPixel[i, j] == 1)
             {
                 GDIBuffer.Instance().getGraphics.DrawRectangle(new Pen(Brushes.Green, 1), j * blockSize, i * blockSize, blockSize, blockSize);
                 GDIBuffer.Instance().getGraphics.FillRectangle(new SolidBrush(Color.Green), j * blockSize, i * blockSize, blockSize, blockSize);
             }
             if (mapPixel[i, j] == 4)
             {
                 GDIBuffer.Instance().getGraphics.DrawRectangle(new Pen(Brushes.Black, 1), j * blockSize, i * blockSize, blockSize, blockSize);
                 GDIBuffer.Instance().getGraphics.FillRectangle(new SolidBrush(Color.Black), j * blockSize, i * blockSize, blockSize, blockSize);
             }
             if (mapPixel[i, j] == 2)
             {
                 GDIBuffer.Instance().getGraphics.DrawRectangle(new Pen(Brushes.Blue, 1), j * blockSize, i * blockSize, blockSize, blockSize);
                 GDIBuffer.Instance().getGraphics.FillRectangle(new SolidBrush(Color.Blue), j * blockSize, i * blockSize, blockSize, blockSize);
             }
         }
     }
 }
Example #2
0
        private void FrameRender()
        {
            Graphics g = CreateGraphics();

            int start, end;

            if (Setting.Instance().테스트단위 > Setting.Instance().모집단)
            {
                start = 0;
                end   = Setting.Instance().모집단;
            }
            else
            {
                if (rotate < Setting.Instance().모집단 / Setting.Instance().테스트단위)
                {
                    start = rotate * Setting.Instance().테스트단위;
                    end   = Setting.Instance().테스트단위 + Setting.Instance().테스트단위 *rotate;
                }
                else
                {
                    start = rotate * Setting.Instance().테스트단위;
                    end   = Setting.Instance().모집단 % Setting.Instance().테스트단위
                            + Setting.Instance().테스트단위 *rotate;
                }
            }
            for (int i = start; i < end; i++)
            {
                trainers[i].WarmAction();
            }
            g.DrawImage(GDIBuffer.Instance().GetImages, new Point(0, 0));
            g.Dispose();
        }
Example #3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            GDIBuffer.Instance(ClientRectangle.Width, ClientRectangle.Height);
            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            Neruon_Form nf = new Neruon_Form();

            nf.Show();
        }
Example #4
0
 public static GDIBuffer Instance(int nW, int nH)
 {
     if (oInstance == null)
     {
         oInstance = new GDIBuffer(nW, nH);
     }
     return(oInstance);
 }
Example #5
0
        private void FrameUpdate()
        {
            GDIBuffer.Instance().getGraphics.Clear(Color.White);
            int  leftWarm = (from t in trainers where t.dead == 0 select t).Count();
            Font _font    = new System.Drawing.Font("dotum", 10, FontStyle.Regular);

            TextRenderer.DrawText(GDIBuffer.Instance().getGraphics, "alive Warms : " + leftWarm, _font, new Point(30, 30), Color.Black);
            TextRenderer.DrawText(GDIBuffer.Instance().getGraphics, "Generation : " + _Generation, _font, new Point(160, 30), Color.Black);
        }
Example #6
0
        public void resetFrame()
        {
            warms = new Trainer(window_width, window_height, blocksize);
            warms.train_setting();
            Graphics g = CreateGraphics();

            FrameUpdate();
            g.DrawImage(GDIBuffer.Instance().GetImages, new Point(0, 0));
            g.Dispose();
        }
Example #7
0
 public void TestStart()
 {
     FrameCount  = 0;
     rotate      = 0;
     _Generation = 0;
     trainers.Clear();
     GDIBuffer.Instance(window_width, window_height);
     for (int i = 0; i < Setting.Instance().모집단; i++)
     {
         Trainer t = new Trainer(window_width, window_height, blocksize);
         t.train_setting();
         trainers.Add(t);
     }
     frameTimer.Enabled = true;
 }
Example #8
0
        public void WarmAction()
        {
            frame_count++;
            future_see();

            if (dead != 1)
            {
                Pixel_Map.Map_data(Warms_total, bonus_X, bonus_Y);

                Preceed_dist = GetDist();
                Warms_total.move_monster();

                int warm_x = Warms_total.warm_parts[0].x;
                int warm_y = Warms_total.warm_parts[0].y;
                if (MemoryStorage[warm_y, warm_x] != 1)
                {
                    MemoryStorage[warm_y, warm_x] = 1;
                }

                Present_dist = GetDist();

                check_Bonus();

                if (check_eat_bonus != 0)
                {
                    new_Bonus();
                }
                Pixel_Map.pixel_draw();
            }
            else
            {
                if (dead == 1 && check_dead == 0)
                {
                    if (Total_score < 0)
                    {
                        Total_score = 0;
                    }
                    _Genetic.score += Total_score;
                    check_dead      = 1;
                }

                Point centerPos = new Point(Warms_total.warm_parts[0].x * blocksize, Warms_total.warm_parts[0].y * blocksize);
                Font  _font     = new System.Drawing.Font("dotum", 12, FontStyle.Bold);
                TextRenderer.DrawText(GDIBuffer.Instance().getGraphics, String.Format("{0}", _Genetic.score), _font, centerPos, Color.LightSkyBlue);
            }
        }