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.


Easy Parallax Stars

Easy Parallax Stars

Don't these stars look great

I spent a long time messing around with chunks, loading, unloading, pooling, etc. before a friend suggested I came up with a much simpler way of getting parallax stars working easily.

Generate a load of random points in a square, each with a random z-value. Scale each point's speed according to the z-value to simulate the parralax (this way you can have as many layers of parallax as you want and to add more you can just increase the range of the z-value). Whenever a star leaves the screen, just spawn it in on the opposite side of the square. As long as your square is slightly bigger than the screen size then that's it, amazing-looking amazingly simple parallax stars. If you scale the star speed in the opposite way i.e. closer stars go faster then you get a king of underwater-y effect. Could be a nice look for a diving game.