课程: AI Algorithms for Game Design with Python

免费学习该课程!

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

Solution: An iteratively deepening cat

Solution: An iteratively deepening cat

(upbeat music) - [Instructor] Let's look at my solution. We start at line 482 by initializing best_depth, which is the deepest successful depth we will report in the end, and output_move, which is the return value. The main loop starts at line 486 where we iterate for depths starting at 1 and ending in the maximum number of possible turns. In the body of the loop, the first thing we do is reset the reached_max_depth fly. Then, in lines 488 and 489, we perform limited depth search with the current depth and assign the resulting move to best_move. In line 491, we check if time is up, in which case, best_move will be a timeout, and so, we can exit this for loop and report the latest output_move, that is the best_move in the previous iteration of this loop. Now, if the limited depth finished on time, we go to line 494. First, we update output_move to the current value of best_move. Then, best_depth will be recorded as the current value of depth. In lines 496 through 499, we report the…

内容