Hi there,
I cannot figure out how on earth to use Gameplay Kits DecisionTrees. I have seen a few examples of how to create them, however I get a lot of errors when it comes to the NSObjectProtocol sections. I found I can use NSString and stuff in place of them and the decision tree that is created looks fine but I get lost with inputting the answers into the tree to get an appropriate answer. I have attempted below at it in a class but it produces nothing of what I want. Are they obsolete or is the documentation just strange, cause the example it gives dont work.
//ATTEMPT//
import UIKit
import GameplayKit
import SpriteKit
class AITrees {
let CanCastAny = "Can I Cast Any Cards In My Hand?" as NSString
let MoveNextTurn = "Move To Next Turn" as NSString
let OneSlotLeft = "Do I Have One Slot Left" as NSString
let PrintYes = "Yes" as NSString
let PrintNo = "No" as NSString
init() {}
func EasyAITree(){
let easyDecisionTree = GKDecisionTree(attribute: CanCastAny)
let root = easyDecisionTree.rootNode
root?.createBranch(predicate: NSPredicate(value: true), attribute: OneSlotLeft)
root?.createBranch(predicate: NSPredicate(value: false), attribute: MoveNextTurn)
let answers: [NSString : NSObjectProtocol] = [
"Can I Cast Any Cards In My Hand?" : false as NSObjectProtocol
]
print(answers)
print(easyDecisionTree)
print(easyDecisionTree.findAction(forAnswers: answers)!)
}
}
///////////////////////////////////////////////