forked from ayberkydn/haxRL
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
62 lines (53 loc) · 1.63 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
//TODO
//Direkten bazen hayvan gibi dönme şeysini düzelt
//Borderları start end diye refactor et
//Epsilon annealing gibi son algoritma tricklerini implement et, parametreleri guzellestir
//Jsona yazıp okumayı implement et sonra timeoutsuz calistir
//LAYERS REFACTOR
//-activation ayri layer
//-networke input shape init
// Gets the handles for rendering
var canvas = document.getElementById("gameCanvas");
var canvas2 = document.getElementById("agentVisionCanvas");
var ctx = canvas.getContext('2d');
var cHeight = canvas.height;
var cWidth = canvas.width;
// Init keypress events
var keys = {};
window.onkeydown = function (evt) {
keys[evt.key] = true;
};
window.onkeyup = function (evt) {
keys[evt.key] = false;
};
// Parameters
var bgColor = Color.green;
var redColor = Color.red;
var blueColor = Color.blue;
var playerMass = 3;
var ballMass = 2;
var playerRestitution = 0.45;
var borderRestitution = 1;
var ballRestitution = 0.45;
var playerDamping = 0.93;
var playerkickDamping = 0.87;
var playerkickPower = 15;
var playerRadius = 16;
var ballRadius = 10;
var ballDamping = 0.98;
var topbottomMargin = 40;
var leftrightMargin = 55;
var goalLength = 140;
var middleFieldRadius = 83;
var postRadius = 8.5;
var scaleH = 0.20;
var scaleW = 0.20;
//
var env = new Environment( /*render*/ true, /*sound*/ true, /*resetDelay*/ true, /*randomStart*/ false);
env.addAgent(new HumanAgent("w", "s", "a", "d", "q"), Side.red);
//env.addAgent(new HumanAgent("ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "."), Side.blue);
env.addAgent(new HumanAgent("8", "5", "4", "6", "0"), Side.blue);
env.draw();
setInterval(() => {
env.update();
}, 30);