Exemplo n.º 1
0
def test_get_full_game_representation_strategy():
    def game_representation_strategy(game):
        return Game.get_full_game_representation_strategy(game)

    snake_length = 3
    width = 8
    height = 8
    input_nodes = width * height + 4
    hidden_layer_nodes = [64]
    output_nodes = 3
    number_of_nn_weights = get_number_of_nn_weights(input_nodes,
                                                    hidden_layer_nodes,
                                                    output_nodes)
    weight_lower_threshold = -1
    weight_upper_threshold = 1

    sample_genotype = SimpleGenotype.get_random_genotype(
        number_of_nn_weights, weight_lower_threshold, weight_upper_threshold)
    sample_phenotype = Phenotype(sample_genotype.weights, input_nodes,
                                 hidden_layer_nodes, output_nodes)
    sample_game = Game(width, height, sample_phenotype, 777,
                       game_representation_strategy, snake_length)

    game_representation = Game.get_full_game_representation_strategy(
        sample_game)
    assert len(game_representation) == 8 * 8 + 4
    assert game_representation[36] == 1
    assert game_representation[44] == 1
    assert game_representation[52] == 1
Exemplo n.º 2
0
 def game_representation_strategy(game):
     return Game.get_full_game_representation_strategy(game)