Read up on genetic algorithms
In principle you can view the simulation as something like this.
Create an evaluation function for each move.
Play the game using a search algorithm using the evaluation function to pick the best move
Evaluate the results
Then you have to come up with a new evaluation function.
Typically you generate N random evaluation functions, run them all, pick some of the best ones and "breed" them together to create another N evaluation functions, rinse and repeat.
The breed phase is the interesting bit of code for me.