Exemplo n.º 1
0
 def __init__(self, dt, start_angle, mass):
     self.screen = curses.initscr()
     self.current_pole_win = curses.newwin(8, 40, 0, 0)
     self.high_scores_win = curses.newwin(8, 30, 0, 41)
     self.genome_win = curses.newwin(20, 40, 8, 0)
     self.high_genome_win = curses.newwin(20, 40, 8, 41)
     self.controller = pyneat.Controller(10, 10, {'a': 'enter', 'v': 'enter', 'w': 'exit'})
     self.dt = dt
     self.start_angle = start_angle
     self.mass = mass
     self.generation_counter = 0
     self.high_scores = [[0, (0, 0), 0]]*5
Exemplo n.º 2
0
                            score = -1*abs(result[0][0]-train[1])
                            print(f'{genera_id},{species_id}:{train[0]}:{result[0][0]}:{score}')
                            combined_score += score
                            scores.append(combined_score)
                avg_score = sum(scores) / len(scores)
                print(f'Average score: {avg_score}')
                print(f'Maximum score: {max(scores)}')
                print(f'Minimum score: {min(scores)}')
        except KeyboardInterrupt:
            print('final summary!')
            for genera_id, genera_species in controller.graphs.items():
                for species_id, species_graph in genera_species.items():
                    combined_score = 0
                    for train in training_list:
                        result = species_graph.run(train[0])
                        score = -1*abs(result[0][0]-train[1])
                        combined_score += score
                        scores.append(combined_score)
            avg_score = sum(scores) / len(scores)
            print(f'Average score: {avg_score}')
            print(f'Maximum score: {max(scores)}')
            print(f'Minimum score: {min(scores)}')
            break



if __name__ == '__main__':
    random.seed(1)
    controller = pyneat.Controller(1, 20, {'a': 'enter', 'b': 'enter', 'c': 'exit'})
    train(5000, controller)
Exemplo n.º 3
0
 def test1():
     pyneat.Controller("1", 1, {"a": "enter"})
Exemplo n.º 4
0
def test_controller_game_over():
    con = pyneat.Controller(5, 5, {'a': 'enter', 'b': 'enter', 'c': 'exit'})
    assert con.scores == {
        0: {
            0: 0,
            1: 0,
            2: 0,
            3: 0,
            4: 0
        },
        1: {
            0: 0,
            1: 0,
            2: 0,
            3: 0,
            4: 0
        },
        2: {
            0: 0,
            1: 0,
            2: 0,
            3: 0,
            4: 0
        },
        3: {
            0: 0,
            1: 0,
            2: 0,
            3: 0,
            4: 0
        },
        4: {
            0: 0,
            1: 0,
            2: 0,
            3: 0,
            4: 0
        }
    }
    for i in range(0, 24):
        a = i // 5
        b = i % 5
        con.game_over(i)
        assert con.scores[a][b] == i
    con.game_over(24)
    assert con.scores == {
        0: {
            0: 0,
            1: 1,
            2: 2,
            3: 3,
            4: 4
        },
        1: {
            0: 5,
            1: 6,
            2: 7,
            3: 8,
            4: 9
        },
        2: {
            0: 10,
            1: 11,
            2: 12,
            3: 13,
            4: 14
        },
        3: {
            0: 15,
            1: 16,
            2: 17,
            3: 18,
            4: 19
        },
        4: {
            0: 20,
            1: 21,
            2: 22,
            3: 23,
            4: 24
        }
    }
Exemplo n.º 5
0
 def test5():
     pyneat.Controller(1, 1, {"a": "a"})
Exemplo n.º 6
0
 def test4():
     pyneat.Controller(1, 1, {"a": 1})
Exemplo n.º 7
0
 def test3():
     pyneat.Controller(1, 1, {1: "enter"})
Exemplo n.º 8
0
 def test2():
     pyneat.Controller(1, "1", {"a": "enter"})