We had been working on creating an evolutionary AI that can learn how to play checkers. So far so good, our Neural Nets have been evolving for about 2 weeks now, and they are good enough to beat us, their creators!! (Skynet anybody?) However, we set up our board internals as red at the top, black at the bottom, counting the dark squares from 0 - 31, starting at the top left.
Come day of the server test, to see if our different AI's can actually connect and play a game, the teacher announced that everybody should represent their board as red (white) at the bottom, black at the top with 0 starting at the bottom left. We soon scrambled to find an easy way to convert it and with the help of classmate who loves creating equations for solving numerical puzzles came up with an equation to take our position 0 and represent it as 3, 1 as 2 and so forth. It was a rather simple equation that utilized integer devision and only took one line of code in order to get our board converted over for the server board everybody else had to use. Next we needed to take the boards we received from the server and convert them back into our internal representation so that our Neural Networks could evaluate them and choose the next move.
After staring at the first equation for a second and dreading having to solve for x, while keeping all of the necessary traits such as integer division, suddenly it hit us.... Its the same exact equation to go back!
int num = (2*(i/4))*4+3 -i;
Where i is position 0 - 31. I call it a "palindromial", the same equation forwards and backwards. In simple terms:
f(x) = y AND SO f(y) = x. Sure, its a really inefficient code, but we only needed a quick fix for our server code! At least we have our Neural Nets evaluating about 800,000 boards per second, and our entire board stored in three ints.
If you want to try your luck against Generation 284 (without the end game database) download and extract the file for your system. And then run the game by launching playcheckers_vs_black.exe
PlayCheckersx64
PlayCheckersx86
If you are unsure which version you need its probably the x64 version.
If you want the source code just let me know.
PlayCheckersx64
PlayCheckersx86
If you are unsure which version you need its probably the x64 version.
If you want the source code just let me know.
0 comments:
Post a Comment