Example #1
0
        private void Chessboard_MouseDown(object sender, MouseEventArgs e)
        {
            int x = Pixel2Index(e.X);
            int y = Pixel2Index(e.Y);

            if (gs.PlaceChess(x, y, gs.NextPlayer()))
            {
                DrawChess(x, y, gs.NextPlayer());
                Redraw();
                if (gs.WhoIsWin() != ChessPiece.EMPTY)
                {
                    Win(gs.WhoIsWin());
                    return;
                }

                if (enableNeuroSuccessful)
                {
                    GameAI.PlaceChessAI(gs, NeuroEvaluateFunction);
                }
                else
                {
                    GameAI.PlaceChessAI(gs, GameAI.EvaluateFunctionWithoutNervus);
                }

                DrawChess(gs.X, gs.Y, gs.NextPlayer());
                Redraw();
                if (gs.WhoIsWin() != ChessPiece.EMPTY)
                {
                    Win(gs.WhoIsWin());
                }
            }

            //MessageBox.Show(Pixel2Index(x).ToString() + ' ' + Pixel2Index(y).ToString());
        }
Example #2
0
 /// <summary>
 /// 针对整个群体进行适应度的评估
 /// </summary>
 public void Evaluate()
 {
     for (int i = 0; i < population.Count; i++)
     {
         int fit = 0;
         for (int j = 0; j < Settings.GAME_MATCHES; j++)
         {
             fit += GameAI.ComputerVSComputer(
                 population[i].Compute,
                 population[rand.Next(population.Count)].Compute);
         }
         population[i].Fitness = fit;
     }
 }
Example #3
0
 public AIThreadClass(GameState gs, GameAI.EvaluateFunction eva_fun)
 {
     game_state = gs;
     ef = eva_fun;
 }
Example #4
0
 public void RunThread()
 {
     GameAI.PlaceChessAI(game_state, ef);
 }