Write a program in your chosen language which plays a perfect game of tic-tac-toe on a 3 * 3 board against a human player. However, every move has to be a different program, generated from the previous iteration.
How and in what form you evaluate human input, is up to you, but it has to be read from the standard input. Similarly, you are free to choose a method how you will determine which player starts (for example, you ask first, or you allow the human to enter an invalid move to signal that the computer starts, or other ideas).
Validating moves is not necessary, you can assume a fairly playing human opponent.
Basically, you have program which corresponds to a state of the board. The state is printed in any recognizable way, but at least the following level of detail is expected:
X.. 00X x..
After the human player entered his moves, your program has to generate the next iteration of itself as a source file in the same language (either to standard output or to a file) and terminate. You are not allowed to store information anywhere else outside of that source file. (it is not necessary for your program to build and run the generated program, it can be done by the user - however, it's not forbidden). When the generated program is built and run, it will behave similarly, display the state, wait for user input, etc.
At the end of the game, you have to print the result (whether you won or it's a tie) in any unambiguously identifiable way.
By perfect play I mean the program must not lose, and if there is a possibility to force a win, it should win.
Shortest code wins, winner is selected at least 10 days after the first valid entry.
You get a 10% reduction in the score if your program can handle the building and launching of its next iteration. (I know, it's most probably not worth it) Of course, the program itself must be terminated by the time the next iteration accepts the moves from the user.
If you use some strange uncommon tricks, please post a short explanation with your code.