-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertMove.js
More file actions
34 lines (32 loc) · 869 Bytes
/
convertMove.js
File metadata and controls
34 lines (32 loc) · 869 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
28
29
30
31
32
33
34
const convertMove = (moves) => {
let direction= '';
if(moves.length == 1){
return direction = 'x';
}
for(let x=0; x < moves.length - 1; x++) {
if( moves[x].row - moves[x+1].row == 0){
if(moves[x].col - moves[x+1].col > 0) {
direction = direction + '1';
}else {
direction = direction + '2';
}
}else{
if(moves[x].row - moves[x+1].row > 0){
direction = direction + '3';
}else {
direction = direction + '4';
}
}
}
return direction;
}
//Node class, used by searches as nodes in a tree.
function Node(parent,point,children){
this.parent = parent;
this.point = point;
this.children = children;
}
function Point(pos_x,pos_y){
this.row = pos_x;
this.col = pos_y;
}