-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
27 lines (22 loc) · 777 Bytes
/
test.js
File metadata and controls
27 lines (22 loc) · 777 Bytes
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
'use strict';
var GameMap = require('./src/GameMap');
var Evolution = require('./src/Evolution');
global.print = console.log.bind(console);
global.printErr = console.log.bind(console);
var map = new GameMap([[],[],[],[],[],[]]);
var blocks = [];
for (var x = 0; x < 8; x++) {
blocks.push(~~(1 + Math.random() * 5), ~~(1 + Math.random() * 5));
}
print(blocks);
var evolution = new Evolution({
map: map,
blocks: blocks
});
var result = evolution.evolve();
printErr(JSON.stringify(result.lastGenerationStats));
printErr(JSON.stringify(result.runStats));
printErr('roundCache', GameMap.roundCache._hits);
printErr('turnCache', GameMap.turnCache._hits);
printErr(JSON.stringify(result.best));
var bestAction = result.best.phenotype[0] + ' ' + result.best.phenotype[1];