Re:A Very Simple Genetic Algorithm Written in Swift 3
by Someone on Friday November 11, 2016 @01:53PM
(#12933202)
That's because Character is very, very different from ASCII in Swift (a character in Swift holds an extended grapheme cluster. See https://developer.apple.com/reference/swift/character). I also doubt the way they compute its ASCII value is optimal:
extension Character {
var asciiValue: UInt32? {
return String(self)
.unicodeScalars
.filter{$0.isASCII}
.first?
.value
}
}
Certainly if it is optimal, but probably also if it isn't, I would change the program to not do that conversion in inner loops.
Re:A Very Simple Genetic Algorithm Written in Swift 3
by brothrock on Friday November 11, 2016 @02:10PM
(#12933375)
This is awesome guys. Thanks.
Re:A Very Simple Genetic Algorithm Written in Swift 3
by rookie on Friday November 11, 2016 @02:02PM
(#12933305)
Replaced String with Int array
https://gist.github.com/rookie/3d9a848c6fefacc4254da921da79b...
https://dl.dropboxusercontent.com/u/13740348/Screen%20Shot%2...