Пример #1
0
        private void Evaluate_Gene_Click(object sender, EventArgs e)
        {
            if (!OnceEvaluation)
            {
                if (Learning.Next())
                {
                    System_Log.Items.Add("유전자 불러오기 성공");
                    Gene_Generator.Enabled      = false;
                    Evaluate_Generation.Enabled = false;
                    Learning_heredity.Enabled   = false;
                }
                else
                {
                    System_Log.Items.Add("유전자 불러오기 실패");
                    return;
                }

                Control_Moving.Stop();
                Program_Indicator.Stop();

                label_Generation.Text = Learning.get_Current_Generation() + " 세대";
                label_Serial.Text     = Learning.get_Current_Serial() + "번 유전자";

                game_Start();

                UI_Drawer("가중치", heuristics.get_Weight(), label_Weight, false);


                Control_Moving.Start();
                Program_Indicator.Start();
                string message = "가중치 ";
                foreach (int n in Learning.get_Weight())
                {
                    message = message + n + " ";
                }
                message += "에 대한 평가 시작";
                System_Log.Items.Add(message);
                OnceEvaluation = true;
            }
            else
            {
                Control_Moving.Stop();
                Program_Indicator.Stop();
                game_Start();
                System_Log.Items.Add("평가를 취소했습니다. 이번 평가는 저장되지 않습니다.");
                Control_Moving.Stop();
                Program_Indicator.Stop();


                Evaluate_Generation.Enabled = true;
                Learning_heredity.Enabled   = true;
                Gene_Generator.Enabled      = true;

                OnceEvaluation = false;
            }
        }
Пример #2
0
 private void Game_Click(object sender, EventArgs e)
 {
     if (OnOff == true)
     {
         Control_Moving.Stop();
         Drawing_Map.Stop();
         Program_Indicator.Stop();
         OnOff = false;
     }
     else
     {
         Control_Moving.Start();
         Drawing_Map.Start();
         Program_Indicator.Start();
         OnOff = true;
     }
 }
Пример #3
0
        private void Moving_down(bool Decision, bool fast) // true means that time pass, false means that block completely down.
        {
            if (Moving)
            {
                while (Moving == true)
                {
                    ;
                }
            }
            else
            {
                Moving = true;
            }

            if (Decision)
            {
                BlockArrival = mapping.TimePass(BlockColor);
            }
            else
            {
                BlockArrival = mapping.Full_Down(BlockColor);
            }
            if (!fast)
            {
                FLAG_DRAW_MAP = mapping.get_Draw();
            }
            if (BlockArrival == true)
            {
                if (BlockColor == GameOver)
                {
                    score         = mapping.get_Score();
                    scoreWriting  = true;
                    FLAG_DRAW_MAP = true;
                    Control_Moving.Stop();
                }
                else
                {
                    Current_Block = Next_Block;
                    BlockColor    = mapping.init_Character(Current_Block, 5);
                    Next_Block    = Generator.Next(6);
                }
                BlockArrival = false;
            }
            Moving = false;
        }
Пример #4
0
        private void Heredity_Tick(object sender, EventArgs e)
        {
            /* 한 평가가 종료되고 그 평가의 점수를 기록 */
            if (scoreWriting == true)
            {
                if (!OnceEvaluation && !evaluation && !lastEvaluation)
                {
                    scoreWriting = false;
                    return;
                }
                if (Learning.Save_Score(score))
                {
                    try
                    {
                        System_Log.Items.Add(score.ToString() + "점 기록 완료");
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine(error.Message);
                    }
                }
                OnceEvaluation = false;
                //전체 유전자 평가 종료시
                if (lastEvaluation)
                {
                    Evaluate_Gene.Enabled     = true;
                    Learning_heredity.Enabled = true;
                    Gene_Generator.Enabled    = true;
                    System_Log.Items.Add("한 세대 평가를 완료하였습니다.");
                    lastEvaluation = false;
                    clickListener  = false;
                }
                //단일 유전자 평가 종료시
                if (!evaluation)
                {
                    Evaluate_Generation.Enabled = true;
                    Learning_heredity.Enabled   = true;
                    Gene_Generator.Enabled      = true;
                }
                if (heredityMode)
                {
                    NextEvaluation = true;
                }
                //heredityMode = true;
                scoreWriting = false;
            }


            if (evaluation && heredityMode && NextEvaluation)
            {
                NextEvaluation = false;
                if (Learning.Next())
                {
                    System_Log.Items.Add("유전자 불러오기 성공");
                    Control_Moving.Stop();
                    Program_Indicator.Stop();

                    label_Generation.Text = Learning.get_Current_Generation() + " 세대";
                    label_Serial.Text     = Learning.get_Current_Serial() + "번 유전자";

                    /*타이머 종료 조건*/
                    if (Learning.get_Current_Serial() == 99)
                    {
                        evaluation     = false;
                        lastEvaluation = true;
                    }
                    game_Start();

                    UI_Drawer("가중치", heuristics.get_Weight(), label_Weight, false);

                    Control_Moving.Start();
                    Program_Indicator.Start();
                    string message = "가중치 ";
                    foreach (int n in Learning.get_Weight())
                    {
                        message = message + n + " ";
                    }
                    message += "에 대한 평가 시작";
                    System_Log.Items.Add(message);
                }
                else // 이 부분은 전체 세대 평가 기능 작동시에만 구동됩니다.
                {
                    System_Log.Items.Add("유전자 불러오기 실패");
                    evaluation                = false;
                    Evaluate_Gene.Enabled     = true;
                    Learning_heredity.Enabled = true;
                    Gene_Generator.Enabled    = true;
                    clickListener             = false;
                }
            }
        }