这段代码用一些随机值更新了二维数组的所有元素,还有其他简单而简短的代码来解决这个问题吗?
val terrainTypes = TerrainBlockType.values
(0 until width).foreach(i => {
(0 until height).foreach(j => {
val r = Random.nextInt(terrainTypes.length)
terrainMap(i)(j) = terrainTypes(r)
})
})