I can imagine the code that your computer uses in my head.
Not badly coded, but not unbeatable. Which is good.
In order to beat Single Player, you have to set up two squares that are right next to each other, and put a piece that almost completes both. While the computer blocks one, you get the other.