The Ai checks depth number of steps ahead It sees the best - possible outcome, then it will choses the best outcome. NOTE: Due to the mostly random nature of heads or tails, the Ai will not (even after millions of simulations) win the game 100% of the time. The program works best with 2-player games such as: Chess, and Tic Tac Toe.