From the course: AI Algorithms for Gaming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge solution

Challenge solution - Python Tutorial

From the course: AI Algorithms for Gaming

Start my 1-month free trial

Challenge solution

(upbeat music) - So let me show you my solution. First I'll update the utility function to use my Score Proximity function. In other words, I'll use line 218. Now let's see this evaluation function. So my evaluation function starts at line 427 and its name is Score Proximity, meaning that it outputs a score that is sensitive to how close the CAT is to a border. Remember that when the CAT reaches a border, the CAT wins. So the closer the CAT is to the border, the better the score. However, it may be a bit disappointing to you to learn that this function only considers straight line distances from the CAT to the borders. So if a border is not within the CAT's line of sight, so to speak, then this function will miss this exit for the CAT. So with that in mind, notice that the first thing I do is to declare an array of distances. And it's initialized with two distances. By the way, I need this list to be of length at least…

Contents