I have been trying to run this loop to change the position of an element in an array based but I get the error below. Not really sure what could be wrong. Any thoughts or Ideas!! Thanks.
var population = [[98, 8, 45, 34, 56], [9, 13, 65, 4, 90], [24, 5, 4, 56, 88], [3, 55, 22, 19, 10]]
private func randomIntergerInRange(low:Int, high:Int) -> Int {
let randomGeneratedNumber = low + Int(arc4random()) % (high - low);
return Int(randomGeneratedNumber)
}
for individual in population {
var mutate = 0.01
if mutate > Double(Float(arc4random()) / Float(UINT32_MAX)) {
var positionToMutate = randomIntergerInRange(0, (individual.count - 1))
var valueToAssign = randomIntergerInRange(minElement(individual), maxElement(individual))
individual[positionToMutate] = valueToAssign
print(individual)
}
}
