课程: AI Algorithms for Game Design with Python

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution: Write your own evaluation function

Solution: Write your own evaluation function - Python教程

课程: AI Algorithms for Game Design with Python

Solution: Write your own evaluation function

(upbeat music) - [Narrator] So let me show you my solution. As mentioned in the challenge instructions, all the to-do comments are merely suggestions. You were expected to come up with your own intelligent evaluation function. My solution will follow the suggestions in the comments. That is a combination of two scores for rewards and one for penalties. The first score is in line 218, and it uses my moves evaluation function. Notice that I'm normalizing this value by dividing it by six because there are at most six possible moves for the cat. That is move score will be a floating point number between zero and one. Next, in line 221, we have a proximity score that uses my straight exit evaluation function. This is also normalized to become a real number from zero to one. Then in lines 224 through 226, we calculate the Euclidean distance between the cat and the center of the hex grid, and from lines 228 to 230, I'm producing a penalty. based on this distance. We are penalizing a cat that…

内容