Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Decision Tree Example
Started by gturmo May 04 2018 12:18 AM

2 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

gturmo

[GLOBAL: userInfoPane.html]
gturmo
  • Observer

  • 22 posts
  • Corona SDK

Hi,

I'm newbie to CoronaSDK and programming world. I'm trying to create a simple decision tree for my official job. Is there anybody who have a decision tree example for coronaSDK?

Thanks a lot!

[TOPIC: post.html]
#2

remiduchalard

[GLOBAL: userInfoPane.html]
remiduchalard
  • Contributor

  • 305 posts
  • Corona SDK

Hello,

 

A decision tree is build with a few programming instructions. For example to decide if you go the left or right leaf you do a "if".

If you want to make it easily. Create a table with all data (leaf and branch...)(it will be easy to edit the tree and it can be save in a json file) for example : 

tree={}
tree[id of the object]={}
tree[id].typeOfLeaf="condition"//example for condition
tree[id].data1=idOfLeafIfTrue
tree[id].data2=IDOfTheLeafIfFalse
tree[id].condition1="valueName"
tree[id].operator=">"
tree[id].condition2="SecondValueName"
tree[id].nameOfTheLeaf="My Leaf"

tree[id2]={}
tree[id2].typeOfLeaf="RunTwoBranchAtTheSameTime"
tree[id2].branch1=id1
tree[id2].branch2=id2

Then you will have a function who will read a tree part

function ReadABranch(id){
 if(tree[id].typeOfLeaf=="Condition")then
    conditionAnalyse(id)
  else if....
}


[TOPIC: post.html]
#3

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 755 posts
  • Corona SDK

I'm not sure how beginner-friendly it is, but I saw this pop up a couple weeks ago: erogodic




[topic_controls]
[/topic_controls]