 So one of the things we introduced in the last video was this idea of an A star path finding algorithm That allows us to sort of again think about that idea of where we came from but more importantly Utilizing something known as a heuristic to Again make that assessment of how much further do I have to go and that's actually something that we're going to be Taking at least a little bit of a look at because it starts to motivate a lot of the different Algorithms that we use when we're trying to do searches and problem solving and so do even kind of present that I'm gonna switch up sort of a the problem if you will instead of it being just find a dot, you know find a spot and Find some kind of goal and then how do I you know traverse that goal or that path to that goal? Instead, let's take a look at something known as the sliding puzzle problem The entire idea at least it for the the graphic is I've have an eight puzzle Puzzle these little sliding things that you know when we are kids We used to just sort of get in knickknacks and party bags and the entire idea is I might have some Random assortment of my numbers for example my one may be on the bottom right And the goal of the puzzle is to slide tiles into that empty space So for example the three moves into here for example creating a new open slot And then I could slide the one into here and continue to do this until I reach a Goal situation where again the numbers are in Numerical order from left to right and you can see again I'm just asking what moves do I need to make from sort of the initial state to get to there Now when we think about the sliding puzzle problem any one puzzle Typically takes roughly speaking about 22 moves. So it would take roughly speaking 22 moves To get to our goal state and Just to keep a little bit of the vocabulary that we've seen throughout the the lecture so far We do kind of think about it as having a branching factor of about a three and what we're talking about there is specifically again how many Moves in One step how many possible Moves because again if we think about that well if I have my blank tile in the very center Then I have four positions that could potentially fill that in so that in essence is four moves But that's just for that centerpiece if I'm looking at say my corner piece Well, it only gets to be able to do two moves and finally if we're looking at sort of this edge piece It has a three move and so, you know just for our sake just to make it easier. We're doing some super quick You know Averaging going on there, you know a four plus a two equals six plus a three equals nine Three divided by nine turns into three. So we're just arbitrarily saying, you know Roughly speaking the puzzle the sliding puzzle problem has a branching factor of three. Okay, fine But again if we're starting to look at this from that same kind of perspective one of the things that we're dealing with is again just working through a Searching problem where whichever candidate we're looking at. We're simply saying all right. Well Am I at my goal condition? And so again, you can see we can start to structure this Very similar to how we worked off of the a star problem when it was just off of sort of airports and you know nodes in a graph But the problem is you know if we're making just one transition one step It's easy for us to establish what the g-value can be all right. I'm moving only one tile I can only do one slide But what about that H and specifically, you know, how much further do I have to go right again? I want my Puzzle pieces to look like this Seven eight. I want them to look like this and that's a little harder for us to Assess rather than a straight line or Manhattan distance. It's not as easy so what kind of heuristics can we work off of and so To kind of realize this, you know, one of the reasons that we would want to do this is, you know If we're looking at this from just a brute force breadth-first search kind of look We're generating so many possible conditions that it's very difficult for us to work off of again Look at how many pieces there are you can see, you know, that's a branching factor to a depth Equal to three to the 22nd 20 seconds power. It's a lot 20 seconds, whatever Either way, I'm gonna present to you instead two potential heuristics that we can look at just to evaluate this problem And hopefully get there again the big focal point for a heuristic Right is to not over Estimate and we'll see that a little bit more a little bit, but that's the big goal We don't want to overstep our bounds So again, if we're looking at it the first heuristic I'm gonna present to you is something I'm gonna call H1 and H1 is just going to say well look at whatever your state currently is in so here and Count how many of your tiles are in the wrong spot again? We know what our goal condition should look like so my heuristic is gonna be well. How many of those are just? Wrong well the twos in the wrong spot four six all of them are in the wrong spots So we would generate a heuristic of an eight and in that kind of sense, you know Oh, well, you know my heuristic for when I'm in the goal condition would be a zero because none of them are in the wrong spot And if we're thinking about this from sort of this path stepping down motion What we're essentially asking with our age here is for each one of those potential steps How many Tiles in the wrong Place Now once again, you know if we're looking at this They're all still going to be roughly speaking in the wrong place and so eight But again if we're working towards a gradual move to zero. Oh, this is starting to influence our decisions But that's just h1. I said I'm gonna show you two of them now h2 is actually going to say let's Utilize that Manhattan distance. We've shown it So let's take a look at it and say all right. Well for each one of my pieces for say for example seven What's the Manhattan distance from where it currently is to where it needs to be so it needs to be? right here so it would need one two Three potential moves for that and now you notice that second part Looking at each goal state or each one of the tiles in the goal state And so if you were to take all of those up and add them together So we just talked about that seven it would take three moves Well, if we then took a look at the two the two only needs to do one move or there's two If we were to look at the four the four needs to go one two four Next one five needs to just go to five Etc. Etc. Because again if we're looking at this we're just generating out some arbitrary number and this is just me walking through a few of those different Steps to kind of show you where those numbers are all coming from So what we can do with this is again We can translate this into the a star problem as I start to look at this sort of approach again I have sort of a starting point. I'll call this s zero and that s zero Has some branches that it can work off of now. We're dealing with an edge So it only has three potential moves. We could slide the five down We could move the four across or we could take the eight up Well, even with each one of those again the G's for them would all be one, right? Now if we're looking at it again from that perspective of using one of those heuristics Well, if I moved down my five, right? H one That heuristic would be only two of them are out of place Because fives in the right spot if I looked at the Manhattan distance All right. Well, we moved the five down. So again, that's a zero two needs to move one over one needs to move one over So we'd still get that two spot But what I'm sort of going at here is that would be sort of the decision for that first step If we're looking at the four moving across, right? So this was moving five down moving four across H one Well, now we've got one two three four Four moves in the wrong spot and then for the H two Again, we need to count out how many there need to be moved over the one would need to be moved over the two needs to be over So that's two five needs to be moved over and four needs to be moved over So again, we can see that that particular move would have a plus H of Four and then finally if we moved the eight up and the two let's see Again, those are still all in the wrong spot that one gets in the wrong spot I would believe off the top my head both of those would still be four, you know, that's that's sort of where we would go There we are But again, if we're starting to look at this again treating this like it's the a star problem Well, we still got that G we still see that that's a one We still see that H and we have our two potential or our three potential moves to work off that meant to be a four There we are so one one and one three Five and five Since we're dealing with a priority Q in the a star We see which one would be our next consideration and we would just start to expand it out as well And we continue to move through that