A Chess AI made for CMSC404 Final Project in JavaScript.
Partners: Rebecca Murphy & Robert Whitaker
-
If you do not already have Node.js and NPM (Node Package Manager) installed, install them from http://nodejs.org/
-
Once they are installed, open terminal and cd into the Chess-AI project directory and run "npm install". This will install the required dependencies.
-
When the dependencies finish installing, you can run the Chess AI with the following command: "node Play.js GAME_ID TEAM_COLOR". If, for example, the game ID is 500 and this AI is playing as the white team, to begin the AI, you would run: "node Play.js 500 White".
Our strategy used minimax with alphabeta pruning. We use prune move that would put kings in check and we sort our move list to maximize pruning. There are serveral extra checks in our alphabeta function. One that says if an move can take the opponents king, return turn that move without looking at anything else. Another check is for if you AI gets caught it a move loop. The last 4 moves sent to the server are stored in an array, we check if the new move found my alphabeta is in the cache. If it is, we redo alphabeta with that move pruned out of the tree.
Our Eval function considers four things for both sides, first it adds up each for the moving side, then subtracts each from oppositing side, and returns the value. The first is the material, which is just weighted score of all pieces. Next it rates the attack by checking if the King would be in check at then position, adds or subtracts a weighted amount based on the piece if the King would be in check. Then it rates the movebility of the move by adding to the amount of moves this move would leave to the over all score. The last check rates the positional, which weighs a piece based on its rank and location, with tables found at http://chessprogramming.wikispaces.com/Simplified+evaluation+function. It then calculate the value of all these for the opponent, and substracts them from moving player's score.