课程: AI Algorithms for Game Design with Python

免费学习该课程!

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

Solution: A perfect cat in a small world

Solution: A perfect cat in a small world

(exciting music) - [Instructor] Let's look at my solutions, starting with max value. Starting at line 210, we have the logic for terminating the search just before time is up. The last call, MS constant is 0.5. So, half a millisecond before the deadline we start a chain of returns until we reach level 0 and return timeout. The first part you have to add was to check for terminal states, and that's in line 216. Since this is a max node, it's the cat's turn, and so a terminal state occurs when there are no legal moves left for the cat. That's why the check is as simple as legal moves being empty. Now, lines 217 through 219 have the action to take when we are at a terminal state. Take a moment to read this and make sense of it. Basically, it gives more importance to levels that are closer to level 0 and less importance to deeper levels when calculating the utility, which is a large negative number. That's because losing is the worst outcome for the cat. The sooner the defeat, the more we…

内容