-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (38 loc) · 908 Bytes
/
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
var PetriDish = require('./source/petriDish'),
Cell = require('./source/cell'),
Food = require('./source/food'),
Random = require('./ai/random'),
width = 1000,
height = 800,
aiList, cellList, foodFactory,
petriDish;
aiList = [
new Random('One'),
new Random('Two'),
new Random('Three'),
new Random('Four'),
new Random('Five'),
new Random('Six'),
new Random('Seven'),
new Random('Eight')
];
cellList = aiList.map(function (ai) {
var x = Math.random() * width,
y = Math.random() * height;
return new Cell(x, y, 10, ai);
});
foodFactory = function(width, height) {
return new Food(width, height, 5);
};
petriDish = new PetriDish(width, height, 12, 10, 200, cellList, foodFactory);
function processTurn() {
petriDish.processTurn(function (err, results) {
if (results) {
console.log(results[0].name);
process.exit();
} else {
processTurn();
}
});
}
processTurn();