don't know of a script that's out there, but a friend of mine was working on a very similar project, and he had most of the classes for the different pieces written. if i remember right, where he got stuck was when he was trying to get the computer to decide between a couple paths 2-3 moves in advance.
i'll see if he still has what he was working with if you think it would help