Example #1
0
    public void TestAI()
    {
        game = new Game();
        AIPlayer player1 = new AIPlayer_GeneticUtilityAI(
            game,
            new float[] {
            0.20f,                     // New stone
            0.30f,                     //0.10f, // Block roll again
            0.25f,                     //0.50f, // Score stone
            0.50f,                     // Roll again
            0.60f,                     // Kill stone
            0.70f,                     // Kill stone late bonus
            0.50f,                     // Danger late bonus
            0.2f,
            0.3f,
            0.2f,
            0.05f
        }
            );
        AIPlayer player2 = new AIPlayer_UtilityAI(game);
        int      score   = 0;

        for (int i = 0; i < 1000; i++)
        {
            if (Evaluate(player1, player2))
            {
                score++;
            }
        }
        Debug.Log("Winrate: " + score / 10f + " %");
    }
Example #2
0
    public GeneticAlgorithm()
    {
        game        = new Game();
        referenceAI = new AIPlayer_UtilityAI(game);

        population = new AIPlayer_GeneticUtilityAI[POPULATION_SIZE];
        for (int i = 0; i < POPULATION_SIZE; i++)
        {
            population[i] = new AIPlayer_GeneticUtilityAI(game);
        }
    }