I have taken the base code from the following link http://forum.codecall.net/topic/50892-tic-tac-toe-in-python/  The above link is code for 2-player tic-tac-toe game. I edited the code to make it a 1-player game. It was one of my assignments for Artificial intelligence class.