I want to make a simple app with a simple AI. I did allot of research and found some articles about decision-trees, Rules and behavior-trees.
I saw a video of the WWDC2016 where the new GKDecisionTree was presented. Maybe this could be simple solution for my app.
I tried this code but I got an error in this line:
let tree = GKDecisionTree(attribute: "anrgy?")
Argument type 'String' does not conform to expected type 'NSObjectProtocol'
// SETUP TREE
let tree = GKDecisionTree(attribute: "anrgy?")
let root = tree?.rootNode
// ADD BRANCH
// Create branches
root.createBranch(value: true, attribute: "attack")
let goAway = root.createBranch(value: false, attribute: "goAway")
// Create actions for when nearby
goAway.createBranch(withWeight: 9, attribute: "Left")
goAway.createBranch(withWeight: 1, attribute: "Right")
// Find action for answers
// Find action for answers
let answers = ["anrgy?" : true]
tree.findActionForAnswers(answers: answers)
Please let me know if there is a better way for a simple AI or how to fix this example.
Thank you for your help.