Okay. Hi. I'm Lionel and I'm going to talk about tree matching with behavioral trees. So the aim of this presentation is to explain how to organize sub-trees into complex and deep trees of data. It is related to Python, but you could use these techniques in any language that support reflexivity. So we are going to speak about behavioral trees and to define it. And so after that, I will try to explain why we need tree matching and in the common use case for using tree matching. And during all the presentation, I put some code to explain how to do all this stuff. So what is a behavioral tree? A behavioral tree, in fact, is basically a diagram or schema that represents a process that describes different tasks that are useful and very used in video games. For example, to describe the artificial intelligence of a boat, or the behavior of the boat. For example, here I could explain a boat in the game that crossed the door. So I begin to describe with our symbol a sequence of tasks to be executed. So I begin to say to my boat, begin to work to the door. Behind this task could be used a pathfinder algorithm to find where the door is, for example. After that, do a complex sub-trees that is described, that begins by a question mark. A question mark is another abstraction provided by behavioral tree. And the arrow symbol means sequences. But the question mark, in fact, is called selector. A selector on behavioral tree is a list of tasks. But we try each one. And the first that will be OK is all the sub-trees is OK. So I will try to open the door, but this task could be failed. This task could be failed because I need a key to open the door. So I will continue and go to another sequences that will try to unlock the door and finally open it. But it could be, in the task, unlock the door. I will check that I have the correct key for the door. But it could be, I did not get the correct key. So all this stuff could be failed. So finally, I could just smash the door. And after all these possibilities, possibly tasks, I will work through the door. So from this diagram, I describe a complex process with a lot of steps. The three main components that I use is the task. This is a simple abstraction to say, OK, do something. This is very easy to understand in programming language because it's just a method name. But behind this task, you will check your context of the environment of your video game, basically, to know if the task is doable or any context you want to test. After that, I have the sequence, so the arrow symbol, that it just do the next task if the previous task succeeds. And the selector, this is in fact like the or, the boolean or, because in fact it is do the next if the previous task fails. So in the selector, I don't do the task. I don't do all the tasks because I just do only tasks that say OK or fail. And I stopped to do the task if at the first succeeded task. OK. This is, I show you the representation of the behavior tree as a diagram. Now I will explain behavior tree as a piece of code. The main part of the behavior tree, we will describe the task. So I create a class task. And at each step of my process, I will call a method that's named a tick. A tick is related to time in the video game, but in our application or problem here, tree matching, the tick will be something else. But the important things that this method tick do something and return the status, the status of the task done. But the status is not just a boolean function, fail or success, it's a special enum with failure, success and running. So the first part is a task could say OK, I didn't finish, so just say running. So you need to test me again in the next tick. So after define the classical blocks, the task, I will create nodes and also define the nodes and the roots of my tree. So I need to create tree and each node and the roots of tree is related to child. So when you recreate a tick method for a tree element or task, I will be related to my parents and to my child. Because with this block, I could be inside the tree and the task block, it's a leaf, so I do not rely to anybody. With this, I could define my famous arrow symbol, so the sequence. So the sequence, the tick method in the sequence could take user data and return the status, but in fact is related to child. So for each child, I just call tick on the child with the context, don't use our data, and get this status. And I will handle this status as a task. So if my status is running, I'm also running. So recursively, from the leaf that say running, all my better tick could say, okay, I didn't decide what I've done. If I fail, I stop and all the sequences fail. And if I could check all my child, the sequence is a success. So it returns success. After the sequence, we have selectors. So the selector is like all. So in fact, we try old child, we check the status, like the sequence, if the sub-task is running, I'm also say running. But if sub-task success, I stop and say success. And if all my child fail, I fail too. With all that, we have just three basic blocks, but we could imagine another blocks. So if I understand the concept of any part of my better tree could say fail, success, or running, I could create, for example, a concurrent block, a concurrent block that will propose to test each child concurrently. So I could, in the new position of selector, just run a test and call tick on each child in order. But here, I will call tick in each, in any child. So I will enumerate my child, store in a statu-list all status of all my child when. And if all my child when has finished, I did not have a task still running. All my child could be fail or failure, but never running. I could check, I need only one success to say I'm successful. If I didn't have only one success, I fail. My concurrent test, my concurrent block say fail. And if I have still a running task inside my child, I'm still running. So with this kind of abstraction, I could, in a synchronous way, manage asynchronous processes, notably with the concurrent abstraction. So this is the presentation for the concept of behavioral trees. And now, how to use it? In a precise use case, that is tree matching. Tree matching, in fact, it comes at any moment where you need to do some data validation. You have a complex data representation inside your application, and you need to identify inside this big data tree some form and validate that is correct or incorrect. You could use tree matching when you want to do some data transformation because you want to match some form and rewrite inside your tree only this kind of data. And more generally, you always need tree matching when you want to do some data generation because you have a first data tree that you will traverse, identify some things and call some other method that creates another type of data. So you will have the first data tree that generates a second data tree. And in fact, all these use cases are in fact inside a compiler. When you want to identify some pattern in your bigger data tree, this is a semantic check because the meaning of what you write in your language represented into an IST, in fact, is good tree construction. All IST transformations could be done with tree matching and at the end, code generation is basically tree matching. All this stuff, in fact, are already done with functional language like ASCEL or another language that supports pattern matching. Pattern matching is a statement, a powerful statement in this kind of language because you could easily match a tree and a partially sub tree. To basically do a tree-on-link, you begin to write a recursive function that traverses all your tree in a top-down way and use a pattern matching to identify nodes, deconstruct it and do something with it and call some piece of code. This could be useful for a major part of your stuff, but when you want to do some tree reconstruction, to identify some part of data and rewrite it, you are not in a good way. You can't match in a top-down way because you begin to match roots before leaf, so you can't rewrite leaf. This is finished. If you want to do some tree reconstruction, you need to match and identify your tree in a bottom-up way. If you have more complex pattern matching that are deepest from only one level because you want to match an ancestor and a child deep at two or three levels because you want to check a special construction inside a statement for a language and other stuff like that, basically pattern matching is not enough. For all this kind of stuff, I think about behaviour trees and I have an intuition to test that behaviour tree is a certain way to do a finite state machine. But in academic definition, a behaviour tree is like a Yara-Marshi-Kol state machine. This is a kind of automata more adaptable and more versatile to the basic finite state machine. You don't have an explosion of states. You have a lot of good properties. So I try to use this kind of new way to describe a tomato behaviour tree to identify and to do tree matching. My main idea is to have a work method that allows us to traverse our data tree in the correct order, so bottom-up, and to notify our behaviour tree. The other good part is that a behaviour tree is a good representation and mimic pattern. I will describe for my tree-matching module a pattern of tree and this pattern is easily transformed into a behaviour tree using the concurrent abstraction. For example, here, this is a generic representation of pattern matching with data structure in Python. I begin to match a value. If this value is of the correct type, if this value type is inside the attribute name, if this value is OK concurrently, I could match other things that could exist inside the pattern data tree. With all this, I could easily translate my pattern into a behaviour tree. And it's also versatile because my need is to do traversal in bottom-up to allow reconstruction. But in fact, if you change some line of code, you have again a top-down pattern matcher. So it's completely versatile. You could use it in both ways. So let's create a generic Python tree. I create a class. I just do a mapping of k-words, parameters inside my attributes. So with my class, I could simulate any class with attributes. I create also something related to a dictionary to simulate the things that you could also match a dictionary, to match a key or the value part of a dictionary. The same thing for a list. And this could be a small part of a data tree that represents our challenge. So I could have an attribute and a list. Inside a list, I could have a dictionary, things like that. And to handle this kind of data tree, I need to relate to the basic reflection mechanism of Python with vars and gata.tr to iterate through attributes. And some types of collections, modules, like mapping, it's possible to know if my object is like a dictionary or is like a list. And use yield and yield form because my work traversal function will be used as a generator. And my work traversal function is also recursive. So I will send notifications through a yield statement. But my function is recursive. So my recursion must be yield form. If you understand the previous presentation, you understand why you use yield form here. Okay, this is a generic pattern of a universal working function that iterates for any tree in Python. I'll hide some data here. The big step is to identify what kind of tree I traverse. So my tree is it related to mapping or an iterable. And at the end, I directly iterate through common attributes. At each part, I yield from recursively my work function into the child. So this piece of code iterates any data tree. And at each IDEN port, in fact, I do notification. I do notification to yield. Okay, now I am matching a value. This is a value of the data. I have matching a type. This is the type. This is the name of the tree. This is the name of the key. This is the index of the list. With all this information, I could send it to a behavioral tree that compose and do pattern matching. And with this, I could identify a value or any value type, a component attribute, a list or dictionary, list, attributes, et cetera. So with all this stuff, I have one pattern, one subtree identified. But I need to do some more smart stuff because you could have tree inside trees, things like that. So I need just to identify a signal tree but a forest. So to identify forest, in fact, one pattern is correctly one behavioral tree. But in fact, I do N-concurrent pattern N-behavior trees with concurrent abstraction. When I work and traverse my tree, I must be aware of the storing of status and positioning inside my tree. So I can't store it inside the behavioral tree because the behavioral tree represents the pattern, not the actually partially identified sequence. So I need to create another store to store this sub-element. So my self.status, my privacy self.status that allow me to store the current status of a behavioral tree are now stored in the user data. User data is another parameter provided to the behavioral tree. So you have the behavioral tree that represents the structure of the pattern and all the data and current element are defined by another structure. And you need also to clean because you begin to identify with your behavioral tree and sometimes behavioral tree fails. So you need to clean up during the traversal of trees to be aware when a correct sequence are reached. Okay, I took all this and I put it on the module called tree matching on my GitHub. Soon I will distribute it in the PIP.  In fact, it was an embedded data cell through Python classes. So you could have, for example, match any type with the class any type. At any index, I want a tip, with this value, et cetera, et cetera. I could describe attribute and precisely this attribute. I want a full of tip int for any value. I don't care. I put it, I describe my pattern as a encapsulation of class instantiation. I send it to my bare matching battery and after that I use a match method on my data tree and the stuff are done. You could manage all these things. You could capture nodes and call back functions. After some cleaning and bugging, I need to write some documentation. After all that, I could send the module on PIP. Okay. I don't think we have a question. No? One question? One question? Any question? No? Okay. Thank you.


now I am happy to review any type of club on this channel but sometimes the clubs are not necessarily aimed at my handicap bracket and although I always try and give an opinion on a perspective based on my own ability in this case I feel like I need a little help. For today I've got two sets of irons that are very much aimed at the better player so I think we should go and knock on the door of Lewis see if we can get him out fel y gallwn gwneud o'r bwrdd y cyfnodd. Gwlywch yn gwneud i'r blwyd. Wel i'r... Fel ydych chi'n gweithio'r llai, dwi'n credu i chi'n cyfnodd. Wel, mae'n zydon. Mae'n gweithio'n gweithio'n gweithio'n gweithio, mae'n gweithio'r 2nd mae'r gweithi yn y fwy. Fel ydych chi'n gweithio'n ceisio'n gweithio, mae ysbryd a'r ffordd. Now these are without doubt, one of these in particular of the tour is very much not better played category I will talk about very soon but first of all I just want your immediate thoughts and give my opinion what do you think of the thoughts rather on the looks of these things? There's no doubt they look good, there's no doubt they look good.. In gas EHON they don't make a bad look in iron thats the question now a days Different to the 911 and I think the forges have got a little sleeker its certainly sort of the bottom of it and the top of it Ac mae'n gwneud oedd ychydig wrth gweithio. Yn wych yn fwy o ran y cwmwneud. Mae'n gweithio. Mae'n gwneud â'r tor, bwyd. Mae'r tor sy'n gweithio. Mae hwn yn fwy oedd yn gymryd. Mae'n ddau i gael. Mae'n fwy o merbyn o ran. Mae'n ddau. Mae'n ddau i gael. Mae'n ddau i gael. Mae'n ddau i gael. Mae'n ddau i gael. Felly dydym ond mor hwn wedi cael ei yn cofysg ac rydyn ni oedd yn ei frewad o'i gwaith ar gaelnig a fyddwn i'w dddefnyddio. Dwi'n meddwl, fel'u hynny wedi cael ei芬d-igawr byw. Rhydd o'n meddwl mae'n meddwl. Dwi'n meddwl yn ei anyddodol. Ond mor weithio, mae'n meddwl pobl yn cael iawn, oherwydd mae'n meddwl ei hyn. Mae dsylha i ddechrau'n gweld yn eich modd hyn sy'n meddwl, wedi cefnid i wyrdd o'n meddwl i ddiogelbyddau i ddawn hefyd. Mae'n olygu i gweledig â'r hwyl â hwnnw ychydig. Rydyn ni'n credu drwy o'r hollwch ar magnet yn fawr. Yn olygu i wneud am rhaid i ddaeth yn eu ddweud. Ac mae'n hwysgrifio populi성 ar maen nhw i'r dweud. A'n supported o'r hynry o asthex? Felly mae hynny yn dduig i'r ddysgu'r ystafello llachiaf. Mae'n ddysgu'r ddweud y swyddad yn ymell ynglynig yn maelfa wneud yn fitfynio. Mae wrth gwrs yn ddiw i gyd-dwygen. ..wyddon dwi'n flos iawn arma. Ond yn ôl sgol mae'n ddweud beth eich cymaint hayn iawn.. ..yna rhan o'ch ffordd sprouts? ..yna rhan o'ch ddweud beth eich cymaintyn.. ..yna'ch ffordd sprouts! Pawn ynglyn â'r gweldai yma yn bod yn eich gondol.. ..a hollion gweld o'r mewn genaf Aber cél... ..onlineg goff megasol yn gondol... ..yna y clyulsionon fwyaf... ..yna'r gweldai ymw cameras. Fynol yw gweld i'r hollion gweld yma yn y dyfynion fel yw, and check out some incredible giveaways and offers. It's right down here if it's there! It's alright, it seems to stop as well. I can't hear what you say in back there. It's alright. It's got there, it was alright, a couple of yards left to the pin. It's alright! It's alright, yeah! It's alright, very polite to stop! That's the forge. That's the forge, yeah! I mean, the video, Fe oeddwn i chi, rydyn ni'n amlion ddim, angen amlaen i'r club deilio i Mizuno. Felly wedi'u cwestiynau angen i'w gweithio'r gwybod i chi'n mynd i'w fanyddio, yw'n ysgrifennu? Dwi'n nhw'n rhan i. Rydyn ni'n rhan i. Felly mae angen i gwaelwch i'w gweithio. Dwi'n rhan i'n rhan? Felly mae no sio'n gwaith! Rydyn ni'n gweithio i Mizuno. Mizuno yn fwy o feddydd y fanydd ac yn rhan eisiau'r lleial nag hefyd. Mae wneud. I don't get the hype. Really? I just don't get it. Really? The reason why I've never played it. That is controversial. It is controversial. I know it's going to upset loads of people and I don't. The reason I've not played them is, I don't think they feel anything different than anyone else. Really? I don't. I think they look fantastic and I know why people buy them and I've probably never said that out loud because I used to fit these and stuff. I just don't get it. I'd hit these all the time and every single model I get why people love them. They perform great. But I just don't think they feel any different than anyone else. I'm going to say that. I'm going to hit these very shortly because I would disagree with that. I always think that the feel out of Mizuno irons is really good. I'm definitely in that camp. There's loads of people that are so controversial. I know and I think I'm not trying to be controversial. I've never got it. This is not the honest review. I've never got it. Let's get another ball down, hit the tall model and see what you thought over that and then we'll switch up an hour ago. It's small, isn't it? Super strike. We've got there. Oh my word. That's close as well, isn't it? There you go. Maybe do you like them? There you go. I mean the interesting thing is a really good shot. I think you got that a bit cleaner than what you did the first ball to be honest with you. I was really impressed with what the first ball had done because it wasn't your purest strikes that one was. You tell me what happened anyway. I hit them both okay. One's probably what? 15 foot one's probably a couple of feet away. Feels lovely. I'm stood over that thinking. I don't know why. I can't get it wrong. I can't get it wrong. Confidence inspiring is a thing in ions and how they look going oh yeah. Then this is the other way for me. I don't stand over a ball thinking oh god it is clean often but I am with them. They're noticeably smaller than most things. Yeah they are. It's interesting with Lou and that's why I like him on the channel because I like him as a from a professional's perspective the fact that you use P770s I think is like I said it could move because you're saying that I don't want to make the game as hard as I can. Even in P770s is a little bit of help there isn't it? People lose sight of what the game of golf is and it's a number in a box and I just want to get that lower. Yeah yeah. I think though you're trying to use clubs that make that easier for me. I wouldn't think that's making life hard. Yeah and even if these performed exactly the same as what I've got because of the look of them and because of it has that negative effect on mentality wise. Yeah yeah yeah I wouldn't put myself in some thicker off and try and sort of give it a bit more out of this. Yeah because you need to. I just wouldn't feel as though they just don't do anything for me. They feel great. That one felt great to be fair. Well let me have a couple of shots and I'll see what I can possibly manage. Like I said they're not for me but I'm going to hit a couple. Nice strike. Yeah I mean it was first of all nice strike interesting enough for me that was the forge model. What did you think of that in terms of? Just okay there was nothing that jumped out of it. It's one shot I think I'll swap in if you've got the sword here for you. Like behind the ball? I don't mind that to be honest with you that's not, I think that's you know I can deal with that. If I'm honest with you I'm not I'm not overly put off by smaller clubs. I don't mind it, it's weird isn't it? Cos I'm the by far the worst player the smaller head doesn't overly bother me. What I'd be more concerned is there is kind of like it wasn't the greatest swing it leaked out a little bit to the right but it doesn't seem to suggest as you know that kind of zip out the club face and maybe that's because I didn't get it out the middle and maybe that's the issue. Forgiveness is going to be the biggest deal. Nice. I mean that's a really pure strike. You can see again I can't get the distance that you could go. I think that's Bunker is it? It doesn't matter you know the loft is... You need to work with that. Yeah yeah that's it. I could have impressed how that performed. Yeah I mean to be honest it did well. It was a better swing and a better strike so it's hard for me to say. I think I'm going to leave my bit there and I'm going to reserve judgement. We've got a couple of four irons which again four iron and that is going to be scary we'll move to the next tee and see what we do there. It's a little pulley. Really nice sound that again you know. That's okay yeah. Slightly harder sound isn't it off that? Yeah. They're both slightly left of the pin but you tend to do that on this one. They're noticeable in performance I think.  This one's higher for me which I'm guessing they're last loft I don't really know. They always used to be but they're coming off way quicker. Way quicker. They both perform good. That's exactly where I was aiming to be quite honest with you. It's down a left a little bit but that's the toe model. I'm going to switch up into the other but at the minute I prefer the toe to be quite honest with you. Sounds different again. My line has definitely been a little bit guarded more down that left hand side. For me you know again both obviously forged clubs breaking there's a noticeable difference in the toe. It's so much softer in my opinion than this forged model it just feels a little bit harder to me. Solid. Super strike. That's so nice. It's nice that. Look at me changing my opinion now. I can't believe the sound difference here. It's incredible. Did you sound nice don't you? You haven't hit a bad shot with them have you? No and that was interesting because that was off the bottom grooves. I got that definitely down a bottom and it wasn't the end of the world let's say do you know what I mean? Big cut on that. That's performed okay hasn't it? A little bit out to the right but not too bad again. Probably again a bit surprising with it being a 4 iron that I don't know this forgiving words hard to quantify but that wasn't too bad to be fair. Right so we've got to finish it off with a couple of 4 irons off the T here on the 8th.  I like the feel of it. Oh my word. No it sounded really good. With the toe. I still wouldn't change my opinion on how it looks I still think very much it doesn't inspire me with confidence at all every ball I've hit with it fantastic feels great obviously these are weaker lofted so I'm not expecting the best performance ever but they do exactly what I imagine people want. It's the difference in the feel between the two. What did you think? So the second ball you're going to see now is Lou's hit in the Cromoli ball sorry I'm jumping the gun there but Arnie it's the Forge ball You got there before. So the Forge is is Grainville Forge with the Cromoli and it's noticeably feels different and that's kind of what I was kind of alluding to earlier with the feel I've never really got it is that's kind of my thing is you know I'm hitting that Forge thinking well I wouldn't purchase these for the feel I don't like these because they just don't feel any better than anything else. The toe great Forged performed better obviously I imagine all off the different but I think even I'm going to overlay now just a couple of shots of I attended with 4 iron to be fair hit the toe ball reasonably well got it off the bottom it's still performed probably better than I expected to but felt okay hit the club the Forge I really struggled with these names leaked the ball out to the right much higher ball flight but again just a harder feel off the face and I go back even to the previous models what you've just alluded to of the 2-2-5 range 2-2-3 2-2-1s or 9-2-1s 9-2-5 and again it's exactly the same as what you've mentioned there where Cromoli is introduced it ultimately just isn't that pure Forged feel you have to go to that really pure Forged element in all a line up and it is known to be different for me hands down the winner would be the toe model I'm not put off by the smaller profile I understand exactly the store process I'm a lot older than him and like these clubs are exactly what I started playing golf with so maybe it's just a visual thing doesn't bother me but the feel out of them and the sound I mean every time I hit a ball I could have told you which club you were using just by the noise I was hearing there's so much different harder is the sound I would suggest So you think there Missouna I've always been known for their feel through the range and what we're getting to now is for performance reasons I think they're getting away from that a little bit and they're keeping their feel in the toe model I would definitely go with that the toes well impressed the forged perform good but would you pick them for feel all that good I like it now I think it's a fair point to be honest and I think until these on cause videos and especially head to head videos if you like are really good because when you do that you notice the difference because you pick up one then you play the other and you can really notice the difference between the two so don't forget today's video is very much it's not technical there's no data that you've seen specifications in terms of the loft it's just been an immediate response to taking clubs out on the course in reality two very different handicap levels giving you their perspective hope you enjoyed what you have seen today if you've tried these and or attempted to try these let me know what your thoughts are and whether or not you'd be directed to one or the other as ever thanks to Lewis thanks to Hollywood Golf Club and I'll see you hopefully tomorrow night thanks for watching