-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
77 lines (63 loc) · 1.61 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
$(function() {
var clicked = false;
var currentWeb = 'neuoroShit';
$("#start").click(function() {
timeoutFunc();
});
$('#myCanvas').click(function(){
clicked = true;
});
function timeoutFunc() {
setTimeout(function() {
start();
if(flappy.Alive) {
timeoutFunc();
}
}, $('#refreshRate').val());
}
visualiser.init(10, 25, 10, 10, 40);
visualiser.base();
var start = function() {
var inputs = flappy.Export();
$('#velocity').text(flappy.bird.velocity);
visualiser.base();
visualiser.run(inputs);
$('#fitness').text(flappy.Fitness);
currentWeb = $('#genome option:selected').val();
if(currentWeb == 'manual'){
flappy.Next(clicked);
clicked = false;
}else{
out = n.response(inputs);
visualiser.neuronWeb(n.network);
flappy.Next(out);
}
}
$.getJSON("genomes/0starter.json", function(json) {
genomes = crossfilter(json);
paymentsByTotal = genomes.dimension(function(d) { return d.Fitness; });
$('#search').click(function() {
var minFitness = $('#minFitness').val();
var maxFitness = $('#maxFitness').val();
genomes = paymentsByTotal.filter([minFitness,maxFitness]).bottom(1)
console.log(genomes);
n = new Network(genomes[0]);
});
});
});
angular.module('flappy', [])
.controller('SearchController', function() {
var search = this;
search.result = [];
search.minFitness = 0;
search.maxFitness = 3;
search.search = function() {
search.result = paymentsByTotal.filter([search.minFitness,search.maxFitness]).top(5);
};
search.selectGenome = function(g){
n = new Network(g);
}
search.resetGame = function(){
flappy.Reset();
};
});