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.
Code example: An iteratively deepening cat - Python Tutorial
From the course: AI Algorithms for Gaming
Code example: An iteratively deepening cat
- [Instructor] Now it's time to look at our masterpiece, the iteratively deepening Cat. So, the CustomCat function selects iterative deepening by the ID flag. This is done in line 95. So we call the function IterativeDeepeningCat. So let's see that function. Once again in line 144, this is just a wrapper for iterative deepening, which by the way may be implemented with Alpha-beta pruning. And here it is in line 389. So in the first three lines, I do some bookkeeping, and the for loop starts at line 393. So here I'm iterating for i in the range from one to the size squared. That is, if we are working with a seven by seven hex grid, this will go from one to 49. That's because there are 49 possible moves for the opponent. I could have used infinity there, it doesn't make a difference. Now notice that I'm keeping a variable called reached maxdepth. This is just an optimization, in case we have a very short tree, so…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.