FourInARow

Is the FourInARow example available written in Swift? And / Or Maze?

Thanks.

Replies

I've done a Swift port of the FourInARow sample code, which can be found here:

http://www.syndrome3d.com/SampleCode-Swift/FourInARow-Swift.zip

Apple sample code is usually very good; the Four in a Row sample code is unfortunately not up to the same standard. I took the code, rewrote it in Swift, took out the CAShapeLayers and CABasicAnimations and replaced them with UIViews and UIView animations, cleaned up some of the stranger parts of the code, refactored the rest to make it clearer, then wrote it all up in a tutorial: http://www.hackingwithswift.com/read/34/overview


GameplayKit and GKMinmaxStrategist are both excellent – have fun!

I'm joining this conversation at a much later date, but posting in case someone like myself who's searching finds this useful.


I found a line-by-line Swift translation of Apple's original source code here:

https://github.com/ooper-shlab/FourInARow-Swift


The original source by Apple does not seem to work correctly, and produces bad moves (it seems to play randon moves in fact), but the above Swift translation works great. I spent some time trying to figure out why, but could not. Apple's tests fail in the current version of Xcode, which may be a clue.