swiftswift2gameplay-kitgkminmaxstrategist

Where to start with GKMinmaxStrategist?


I was wondering if anyone here has had any luck using GKMinmaxStrategist. This class/feature was showed off at the WWDC, but most of the sample code was in Objective-C, which was a disappointment.

The WWDC videos for GameplayKit featured another game, Stone Flipper (Reversi/Othello), but they haven't published the code (yet?).

Has anyone had any luck with this? I was hoping to try this out with just a simple tic-tac-toe game, but am not at all sure how to start.


Solution

  • I agree that it's a tricky framework to learn – I just finished writing a tutorial about GameplayKit and GKMinmaxStrategist and it was no mean feat. If you follow the tutorial it builds a complete game from scratch, explaining how it all fits together. You might find it useful as a starting point, at the very least.

    I'm hopeful that Apple will improve its documentation before iOS 9 is final!

    If you want to dive straight in, here's the least you need to know:

    If you find the AI is running slowly, either restrict the number of moves it can make or reduce its look ahead depth.