My Attempt at a Chess Bot

My bot vs a randomly moving one

I made a chess bot in Java. Really I made a variety: randomly moving pieces around, greedily choosing the best next move, and finally using the minimax algorithm with alpha-beta pruning. The biggest challenge here was not the bot itself, but making a chess engine that efficiently generates possible moves, because even with alpha-beta pruning there is a massively fast growth in possible moves as you look more turns ahead. Consider generating moves for White's bishop. Not only do you need to generate the possible board positions, but for each board position you need to check that your King is not in check, or it is an illegal move. To do this you need to scan through the enemy pieces and see if, with the bishop in the new position, taking the white King is legal. It's easy to see how fast this grows as you go down the minimax tree.

I had grand plans to pit the bot against itself over and over again, until I realised that this deterministic machine would result in identical games on subsequent tries.

The result is a chess bot that beats me at chess, although I'm not the best benchmarking tool.