var temporary=new Array(); for(var i=0;i<4;i++) for(var j=0;j<4;j++) { if(board[i][j]==0) { temporary[count]=i*4+j; count++; } } var pos= parseInt( Math.floor( Math.random() * count ) ); ranx=temporary/4; rany=temporary%4; 自己寫的隨機(jī)代碼
xlb
2014-06-18
2 回答
舉報(bào)
0/150
提交
取消
2014-06-18
有點(diǎn)問題 重新寫了下 var count=0; var temporary=new Array(); for(var i=0;i<4;i++) for(var j=0;j<4;j++) { if(board[i][j]==0) { temporary[count]=i*4+j; count++; } } var pos= parseInt( Math.floor( Math.random() * count ) ); randx=Math.floor(temporary[pos]/4); randy=Math.floor(temporary[pos]%4);
2014-06-18
贊!