How does it work?

I'm guessing you've done it in a special way because it's pretty trivial to create a program which always wins or ties, you just have to list all of the different situations and the correct move.