|
|
|
|
@ -1,15 +1,15 @@
|
|
|
|
|
//const numBeats = Math.ceil(Math.random()*9);
|
|
|
|
|
const numBeats = Math.ceil(Math.random()*9);
|
|
|
|
|
|
|
|
|
|
//let resultString = '';
|
|
|
|
|
//const instructionPosibilities = [ 'n', 'p', 'm', 'b' ]
|
|
|
|
|
let resultString = '';
|
|
|
|
|
const instructionPosibilities = [ 'n', 'p', 'm', 'b' ]
|
|
|
|
|
|
|
|
|
|
//for(let i = 1; i <= numBeats; i++){
|
|
|
|
|
//const instructionIndex = Math.floor(Math.random()*instructionPosibilities.length);
|
|
|
|
|
for(let i = 1; i <= numBeats; i++){
|
|
|
|
|
const instructionIndex = Math.floor(Math.random()*instructionPosibilities.length);
|
|
|
|
|
|
|
|
|
|
//resultString += instructionPosibilities[instructionIndex] + ' ';
|
|
|
|
|
//}
|
|
|
|
|
resultString += instructionPosibilities[instructionIndex] + ' ';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//console.log(resultString);
|
|
|
|
|
console.log(resultString);
|
|
|
|
|
|
|
|
|
|
const breakDown = (node)=>{
|
|
|
|
|
|
|
|
|
|
@ -32,7 +32,7 @@ const breakDown = (node)=>{
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const tree = breakDown({value:10});
|
|
|
|
|
const tree = breakDown({value:numBeats});
|
|
|
|
|
|
|
|
|
|
//console.dir(tree, {depth:null});
|
|
|
|
|
|
|
|
|
|
@ -102,6 +102,14 @@ const getLeaves = (node)=>{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const leaves = getLeaves(tree);
|
|
|
|
|
|
|
|
|
|
console.dir(leaves, {depth:null});
|
|
|
|
|
const claves = getLeaves(tree);
|
|
|
|
|
if(Number.isInteger(claves)){
|
|
|
|
|
console.log(claves);
|
|
|
|
|
} else {
|
|
|
|
|
if(Number.isInteger(claves[0])){
|
|
|
|
|
console.log(claves);
|
|
|
|
|
} else {
|
|
|
|
|
const clave = claves[Math.floor(Math.random()*claves.length)];
|
|
|
|
|
console.log(clave);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|