It's time to write the fallback rule: If none of the other rules apply, then take the center square if it's free, or a corner square if one of those is free, or an edge square if necessary.

Take a moment to think about how to write this. You could do it this way:

silly best free with three branches

... but don't. That would be way more complicated than necessary. Instead, look for specific squares in the right order, e.g., 5,1,3,7,9,2,4,6,8. We don't really care which corner (or edge) we find, but it's easier to look in a specific order than to look by category.

This rule takes the position as input, rather than the triples, because we've given up on finding potential winning or losing combinations if all those rules failed. Now we just want a square, and it's easier to find it in a simple ordered list of squares. Don't forget, though, that free squares in the position are represented as _ rather than as a number.

We suggest for each item as the easiest way to do this.

This is the end of the required part of the project. You now have a procedure that plays a pretty good, but not perfect, tic-tac-toe strategy. Be sure to test your program thoroughly, on several board positions with different configurations of possible wins and losses. Then go on to the next screen.