Generally, I know that I can get a random element of an array in the following way:
var myArray = [x, y, z]
let myArrayLength = UInt32(myArray.count)
let myArrayIndex = Int(arc4random_uniform(myArrayLength))
let randomElement = myArray[myArrayIndex]
But how can I make the possibility of y being the random element twice the possibility of x and z being the random element thrice the possibility of y?
Aucun commentaire:
Enregistrer un commentaire