Skip to content

Commit fe21841

Browse files
committed
Start initial slave at random position.
1 parent 57f0611 commit fe21841

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

app/controllers/master-controller.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
}
2727

2828

29+
// I get a random coordinate based on the given constraints.
30+
function getRandomCoordinate( minCoordinate, maxCoordinate ) {
31+
32+
var delta = ( maxCoordinate - minCoordinate );
33+
34+
return(
35+
minCoordinate + Math.floor( Math.random() * delta )
36+
);
37+
38+
}
39+
40+
2941
// -- Define Scope Methods. --------------------- //
3042

3143

@@ -57,12 +69,12 @@
5769

5870

5971
// This is our list of slaves and their coordinates. Starting with an initial
60-
// collection of one.
72+
// collection of one (at a random position).
6173
$scope.slaves = [
6274
{
6375
id: 1,
64-
x: 100,
65-
y: 100
76+
x: getRandomCoordinate( 50, 400 ),
77+
y: getRandomCoordinate( 50, 200 )
6678
}
6779
];
6880

0 commit comments

Comments
 (0)