CHAI, An Uncommon Chess Agent

How to Play Against CHAI
Download the Prolog program here. There are four queries you should use to interact with CHAI: new_game(Color), end_game, offer_draw, and move([RF,CF],[RT,CF]). new_game(Color) begins a game with Color as your color (white, black). end_game can be used to resign from the current game and should be used before the second new_game(Color). offer_draw will conclude the game if CHAI believes the current state of the game warrants a tie. move([RF,CF],[RT,CT]) will move the piece at [RF,CF] to square [RT,CT] where [0,0] is the top left of the board and [0,7] is the top right. You will only be allowed to move the piece if [RF,CF] to [RT,CT] represents a valid move for your color. After each move an ASCII depiction of the board is drawn to help you find these coordinates: in the drawing, the pieces are: pawn - 1, knight - 3, bishop - 4, rook - 5, queen - 8, king - 9, and empty - 0; black pieces are prefixed by a (-), white pieces by a (+).
Representative Output
This is how a typical game of chess played against CHAI looks. CHAI's first three moves are from his book of openings.
About CHAI
CHAI (CHess AI) plays chess worse than a drunken space monkey. But, hey, at least he's more cordial. Because I don't know how to write especially optimal prolog, I only programmed CHAI to think half a move ahead (a full move is one turn for each color) since any larger a search space gives a memory error. Even so, it still takes 10 to 20 seconds for CHAI to make a single move. He will however use an open book for common openings. CHAI wins nearly every game he plays, because no one really cares to finish a game with him (but let's blame that on the inconvenient interface).
Problems Encountered
By the time I was far enough along to implement a situation calculus the program was already too complex to make it worth finding out why that wouldn't work. It was also difficult keeping track of which clauses would work with which arguments as variables. I squandered several hours learning that in order to properly negate a clause that clause must return only one possible value for each of its variables.
Disingenuous Features (Known Bugs)
The game allows players to castle through check, doesn't implement en passant. Checkmate is not always properly detected (although I'm not sure why).
Effected by Shepherd McIlroy