I'm initialising a set of dice in swift 2.0. I've declared a class Die with a name (:String), a list of states(:[String]) and a face (an index to the states array) (:[Int])
As per the recommendations in the GameplayKit Framework Reference and in this short article by Erica Sadun, I want to drop the first 1024 values of my GKARC4RandomSource to ensure "true" randomness.
In my UIViewController, I setup an init? function to initialise my dice
class IceDiceViewController: UIViewController {
var Dice: [Die]
var source : GKRandomSource
...
required init?(coder aDecoder: NSCoder){
Dice = [Die]()
source = GKARC4RandomSource()
// call the init function to instantiate all variables
super.init(coder: aDecoder)
// now initialize two dice with states ["red","yellow","blue","black","green","multiple"]
Dice.append(Die(name:"iceDie", states: ["red","yellow","blue","black","green","multiple"]))
Dice.append(Die(name:"iceDie", states: ["big","med","small","bigmed","bigsmall","medsmall"]))
// and drop the first values of the ARC4 random source to ensure "true" randomness
source.dropValuesWithCount(1024)
...
}
This won't even compile: the last line returns an error:
Value of type GKRandomSource has no member dropValuesWithCount
My code works without this line, but I'm not sure quite what I'm doing wrong here, and I can hardly find any references to Dice implementation using Gameplay Kit on the web, apart from the above cited links.