Beispiel #1
0
 public void Evaluate()
 {
     for (int i = 0; i < POPULATION; i++)
     {
         CellAutomataGame cellAutomataGame = new CellAutomataGame(intArrayChromosomes.ReadChromosomeAsRule(i), rulesForEvalate);
         cellAutomataGame.InitializeBoards();
         for (int n = 0; n < EPISODESFOREVALATION; n++)
         {
             cellAutomataGame.UpdateGameBoard();
         }
         scores[i] = EvaluateFunction(cellAutomataGame);
     }
 }
Beispiel #2
0
 // 評価をする
 public void Evaluate()
 {
     Parallel.For(0, POPULATION, i => {
         CellAutomataGame cellAutomataGame = new CellAutomataGame(
             intArrayChromosomes.ReadChromosomeAsRule(i), rulesForEvalate, boardSize, INITIAL_RESOURCES);
         cellAutomataGame.InitializeBoards();
         for (int n = 0; n < EPISODES_FOR_EVALATION; n++)
         {
             cellAutomataGame.UpdateGameBoard();
         }
         intArrayChromosomes.SetScore(i, EvaluateFunction(cellAutomataGame));
     });
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            CellAutomataGA cellAutomataGA = new CellAutomataGA();

            for (int i = 0; i < 50; i++)
            {
                cellAutomataGA.NextGeneration();
                Console.Write("Episode:");
                Console.WriteLine(i);
                cellAutomataGA.ShowScores();
                cellAutomataGA.ShowEliteScores();
            }
            Console.ReadLine();
            CellAutomataGame cellAutomataGame = new CellAutomataGame(cellAutomataGA.EliteRule(), cellAutomataGA.rulesForEvalate);

            cellAutomataGame.InitializeBoards();
            for (int i = 0; i < 100; i++)
            {
                cellAutomataGame.Draw();
                cellAutomataGame.UpdateGameBoard();
            }
            Console.Read();
        }