-
Notifications
You must be signed in to change notification settings - Fork 0
/
aidebug.js
47 lines (39 loc) · 1.28 KB
/
aidebug.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
// All the hacky code in one place
function AiDebug(game, map) {
this.map = map;
}
AiDebug.prototype.showInfMap =
function(inf_map) {
var max_v = inf_map.getHighest().score;
var mul = 128 / (max_v + 50);
var min_v = max_v;
for (var i = 0; i < inf_map.width; i++) {
for (var j = 0; j < inf_map.height; j++) {
if (this.map.map[i][j].sprite === undefined)
continue;
var v = inf_map.map[i][j].value;
if (v === undefined)
continue;
if (v < min_v) min_v = v;
// add 50 to push values below zero above zero.
var r = 0, g = 0, b = 0;
if (v == max_v)
{
r = 255;
g = 255;
b = 0;
}
else
{
r = 128 + (v + 50) * mul;
console.log("v: " + (v-50) + ", r: " + r);
}
this.map.map[i][j].sprite.setAttribute(
"fill",
"rgb("+(r|0)+","+(g|0)+","+(b|0)+")"
);
}
}
console.log('max v: '+max_v);
console.log('min v: '+min_v);
}