Sunday, May 8, 2011

My HTML/JavaScript Chess Game


For my optimization class last semester, I built an entire chess game using HTML and JavaScript. I also wrote an artificial intelligence algorithm to play as a computer player. My algorithm only does a two-ply (easy setting) or a three-ply (hard setting) search. It has about 20 different parameters it uses to score each move and decide which move it should take.

For my optimization class project, I also created a real-value genetic algorithm to optimize these 20 parameters and find the "best" settings for the computer player.

With more computing power, the computer player could be increased to a three- or four-ply search. But even with just the two-ply search I ran my genetic algorithm on, it took a pretty significant amount of computing time! We had 20-30 cores cranking away for about 2 weeks. Here are the stats after completing the genetic algorithm:

Total Generations:31
Total Players:128
Games Played:1,832
Turns Taken:637,900
Processing Time:3,830 core-hours (160 continuous days)

There are still a few small bugs that need to worked out in the game (castling sometimes doesn't work properly, en passant isn't possible, and a stalemate is treated as a checkmate). But overall, it's been a fun project to work on!


(Of course, this game is fastest in Chrome, and awfully slow in Internet Explorer.

No comments:

Post a Comment