I think understanding the math behind the game will definitely help you create an AI which will always win (if it can). This game is also known as Nim.

For a mathematical approach to always...