在网上下的源码就这点改不过来,不知道怎么改
func getMoveScore(direction: MoveDirection) -> Int {
// Prepare the generator closure
let coordinateGenerator: (Int) -> [(Int, Int)] = { (iteration: Int) -> [(Int, Int)] in
let buffer = Array<(Int, Int)>(count:self.dimension, repeatedValue: (0, 0))
for i in 0..<self.dimension {
switch direction {
case .Up: buffer[i] = (i, iteration)//类型不对
case .Down: buffer[i] = (self.dimension - i - 1, iteration)//类型不对
case .Left: buffer[i] = (iteration, i)//类型不对
case .Right: buffer[i] = (iteration, self.dimension - i - 1)//类型不对
}
}
return buffer
}
func getMoveScore(direction: MoveDirection) -> Int {
// Prepare the generator closure
let coordinateGenerator: (Int) -> [(Int, Int)] = { (iteration: Int) -> [(Int, Int)] in
let buffer = Array<(Int, Int)>(count:self.dimension, repeatedValue: (0, 0))
for i in 0..<self.dimension {
switch direction {
case .Up: buffer[i] = (i, iteration)//类型不对
case .Down: buffer[i] = (self.dimension - i - 1, iteration)//类型不对
case .Left: buffer[i] = (iteration, i)//类型不对
case .Right: buffer[i] = (iteration, self.dimension - i - 1)//类型不对
}
}
return buffer
}
var buffer = Array<(Int, Int)>(count:self.dimension, repeatedValue: (0, 0))