Slowly murderizing your code.
Made enough so you can play without an opponent, with win detection,
input validation and such. Not fully tested, but a good starting point.