Closed gyf-lancelot closed 8 years ago
func setPosition(row:Int,col:Int,value:Int) -> Bool { assert(row >= 0 && row < dimension) assert(col >= 0 && col < dimension) var index = self.dimension * row + col var val = tiles[index] if (val > 0) { println("This position has been occupied") return false } tiles[index] = value return true }
func emptyPositions() -> [Int]
{
var emptytiles = [Int]()
for i in 0..<(dimension * dimension)
{
if(tiles[i] == 0)
{
emptytiles.append(i)
}
}
return emptytiles
}
func isfull() -> Bool
{
if(emptyPositions().count == 0)
{
return true
}
return false
}
判断方格是否已满,只在空格处生成数字