简单实现,新建了一个数组,效率不怎么高
//随机得到一个打乱的顺序
randomClotherArr:function(){
var clotherArr = [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]];
var arr = [];
while(clotherArr.length > 0){
var index = this.getRandomIndex(clotherArr.length);
arr.push(clotherArr[index]);
clotherArr.splice(index,1);
}
return arr;
},
getRandomIndex:function(num){
return Math.floor(Math.random()*num);
},