Created
September 16, 2018 21:56
-
-
Save Jorger/433ebd90f8820d0c44ec01b690189b32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getNeighbour = (pipesInposition, directionPipe) => { | |
let indexNextPipe = -1; | |
const posibleDirections = [ | |
[[2], [2], [1, 2, 3], [1, 2], [0, 2]], | |
[[3], [3], [0, 2, 3], [2, 3], [1, 3]], | |
[[0], [0], [0, 1, 3], [0, 3], [0, 2]], | |
[[1], [1], [0, 1, 2], [0, 1], [1, 3]] | |
][directionPipe]; | |
if (pipesInposition.length !== 0) { | |
for (let indexPipe of pipesInposition) { | |
//Buscar si existe un posible conector... | |
const conectorExpected = posibleDirections[ | |
actualWorld[1][indexPipe][2] - 1 | |
].indexOf(actualWorld[1][indexPipe][3]); | |
if (conectorExpected >= 0) { | |
indexNextPipe = indexPipe; | |
break; | |
} | |
} | |
} | |
return indexNextPipe; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment