-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.js
52 lines (41 loc) · 829 Bytes
/
tools.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
function createArrayx2( rows, cols, defaultValue){
var arr = [];
// Creates all lines:
for(var i=0; i < rows; i++){
// Creates an empty line
arr.push([]);
// Adds cols to the empty line:
arr[i].push( new Array(cols));
for(var j=0; j < cols; j++){
// Initializes:
arr[i][j] = defaultValue;
}
}
return arr;
}
function randnum(min,max){
return(min + Math.round(Math.random()*(max-min)));
}
function arraycompare(a1,a2){
var count = 0;
for(i=0;i<a1.length;i++){
for(j=0;j<a1.length;j++){
if(a1[i][j]!=a2[i][j]){
count++;
}
}
}
if(count!=0){
return false;
}
else{
return true;
}
}
function arraycopy(from,to){
for(i=0;i<from.length;i++){
for(j=0;j<from.length;j++){
to[i][j]=from[i][j];
}
}
}