The bot knows all winning patterns, if it detects you have 2/3 in any pattern, it will place an X wherever it calculates the 3rd one to be, and it works the same for it’s own placement. If you do not have any pattern, or only one placement, it will randomly place itself on the grid.